Last active
October 11, 2018 17:32
-
-
Save amarioncosmo/e9e078f83128148a7671953c349ccefe to your computer and use it in GitHub Desktop.
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/python3 | |
| import numpy as np | |
| import sys | |
| import time | |
| import math | |
| import os | |
| def plot(array, width, height): | |
| size = len(array) | |
| y = [array[int(round(k*size/width)):int(round((k+1)*size/width))] for k in range(width)] | |
| y = [np.mean(k) for k in y] | |
| y = height*(y-np.min(y))/(np.max(y)-np.min(y)) | |
| res = np.array(list([list('#'*int(round(y[k]))+' '*int(round(height-y[k]))) for k in range(len(y))])) | |
| res = np.rot90(res, k=1, axes=(0,1)) | |
| for r in res: | |
| print('\033[94m' + ''.join(r)+'\033[0m') | |
| def f(x): | |
| return [math.sin(x+k/200) for k in range(-500,500)] | |
| def wave(n=100): | |
| for k in range(n): | |
| print(chr(27)) | |
| print('\033c') | |
| print('\x1bc') | |
| rows, columns = os.popen('stty size', 'r').read().split() | |
| plot(f(k), int(columns)+3, int(rows)-1) | |
| time.sleep(0.1) | |
| sys.stdout.flush() | |
| if __name__=='__main__': | |
| wave() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment