A2osX/EXAMPLES/MANDELBROT.F.txt
2021-07-28 18:50:59 +02:00

54 lines
779 B
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

NEW
AUTO 3,1
#!/bin/forth
140 CONSTANT MAXX
110 CONSTANT CENTERX
192 CONSTANT MAXY
96 CONSTANT CENTERY
16 CONSTANT MAXITER
0 VARIABLE X
0 VARIABLE Y
0 VARIABLE CX
0 VARIABLE CY
0 VARIABLE ZX
0 VARIABLE ZY
0 VARIABLE ZX2
0 VARIABLE ZY2
0 VARIABLE COLOR
: CELL
0 ZX !
0 ZY !
X @ CENTERX - CX !
Y @ CENTERY - CY !
0 COLOR !
MAXITER 0 DO
ZX @ ZX @ * 50 / ZX2 !
ZY @ ZY @ * 100 / ZY2 !
ZX2 @ ZY2 @ + 1000 > IF I COLOR ! LEAVE THEN
ZX @ ZY @ * 25 / CY @ + ZY !
ZX2 @ ZY2 @ - CX @ + ZX !
LOOP
Y @ X @ 4 * COLOR @ PLOT ;
: MANDELBROT
." Press a key to start..."
KEY GR
MAXY 0 DO
I Y !
MAXX 0 DO
I X !
CELL
LOOP
LOOP
KEY TEXT
." All done." ;
MANDELBROT
MAN
TEXT root/mandelbrot.f