Skip to content

Instantly share code, notes, and snippets.

@tushuhei
Created January 3, 2018 22:26
Show Gist options
  • Save tushuhei/1a9ae56d7e1a00c0201ad077fc511764 to your computer and use it in GitHub Desktop.
Save tushuhei/1a9ae56d7e1a00c0201ad077fc511764 to your computer and use it in GitHub Desktop.
Art for new year card 2018
# 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>')
@tushuhei
Copy link
Author

tushuhei commented Jan 3, 2018

Output image.
2018-01-03 23 41 23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment