Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[ALLY] Mandelbrot set

 [1/1] from: larry::ecotope::com at: 9-Oct-2000 19:02


This is a multi-part message in MIME format. ------=_NextPart_000_000B_01C03223.774923A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi folks, I just posted to the Ecotope rebsite a view script which plots the Mandelbrot set. It works ok, but gets pretty slow with large image sizes and a large number of iterations. With the default settings, it draws in about 8 seconds on my 450 MHz PII. I have attached a copy of the script. You can also view it by do http://www.nwlink.com/~ecotope1/mandelbrot.r I don't think it can be made to run much faster in REBOL. For larger and deeper images, all of the time is spent in the iteration loop, which I believe is coded in a nearly optimal fashion. Any suggestions for better color maps are wecome. Enjoy -Larry ------=_NextPart_000_000B_01C03223.774923A0 Content-Type: text/x-rebol; name="mandelbrot.r" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="mandelbrot.r" REBOL [ Title: "Mandelbrot" File: %mandelbrot.r Author: {Larry Palmiter Collin Olson} Date: 07-Oct-2000 Purpose: {Plot the Mandelbrot set} Category: [View VID 2] ] iter: func [ca cb num /local a b olda a2 b2] [ a: b: 0.0 repeat count num [ olda: a a2: a * a b2: b * b if (a2 + b2) > 4.0 [num: count break] a: a2 - b2 + ca b: 2 * olda * b + cb ] return num ] colors: make block! 256 repeat j 256 [append colors to-tuple reduce [256 - j j - 1 256 - j]] calcset: func [sc xo yo size [integer!] maxits [integer!] /local x y num color] [ im1: make image! to-pair size ;this is global repeat i size [ prog/data: i / size show prog repeat j size [ x: sc * ( i / size - .5 ) + xo y: sc * ( j / size - .5 ) - yo num: iter x y maxits if num < maxits [ color: pick colors to-integer (num / maxits * 256 + .5) poke im1 ((j - 1) * size + i) color ] ] ] im1 ] view layout [ style fld field 45x20 style lbl label 70x20 yellow title "Mandelbrot Set" across lbl "maxits" mi: fld "30" lbl "image size" sz: fld "200" return lbl "X-offset" xo: fld "-0.5" lbl "Y-offset" yo: fld "0.0" return lbl "scale" sc: fld "3.0" button "Calc" 124x20 [ view/new layout [ image calcset to-decimal sc/data to-decimal xo/data to-decimal yo/data to-integer sz/data to-integer mi/data ibevel button "Save Image" [save/bmp %mandelbrot.bmp im1] ] ] below prog: progress 254 ] ------=_NextPart_000_000B_01C03223.774923A0--