Created
March 26, 2017 00:54
-
-
Save tylerneylon/e70a684b88809f74168f3a3618fd98a4 to your computer and use it in GitHub Desktop.
20 shortish lines that do something fun.
This file contains 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
import itertools, os, sys | |
it, chars = 20, '.-=*x#X' | |
sys.stdout.write('\x1b[?25l') | |
w = int(os.popen('tput cols').read()) | |
h = int(os.popen('tput lines').read()) - 1 | |
x_max, y_max = float(w) / (2.0 * h) * 1.2, 1.2 | |
for j in itertools.count(1): | |
sys.stdout.write('\x1b[1;1H') | |
x_max, y_max = x_max * 0.995, y_max * 0.995 | |
if j % 40 == 0: it += 1 | |
for y_ in range(h): | |
y = y_max * (float(y_) / h * 2 - 1) | |
for x_ in range(w): | |
x = x_max * (float(x_) / w * 2 - 1) | |
z, i, c = 0j, 0, x - 0.822 + y * 1j + 0.2j | |
while abs(z) <= 2 and i < it: | |
z, i = z * z + c, i + 1 | |
sys.stdout.write(' ' if i == it else chars[i % 7]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment