-
-
Save chmduquesne/2972943 to your computer and use it in GitHub Desktop.
Olà in Python / ASCII art
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
#!/usr/bin/env python | |
#-*- coding: utf-8 -*- | |
import os | |
import time | |
import random | |
ncols = 26 | |
nrows = 20 | |
def cls(): | |
os.system(['clear', 'cls'][os.name == 'nt']) | |
def ola(): | |
i = 0 | |
yield i | |
while True: | |
i = (i + 1) % ncols | |
yield i | |
def ola_row(length, center, width=1): | |
figures = [] | |
for j in xrange(length): | |
if i - width/2 + 1 <= j <= i + width/2 + (width%2): | |
figures.append('\o/') | |
else: | |
figures.append('.o.') | |
return "".join(figures) | |
ola_widths = [ random.randint(1, ncols/6) for i in xrange(nrows)] | |
for i in ola(): | |
cls() | |
line = ola_row(ncols, i, 3) | |
print "\n".join([ola_row(ncols, i, width) for width in ola_widths]) | |
time.sleep(0.2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment