Created
January 3, 2018 22:26
-
-
Save tushuhei/1a9ae56d7e1a00c0201ad077fc511764 to your computer and use it in GitHub Desktop.
Art for new year card 2018
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
# coding: utf-8 | |
import random | |
stroke_width = 4 | |
radius = 10 | |
glyphs = { | |
'd': f'<circle cx="{radius}" cy="{radius}" r="{radius}" /><line x1="{radius*2}" y1="{radius}" x2="{radius*2}" y2="{-radius * 0.6}" />', | |
'o': f'<circle cx="{radius}" cy="{radius}" r="{radius}" />', | |
'g': f'<circle cx="{radius}" cy="{radius}" r="{radius}" /><path d="M {radius*2} {radius} C {radius*2} {radius*2}, {radius*2} {radius*2.8}, {radius} {radius*2.8}" />', | |
} | |
print('<meta charset="utf-8">') | |
print(''' | |
<style> | |
svg { | |
overflow: visible; | |
fill: none; | |
''') | |
print('width: %dpx;' % (radius * 2)) | |
print('height: %dpx;' % (radius * 2 + 10)) | |
print('stroke-width: %d;' % (stroke_width)) | |
print(''' | |
} | |
</style> | |
''') | |
for i in range(1000): | |
stroke = 'rgb(%d, %d, %d)' % (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) | |
print(f'<svg stroke="{stroke}">', glyphs['d'], '</svg>') | |
for j in range(random.randint(1, 3)): | |
print(f'<svg stroke="{stroke}">', glyphs['o'], '</svg>') | |
print(f'<svg stroke="{stroke}">', glyphs['g'], '</svg>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output image.
