Created
November 13, 2015 10:14
-
-
Save zaltoprofen/3240184baf2c7d042fe7 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
#from PIL import Image, ImageDraw | |
from svgwrite import Drawing, rgb | |
from cmath import tan, pi | |
import hashlib | |
a = hashlib.sha256(input('key: ').encode('utf-8')) | |
digest = a.digest() | |
#img = Image.new('RGBA', (256, 256), (255, 255, 255, 255)) | |
#draw = ImageDraw.Draw(img, 'RGBA') | |
draw = Drawing('icon.svg', size=(256, 256)) | |
# num of polygons | |
M = 3 | |
# num of params | |
N = 7 | |
for i in range(M): | |
p = N * i | |
width = int(digest[p]/255 * 100 + 50) | |
center = int(digest[p+1]) | |
diff = int(digest[p+2]) - 128 | |
side = digest[p+3] % 2 == 0 | |
r = int(digest[p+4]) | |
g = int(digest[p+5]) | |
b = int(digest[p+6]) | |
poly = [(int(center - width/2), 0), | |
(int(center + width/2), 0), | |
(int(center + width/2 + diff), 255), | |
(int(center - width/2 + diff), 255)] | |
if side: | |
poly = [(p[1], p[0]) for p in poly] | |
draw.add(draw.polygon(points=poly, fill=rgb(r, g, b), fill_opacity=0.8)) | |
draw.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment