mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 11:14:38 +08:00
Add mandelbrot snippet
This commit is contained in:
1 file changed
+31
@@ -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
|
||||
Reference in new issue
Block a user