RosettaCodeData/Task/Mandelbrot-set/BASIC/mandelbrot-set-2.basic

35 lines
765 B
Text
Raw Permalink Normal View History

2015-11-18 06:14:39 +00:00
fastgraphics
graphsize 384,384
refresh
2018-06-22 20:57:24 +00:00
kt = 319 : m = 4.0
xmin = -2.1 : xmax = 0.6 : ymin = -1.35 : ymax = 1.35
dx = (xmax - xmin) / graphwidth : dy = (ymax - ymin) / graphheight
2015-11-18 06:14:39 +00:00
2018-06-22 20:57:24 +00:00
for x = 0 to graphwidth
jx = xmin + x * dx
for y = 0 to graphheight
jy = ymin + y * dy
2015-11-18 06:14:39 +00:00
k = 0 : wx = 0.0 : wy = 0.0
do
2018-06-22 20:57:24 +00:00
tx = wx * wx - wy * wy + jx
ty = 2.0 * wx * wy + jy
2015-11-18 06:14:39 +00:00
wx = tx
wy = ty
2018-06-22 20:57:24 +00:00
r = wx * wx + wy * wy
k = k + 1
until r > m or k > kt
2015-11-18 06:14:39 +00:00
2018-06-22 20:57:24 +00:00
if k > kt then
2015-11-18 06:14:39 +00:00
color black
else
2018-06-22 20:57:24 +00:00
if k < 16 then color k * 8, k * 8, 128 + k * 4
if k >= 16 and k < 64 then color 128 + k - 16, 128 + k - 16, 192 + k - 16
if k >= 64 then color kt - k, 128 + (kt - k) / 2, kt - k
2015-11-18 06:14:39 +00:00
end if
2018-06-22 20:57:24 +00:00
plot x, y
2015-11-18 06:14:39 +00:00
next y
refresh
next x
imgsave "Mandelbrot_BASIC-256.png", "PNG"