-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen.py
executable file
·92 lines (82 loc) · 5.95 KB
/
gen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
header = """<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" viewBox="0 0 1000 1000">
<defs>
<!-- Cupcake path sourced from https://www.svgrepo.com/svg/65988/cupcake under CC0 -->
<!-- Scaled and translated to align to center on 1000x1000 canvas -->
<g id="cupcake" transform-origin="500 500">
<g transform="translate(500 500) scale(2.15982721382) translate(-229 -231)">
<path d="M388.909,272h-0.331c7.057-9.252,13.254-21.671,13.009-36.607c-0.331-20.188-12.399-39.939-35.868-58.705
c2.934-8.811,3.557-17.498,1.835-26.009c-6.824-33.717-43.412-47.183-76.987-54.669c1.193-3.964,1.842-8.162,1.842-12.51
c0-16.454-9.185-30.802-22.695-38.192C283.155,18.017,301.077,15,308.286,15c9.185,0,14.96,1.966,18.301,3.739
c2.599,1.379,5.749,1.157,8.091-0.623c4.361-3.315,3.799-10.016-1.037-12.589C328.261,2.663,320.085,0,308.286,0
c-14.379,0-27.865,6.616-39,19.132c-3.749,4.214-9.167,11.317-13.899,21.353C253.273,40.168,251.11,40,248.909,40
c-16.313,0-30.55,9.031-37.994,22.352c-2.725-3.011-5.735-6.95-7.856-11.408c-0.892-1.875-2.522-3.296-4.501-3.925
c-1.979-0.628-4.131-0.409-5.941,0.607c-22.422,12.578-38.793,29.335-48.66,49.806c-8.438,17.507-9.998,33.636-10.027,43.015
c-0.634,0.246-1.262,0.492-1.849,0.744c-19.413,8.32-30.607,24.159-32.375,45.804c-0.706,8.652,0.271,16.547,1.314,21.965
c-15.449,5.536-26.193,16.119-30.067,29.988c-3.058,10.948-1.48,22.826,3.939,33.053h-5.984c-2.281,0-4.438,1.038-5.862,2.821
c-1.423,1.783-1.957,4.116-1.452,6.341l37.169,163.546c2.448,10.77,11.871,18.292,22.916,18.292h214.457
c11.044,0,20.468-7.522,22.916-18.292l37.169-163.546c0.505-2.225-0.029-4.558-1.452-6.341
C393.348,273.038,391.191,272,388.909,272z M248.909,55c15.715,0,28.5,12.785,28.5,28.5c0,15.715-12.785,28.5-28.5,28.5
c-15.715,0-28.5-12.785-28.5-28.5C220.409,67.785,233.195,55,248.909,55z M121.681,448c-3.995,0-7.403-2.721-8.289-6.616
L78.305,287h24.274l26.813,157.306c0.218,1.28,0.525,2.51,0.898,3.694H121.681z M148.488,448c-1.362,0-3.617-2.16-4.308-6.214
L117.796,287h24.417l17.829,156.893c0.163,1.43,0.401,2.802,0.708,4.107H148.488z M176.651,448
c-0.522-0.849-1.352-2.701-1.704-5.801L157.31,287h24.513l8.891,156.471c0.091,1.608,0.231,3.117,0.417,4.529H176.651z
M221.409,448h-15.078c-0.257-1.285-0.51-3.059-0.642-5.379L196.847,287h24.039c0.009,0,0.018,0.002,0.027,0.002
c0.013,0,0.025-0.002,0.038-0.002h0.458V448z M252.129,442.621c-0.132,2.32-0.385,4.095-0.642,5.379h-15.078V287h24.562
L252.129,442.621z M281.168,448h-14.481c0.187-1.411,0.326-2.92,0.417-4.529L275.995,287h24.514l-17.637,155.199
C282.52,445.299,281.691,447.151,281.168,448z M309.331,448h-12.263c0.308-1.305,0.546-2.677,0.709-4.107L315.605,287h24.417
l-26.384,154.786C312.948,445.84,310.693,448,309.331,448z M344.426,441.384c-0.885,3.896-4.294,6.616-8.289,6.616h-8.61
c0.373-1.184,0.68-2.414,0.898-3.694L355.239,287h15.896c0.006,0,0.012,0.001,0.019,0.001c0.008,0,0.015-0.001,0.023-0.001h8.337
L344.426,441.384z M368.307,272h-115c16.863-8.811,38.706-21.158,59.289-35.598c3.391-2.379,4.211-7.056,1.832-10.447
c-2.379-3.391-7.056-4.211-10.447-1.832c-35.726,25.065-76.633,44.199-84.689,47.877H93.137
c-7.453-8.047-10.489-19.156-7.735-29.018c3.118-11.165,13.188-18.983,28.355-22.017c14.246-2.849,51.915-10.78,93.934-22.862
c3.98-1.145,6.28-5.3,5.135-9.281c-1.145-3.98-5.296-6.282-9.281-5.135c-37.454,10.77-71.4,18.197-87.991,21.608
c-2.293-12.345-3.808-39.07,22.437-50.318c10.129-4.341,30.656-8.079,52.388-12.036l7.26-1.325
c4.074-0.748,6.771-4.656,6.023-8.73c-0.748-4.075-4.656-6.771-8.73-6.023l-7.24,1.322c-14.033,2.555-27.579,5.023-38.632,7.726
c1.02-17.477,8.423-48.343,44.532-71.394c2.71,4.048,5.623,7.382,7.938,9.769c1.616,1.666,2.995,2.971,4.2,4.019
c-0.204,1.706-0.321,3.437-0.321,5.197c0,23.986,19.514,43.5,43.5,43.5c14.095,0,26.641-6.744,34.595-17.169
c14.792,3.146,27.032,6.785,36.917,11.036c1.875,2.837,1.618,4.876,1.099,6.505c-1.863,5.837-13.482,21.888-80.971,44.791
c-3.922,1.331-6.023,5.59-4.692,9.512c1.06,3.124,3.976,5.092,7.102,5.092c0.799,0,1.612-0.129,2.411-0.4
c24.19-8.209,43.814-16.407,58.327-24.366c18.367-10.073,28.872-19.909,32.114-30.069c0.239-0.749,0.43-1.497,0.59-2.246
c9.221,6.697,14.555,14.593,16.453,23.969c2.759,13.63-3.437,28.679-18.414,44.729c-2.826,3.028-2.662,7.774,0.367,10.6
c1.446,1.349,3.282,2.017,5.115,2.017c2.006,0,4.008-0.8,5.485-2.383c5.602-6.003,10.184-11.979,13.753-17.912
c17.96,15.076,27.19,30.181,27.431,44.933C386.858,252.009,376.05,264.893,368.307,272z"/>
</g>
</g>
<g id="spiral-component">
<use xlink:href="#cupcake" transform="rotate(0) translate(0 -450) scale(0.1)" transform-origin="500 500" />
</g>
"""
def spiral_0(i):
return """
<g id="spiral-0-{}">
<use xlink:href="#spiral-component" />
<g transform-origin="500 500" transform="rotate(9)"><g transform-origin="500 200" transform="scale(0.994)">
<use xlink:href="#spiral-0-{}" />
</g></g>
</g>""".format(i, i + 1)
def spiral_1(i):
return """
<g id="spiral-1-{}">
<use xlink:href="#spiral-0-1" />
<g transform-origin="500 500" transform="rotate(0.5) scale(0.78134306224)">
<use xlink:href="#spiral-1-{}" />
</g>
</g>""".format(i, i + 1)
footer="""
</defs>
<!-- DEBUG:
<rect fill="grey" x="0" y="0" width="1000" height="1000" />
<rect fill="red" x="500" y="500" width="500" height="500" />
<rect fill="red" x="0" y="0" width="500" height="500" />
-->
<use xlink:href="#spiral-1-1" />
</svg>"""
print(header)
for i in range(41):
print(spiral_0(i))
for i in range(20):
print(spiral_1(i))
print(footer)