Mandelbrot set: Difference between revisions

Content deleted Content added
Basicgames (talk | contribs)
Chkas (talk | contribs)
zoom in and out
Line 5,118:
 
<syntaxhighlight lang="easylang">
center_x = 220
for y0 = 0 to 299
cycenter_y = (y0 - 150) / 120
scale = 150
for x0 = 0 to 299
background 000
cx = (x0 - 220) / 120
textsize 2
x = 0 ; y = 0 ; iter = 0
#
while iter < 64 and x * x + y * y < 4
proc draw . .
h = x * x - y * y + cx
clear
y = 2 * x * y + cy
for scr_y = x0 =to h299
itercy += 1(scr_y - center_y) / scale
for y0scr_x = 0 to 299
.
cx = (x0scr_x - 220center_x) / 120scale
if iter = 64
x = 0 ; y = 0 ; iter = 0
. repeat
color3 iter / 16 0 0 xx = x * x
move x0 / 3 y0 / 3 yy = y * y
until xx + yy >= 4 or iter = 128
rect 0.4 0.4
h = x * x - yh *= xx - yyy + cx
.
y = 2 * x * y + cy
x = h
x = 0 ; y = 0 ; iter += 01
.
if iter =< 64128
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
</syntaxhighlight>