Skip to content

Instantly share code, notes, and snippets.

@mic-e
Last active December 30, 2016 16:07
Show Gist options
  • Save mic-e/8aad7d9d8fcbd2199c7140d301284d18 to your computer and use it in GitHub Desktop.
Save mic-e/8aad7d9d8fcbd2199c7140d301284d18 to your computer and use it in GitHub Desktop.
pixelflut sinewave, usage: python3 pixelflut.py 600 0.5 1 8 | pv | nc 151.217.25.113 1234
# the code is rather dirty but hey it works and it looks pretty amazing
import math
import itertools
import argparse
cli = argparse.ArgumentParser()
cli.add_argument('ypos', type=float)
cli.add_argument('freq', type=float)
cli.add_argument('amp', type=float)
cli.add_argument('order', type=int)
args = cli.parse_args()
while True:
for step in itertools.count():
for x in range(1024):
amplitude = (math.sin(step / 142)**2 * 50 + 5) * args.amp
freq = (0.1 + math.sin(step / 10) * 0.005) * args.freq
y = args.ypos + math.sin(step / 3) * 5 + sum(math.sin(freq * x * k)/k for k in range(1, 1 + args.order)) * amplitude
r = math.sin(1 + step / 5) / 2 + 0.5
g = math.sin(0.5 + step / 5) / 4 + 0.75
b = 1
print("PX %d %d %02X%02X%02X" % (int(x), int(y), int(r*255), int(g*255), int(b*255)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment