RosettaCodeData/Task/Mandelbrot-set/EasyLang/mandelbrot-set.easy

52 lines
1.0 KiB
Plaintext

center_x = 220
center_y = 150
scale = 150
background 000
textsize 2
#
proc draw . .
clear
for scr_y = 0 to 299
cy = (scr_y - center_y) / scale
for scr_x = 0 to 299
cx = (scr_x - center_x) / scale
x = 0 ; y = 0 ; iter = 0
repeat
xx = x * x
yy = y * y
until xx + yy >= 4 or iter = 128
h = xx - yy + cx
y = 2 * x * y + cy
x = h
iter += 1
.
if iter < 128
color3 iter / 32 iter / 128 0
move scr_x / 3 scr_y / 3
rect 0.4 0.4
.
.
.
color 990
move 1 1
text "Short press to zoom in, long to zoom out"
.
on mouse_down
time0 = systime
.
on mouse_up
center_x += 150 - mouse_x * 3
center_y += 150 - mouse_y * 3
if systime - time0 < 0.3
center_x -= 150 - center_x
center_y -= 150 - center_y
scale *= 2
else
center_x += (150 - center_x) / 2
center_y += (150 - center_y) / 2
scale /= 2
.
call draw
.
call draw