Last active
October 6, 2017 12:15
-
-
Save kordless/0c9d9dec997bbc4d78b49a9adf01fd16 to your computer and use it in GitHub Desktop.
I wrote this code to generate images using primes. You'll need pyprimes to run it, which is here: https://github.com/uzumaxy/pyprimes. I don't know what this means, but it's definitely weird.
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
""" | |
Copyright (c) 2017, Kord Campbell | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in all | |
copies or substantial portions of the Software. | |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
SOFTWARE. | |
""" | |
import pyprimes | |
import os | |
import time | |
x = 1 | |
while True: | |
p = pyprimes.nth_prime(x) # grab a prime | |
fh = "{0:b}".format(p) # binary the prime | |
sh = fh[::-1] # make a mirror copy | |
s = "%s%s" % (fh[:-1], sh[1:]) # overlap the middle | |
for i in s: # render a line | |
if i == "1": | |
print u"\u2588", # print a square | |
else: | |
print " ", # print a blank | |
x = x + 1 # next prime | |
time.sleep(0.05) # animation speed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment