Last active
October 23, 2016 01:07
-
-
Save G33kDude/7ab8b3cfbc34ea436eb3d4301a810fc3 to your computer and use it in GitHub Desktop.
Outputs an ASCII mandelbrot set representation without using floating point numbers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
p = 999 | |
s = 15 | |
for py in range(21*s//10): | |
row = '' | |
for px in range(35*s//5): | |
x0 = (px-50*s//10)*p//s//2 | |
y0 = (py-10*s//10)*p//s | |
x=0 | |
y=0 | |
i=0 | |
m=99 | |
while (x*x + y*y < 2*2*p*p and i < m): | |
t = x*x//p - y*y//p + x0 | |
y = 2*x*y//p + y0 | |
x = t | |
i += 1 | |
row += '*' if i == m else ' ' | |
print(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment