Skip to content

Instantly share code, notes, and snippets.

@chmduquesne
Forked from brunobord/ola.py
Created June 22, 2012 14:12
Show Gist options
  • Save chmduquesne/2972943 to your computer and use it in GitHub Desktop.
Save chmduquesne/2972943 to your computer and use it in GitHub Desktop.
Olà in Python / ASCII art
#!/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