X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=examples%2Fmandelbrot.4th;h=b8af203c870210f478254b0be53686e1c3e9d400;hb=fca502cc9896f8289b80f20d515f2adbf88ce6a0;hp=d31b028cacac3b5b1000b30cf3ccae6382b64de5;hpb=3497073ce4fa8c523c05c4959b0c574c3c3bebcc;p=forth.jl.git diff --git a/examples/mandelbrot.4th b/examples/mandelbrot.4th index d31b028..b8af203 100644 --- a/examples/mandelbrot.4th +++ b/examples/mandelbrot.4th @@ -1,7 +1,7 @@ ( --- Complex arithmetic --- ) ( Location of floating point. ) -: precision 10000 ; +10000 value precision : sign dup abs / ; @@ -47,11 +47,13 @@ 2over 2swap csq c+ ; +100 value maxiter + : inSet? ( cr ci -- res ) 0 0 ( z_0 = 0 ) true ( flag indicating set membership ) - 100 0 do + maxiter 0 do drop iterate @@ -68,11 +70,11 @@ -rot 2drop -rot 2drop ; -: xsteps 100 ; -: ysteps 30 ; +100 value xsteps +30 value ysteps ( Draw the Mandelbrot Set!) -: mandel ( x1 y1 x2 y2 -- ) +: mandeldraw ( x1 y1 x2 y2 -- ) 0 pick 3 pick - ysteps / 1 pick 4 pick do @@ -97,3 +99,11 @@ ( Clean up - hide non-standard multiplication def. ) hide * + +( Default picture ) +: mandel + -2 0 >scaled -1 0 >scaled 0 5 >scaled 1 0 >scaled + mandeldraw +; + +.( Enter 'mandel' to draw the Mandelbrot Set.)