Add mandelbrot snippet

This commit is contained in:
coolreader18 committed 2019-02-23 11:05:51 -06:00
1 parent b89d95c4c6
commit 6e8b88e1fd
1 file changed
+31
+31
View File
@@ -0,0 +1,31 @@
# NOTE: will take a while, up to around a minute, to run.
# Expect this page to freeze.
w = 50.0
h = 50.0
y = 0.0
while y < h:
x = 0.0
while x < w:
Zr, Zi, Tr, Ti = 0.0, 0.0, 0.0, 0.0
Cr = 2 * x / w - 1.5
Ci = 2 * y / h - 1.0
i = 0
while i < 50 and Tr + Ti <= 4:
Zi = 2 * Zr * Zi + Ci
Zr = Tr - Ti + Cr
Tr = Zr * Zr
Ti = Zi * Zi
i = i + 1
if Tr + Ti <= 4:
print('*', end='')
else:
print('·', end='')
x = x + 1
print()
y = y + 1