Last active
August 29, 2015 14:15
-
-
Save olls/393104bbd4b5a2ce8094 to your computer and use it in GitHub Desktop.
Trying to golf down an animated, coloured ASCII sine wave. Usage: `python3 sine.py [width] [height]`
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 math,time,sys | |
j,i,p=int,0,print | |
W,H=map(j,sys.argv[1:]) | |
while 1:y=0;exec("x=0;exec(\"d=math.sin(x*6/W)*math.sin(i);p('\x1b[3'+str(j(abs(d)*8))+'m'+' #'[j(H/2*(1+d))==y],end='');x+=1;\"*W);p();y+=1;"*H);i+=.1;time.sleep(.1) |
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 math,time | |
i=0 | |
while 1:i+=.3;a=math.sin(i)*4+4;print(int(a*2)*' '+'\x1b[3'+str(int(a))+'m#');time.sleep(.01) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment