[futurebasic] Re: [FB] Julia Fractal Demo

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2003 : Group Archive : Group : All Groups

From: Joe Lewis Wilkins <PepeToo@...>
Date: Sat, 20 Sep 2003 00:09:03 -0700
Gorgeous Robert, gorgeous!

Joe Wilkins

Robert Covington wrote:

> From METAL Basic examples.
>
> Robert Bob
>
>
> // BEGIN FB3 Program
>
> 'METAL Julia by Ivan Freyman © July 2000
> 'Email:  pixelman@...
> 'This program plots the Julia set, using the
> 'equation Z(next)=Z(Current)^2+C, where C is a
> 'constant throughout the process.
> 'Both Z and C are complex numbers on the Gaussian Surface.
>
> // Conversion and changes to FB3:  Robert Covington, <artlythere@...>
>
> _infinity       = 9999
> _MaxInterations = 400// 200 in original. 2000 lightens things up a bit
>
> clear local
> DIM as double scrn,y,x,xl,xh,yl,yh,r,r2,i,xb,rat
> Local FN Julia_Thing(rct as ^Rect)
> DIM as long rr,gg,bb
> DIM as int sx,sy,maxi,xp,yp,iter,draw
>
> sx = rct.right
> sy = rct.bottom
>
> scrn = 1                'Image size (inversly proportional)
> maxi = _MaxInterations              'Maximum # of iterations to perform
>
> xl = -1.6   'Coordinates of view window
> xh = 1.6    'Mandelbrot set
> yh = 1.2
> yl = -1.2
>
> yp = 0
> y = yh
> for y = yh to yl step  (yl - yh) / sy * scrn
> xp = 0
>  yp = yp + 1
> x = xb
>  for x= xl to xh step (xh - xl) / sx * scrn
> xp = xp + 1
> r = x:i = y
>
> for iter=0 to maxi                'Set up loop to iterate point.
> r2 = r * r - i * i + .32          'Complex multiplication.
> 'You can change the numbers .32 and .043 for other Julia set.
> i = 2 * r * i + .043
> // RC : Try .045
> r = r2
> long IF r*r+i*i > 20 'Escape to infinity check
>  r2=iter
>  iter = _infinity
>  GOTO "plotit"
> END IF
> next          'it close
> "plotit"
> long if iter= _infinity
> rat = log(r2+5)/log(maxi)
> rr  = (sin(rat*11+.9)+1)*32000/(sgn(i*r)/10+1.1)
> gg  = (sin(rat*9+.9)+1)*32000/(sgn(i*r)/10+1.1)
> bb  = (sin(rat*7)+1)*32000/(sgn(i*r)/10+1.1)
> long color  bb,gg,rr// RC: rr,gg,bb is in original
> //RC: swap of r & B channels makes for a cool look
> Plot xp,yp
> end if
> next x                         'End loops
> if FN button then exit For // Get me out of here
> long if draw = 4// RC : Plot is slow enough , but too many 
> FlushWindowBuffer
> // is a drag!
> handleEvents // RC : FlushWindowBuffer and no spinning cursor too.
> draw = 0
> xelse
> inc(draw)
> end if
> next y
>
> end fn
>
> DIM as rect r
> SetRect(r,0,0,700,500)
>
> Window 1, "Julia",(0,0)-(700,500),_doc
> paintRect(r)
> FN Julia_Thing(r)
>
> do
> handleEvents
> until FN button
>
> ' END FB3 PROGRAM
>
> --
> To unsubscribe, send ANY message to 
> <futurebasic-unsubscribe@...>
>
>