Неизвестный фрактал

 


Клоповник пейсбук только и хорош отдельными группами, посвященным компьютерам. Пару дней назад нашлись посты, в которых были исходники без названия:

;503122196_4140937976151410_2334423112045921720_n.jpg
w=1280
h=720
zoom.f=2/w
dmin.f=0.06
  If OpenWindow(0, 0, 0, w, h, "fractal QB64", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    CanvasGadget(0, 0, 0, w, h)
    If StartDrawing(CanvasOutput(0))
      Box(0,0,w,h,0)
      For a=0 To w-1
        For b=0 To 1.5*h
          x.f=(a-w)*zoom
          y.f=(b-h)*zoom
          i=0
          d.f=100
          Repeat
            u.f=x*x
            v.f=y*y
            If (u+v)>4.8 Or i>30 Or d<dmin
              Break 1
            EndIf
            y=2*x*y+0.156
            x=u-v-0.8
            i=i+1
            n.f=Abs(u+v-1)
            If n<d
              d=n
            EndIf
          ForEver
          If d<dmin
            coul=255-Int(4000*d)
            If coul<0
              coul=0
            EndIf
            If coul>255
              coul=255
            EndIf
            x1.f=a-w/2
            y1.f=b-h/2
            x2.f=w+w/2-1-a
            y2.f=h+h/2-b
            LineXY(x1,y1,x1+1,y1+1,RGB(coul,coul,0))
            LineXY(x2,y2,x2+1,y2+1,RGB(coul,coul,0))
          EndIf
          Next b
          Next a
            StopDrawing()
          EndIf
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  EndIf
If OpenWindow(0, 0, 0, 640, 480, "unknown fractal", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  CanvasGadget(0, 0, 0, 640, 480)
  If StartDrawing(CanvasOutput(0))
    Box(0,0,640,480,0)
    dmin.f=0.06
    x01.f=-1.3
    x02.f=1.3
    y01.f=-1
    y02.f=1
    inc.f=2.6/640
    a.f=x01
      px_=0
    While a<=0
      b.f=y01
      py_=0
      While b<=y02
        x.f=a
        y.f=b
        i=0
        d.f=100
        For i=1 To 30
          u.f=x*x
          v.f=y*y
          If (u + v) > 4.8 Or d < dmin
            Break 1
          EndIf
          t.f = u - v
          y = 2 * x * y + 0.156
          x = t - 0.8
          n.f = Abs(u + v - 1)
          If n < d
            d = n
          EndIf
        Next i
        If d < dmin
          coul = 16 - Int(Sqr(2000 * d))
          If coul < 0
            coul = 0
          EndIf
          If coul > 15
            coul = 15
          EndIf
          ;PSET (a, b), coul
          Box(px_,py_,1,1,RGB(coul*16,coul*16,0))
          ;Debug coul
          ;PSET (-a, -b), coul
          Box(640-px_,492-py_,1,1,RGB(coul*16,coul*16,0))
        EndIf
        py_+1
        b=b+inc
      Wend
      px_+1
      a=a+inc
    Wend
    StopDrawing()
  EndIf
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

Исходники


Комментарии