X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=blobdiff_plain;f=examples%2Fmandelbrot.4th;fp=examples%2Fmandelbrot.4th;h=55f746eec222d3eaaea9fd8749e3add6e86be489;hb=91c9ee133605d4d8871b897b109a60f401b3aa79;hp=c75ebd0f3054acff1d3174bfe7184f1696e7ff47;hpb=3de60226999be55f55a944418c6794faf623509d;p=forth.jl.git diff --git a/examples/mandelbrot.4th b/examples/mandelbrot.4th index c75ebd0..55f746e 100644 --- a/examples/mandelbrot.4th +++ b/examples/mandelbrot.4th @@ -3,7 +3,15 @@ ( Location of floating point. ) : precision 10000 ; -: >scaled precision 10 / * swap precision * + ; +: sign dup abs / ; + +: >scaled + precision 10 / * over + ?dup 0<> if + sign * + then + swap precision * + +; ( Redefine multiplication. Yay forth! ) : * precision */ ; @@ -48,9 +56,20 @@ loop ; +: xsteps 100 ; +: ysteps 50 ; + ( Draw the Mandelbrot Set!) : mandel ( x1 y1 x2 y2 -- ) + 1 pick 4 pick - + 2 pick 5 pick do + i 0 inSet? if + 42 emit + else + '.' emit + then + dup +loop ; ( Clean up - hide non-standard multiplication def. )