Dark Fractals by Richard Davey12th Sep 2003 13:15
|
---|
Summary This code will produce a 640x480 pixel mandelbrot fractal with a user-definable set of maximum iterations. It syncs on every line to show progress, but a sync after the next y lin Description ========================================================== Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` Dark Fractals ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` By Rich Davey (rich@fatal-design.com) ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` My thanks to BjornLynne for providing ` the music during the coding of this ! ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- sync rate 0 sync on hide mouse cls rgb(255,255,255) start_time=timer() MinX#=-1.75; MaxX#=1.75; MinY#=-1.75; MaxY#=1.75 ` Uncomment the following (and comment the line above) ` for a more zoomed-in fractal. Play with the values for different patterns ` MaxX and MaxY = zoom, MinX and MinY = alignment ` ` MinX#=-2.75; MaxX#=2.75; MinY#=-2.75; MaxY#=2.75 ` Start drawing dx#=(MaxX#-MinX#)/640 dy#=(Maxy#-MinY#)/480 for y=0 to 480-1 for x=0 to 640-1 pixel_color#=calc_pixel(MinX#+x*dx#,MinY#+y*dy#)*20 ink rgb(pixel_color#,0,pixel_color#),rgb(0,0,0) dot x,y next x sync next y end_timer=timer() ` Show time to render set cursor 0,0 ink rgb(255,255,255),rgb(0,0,0) print "Time to render ", end_timer, " milliseconds" wait key save bitmap "fractal2.bmp" end ` End! function calc_pixel(ca#,cbi#) ` You can change max_iteration for a more detailed fractal ` Suggested values = 16, 32. 64, 128 & 256 (larger = slower) max_iteration=64 a#=0 b#=0 iteration#=0 repeat old_a# = a# a# = a#*a# - b#*b# + ca# b# = 2 * old_a#*b# + cbi# length_z# = a#*a# + b#*b# inc iteration# until length_z#>4 or iteration#>max_iteration pixel_color#=iteration# endfunction pixel_color# |