REBOL [ title: "Mandelbrot" author: cyphre@rebol.com Type: 'graphic Purpose: "Standard mandelbrot set calculations" ] time: func [b /local start] [ start: now/precise do b print ["Time:" difference now/precise start] ] img-size: 512x384 isx: img-size/x isy: img-size/y img: make image! img-size img/rgb: 48.64.80 view/new layout [origin 0 ii: image img] mandelbrot: rebcode [/local w h px py nbi inc side zoom d h2 hd v ar ai a b length colr colg idx cr ci zr zi it xd yd yy][ set w 256 set h 256 set px isx sub.i px w div.i px 2 set py isy sub.i py h div.i py 2 set nbi 256 set inc 0.1 set side 2.5 set zoom 0.0097 set d side set h2 h to-dec h2 div.d d h2 sub.d d zoom set hd 2.35 set v 0.5969 set ar hd sub.d ar 2.0 set ai v sub.d ai 1.25 set a 0.0 set b 0.0 set length 0.0 set colr 0 set colg 0 set idx 0 set cr 0.0 set ci 0.0 set zr 0.0 set zi 0.0 set it 0 repeatz y h [ repeatz x w [ set xd x to-dec xd set yd y to-dec yd set.d cr xd mul.d cr d add.d cr ar set.d ci yd mul.d ci d add.d ci ai set.d zr cr set.d zi ci set.i it 0 until [ label inner-loop set.d a zr mul.d a zr set.d b zi mul.d b zi set.d length a add.d length b sqrt length mul.d zi zr mul.d zi 2.0 add.d zi ci set.d zr a sub.d zr b add.d zr cr add.i it 2 gt.d length 2.0 breakt gt.d it nbi breakt bra inner-loop ] set.i colr it sub.i colr 32 lt.i colr 0 ift [set.i colr 0] lsl colr 16 set.i colg it sub.i colg 16 lt.i colg 0 ift [set.i colg 0] lsl colg 8 or colr colg lt.i it 0 ift [set.i it 0] gt.i it 255 ift [set.i it 255] or colr it set.i idx py add.i idx y mul.i idx isx add.i idx px add.i idx x poke img idx colr ] set.i yy y rem.i yy 16 eq.i yy 0 ift [ apply res show [ii] ] ] ] time [mandelbrot] wait []