Created
June 14, 2017 22:40
-
-
Save kmcallister/0f18b776ad1be05bf99d02fe48b1139e to your computer and use it in GitHub Desktop.
oscilloscope sierpinski triangle
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/env python | |
| import sys | |
| import struct | |
| import random | |
| funcs = [ | |
| lambda (x, y): (x/2.0, y/2.0 + 1.0), | |
| lambda (x, y): (x/2.0 - 1.0, y/2.0), | |
| lambda (x, y): (x/2.0 + 1.0, y/2.0), | |
| ] | |
| point = (0.0, 0.0) | |
| scale = int((2**15 - 1) / 2.0) | |
| while True: | |
| sys.stdout.write(struct.pack('<hh', | |
| int(point[0] * scale), | |
| int(point[1] * scale))) | |
| point = random.choice(funcs)(point) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment