day 15 svg visualization
parent
032c1df356
commit
5a7c8ef732
|
@ -0,0 +1,25 @@
|
||||||
|
<svg width="1000" height="1000" viewBox="0 0 4000000 4000000" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M 325337 1156002L 1738198 2568863 L 325337 3981724 L -1087524 2568863 L 325337 1156002" style="fill:#ff0000;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3988825 -768301L 5594946 837820 L 3988825 2443941 L 2382704 837820 L 3988825 -768301" style="fill:#ff3700;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 1611311 363595L 3300890 2053174 L 1611311 3742753 L -78268 2053174 L 1611311 363595" style="fill:#ff6e00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 101890 2603932L 1438007 3940049 L 101890 5276166 L -1234227 3940049 L 101890 2603932" style="fill:#ffa600;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3962702 2247845L 4273282 2558425 L 3962702 2869005 L 3652122 2558425 L 3962702 2247845" style="fill:#ffdd00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 2957890 1448846L 3669857 2160813 L 2957890 2872780 L 2245923 2160813 L 2957890 1448846" style="fill:#e8ff00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3907456 3015138L 4217928 3325610 L 3907456 3636082 L 3596984 3325610 L 3907456 3015138" style="fill:#b1ff00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3354177 2884329L 3905767 3435919 L 3354177 3987509 L 2802587 3435919 L 3354177 2884329" style="fill:#79ff00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3997379 2616205L 4453042 3071868 L 3997379 3527531 L 3541716 3071868 L 3997379 2616205" style="fill:#42ff00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 145143 766120L 1093985 1714962 L 145143 2663804 L -803699 1714962 L 145143 766120" style="fill:#0bff00;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 611563 2496305L 1264122 3148864 L 611563 3801423 L -40996 3148864 L 611563 2496305" style="fill:#00ff2c;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3080405 2610557L 4374625 3904777 L 3080405 5198997 L 1786185 3904777 L 3080405 2610557" style="fill:#00ff63;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 644383 -574325L 1229440 10732 L 644383 595789 L 59326 10732 L 644383 -574325" style="fill:#00ff9b;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3229566 1177170L 3746563 1694167 L 3229566 2211164 L 2712569 1694167 L 3229566 1177170" style="fill:#00ffd2;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 1600637 2812349L 2773172 3984884 L 1600637 5157419 L 428102 3984884 L 1600637 2812349" style="fill:#00f3ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 2959765 2275581L 3505044 2820860 L 2959765 3366139 L 2414486 2820860 L 2959765 2275581" style="fill:#00bcff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 2235330 2641704L 3021423 3427797 L 2235330 4213890 L 1449237 3427797 L 2235330 2641704" style="fill:#0085ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 2428996 -1555978L 4195855 210881 L 2428996 1977740 L 662137 210881 L 2428996 -1555978" style="fill:#004dff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 369661 -299603L 1357069 687805 L 369661 1675213 L -617747 687805 L 369661 -299603" style="fill:#0016ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3558476 1372938L 4309152 2123614 L 3558476 2874290 L 2807800 2123614 L 3558476 1372938" style="fill:#2100ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3551529 2279143L 4097490 2825104 L 3551529 3371065 L 3005568 2825104 L 3551529 2279143" style="fill:#5800ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 64895 -594317L 662789 3577 L 64895 601471 L -532999 3577 L 64895 -594317" style="fill:#9000ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
<path d="M 3079531 1245503L 3372687 1538659 L 3079531 1831815 L 2786375 1538659 L 3079531 1245503" style="fill:#c700ff;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />
|
||||||
|
</svg>
|
After Width: | Height: | Size: 3.9 KiB |
|
@ -0,0 +1,26 @@
|
||||||
|
data = []
|
||||||
|
for line in open("input"):
|
||||||
|
words = line.replace(":", "").replace(",","").split()
|
||||||
|
coords = [int(w[w.index('=')+1:]) for w in words if '=' in w]
|
||||||
|
data.append(coords)
|
||||||
|
|
||||||
|
import colorsys
|
||||||
|
def hsl(h,s,l):
|
||||||
|
r,g,b = colorsys.hls_to_rgb(h/360,l,s)
|
||||||
|
return int(r*255),int(g*255),int(b*255)
|
||||||
|
|
||||||
|
colors = []
|
||||||
|
for i in range(len(data)):
|
||||||
|
hue = i*300/len(data)
|
||||||
|
colors.append("#%02x%02x%02x" % hsl(hue, 1, .5))
|
||||||
|
|
||||||
|
print('<svg width="1000" height="1000" viewBox="0 0 4000000 4000000" xmlns="http://www.w3.org/2000/svg">')
|
||||||
|
for i,(sx,sy,bx,by) in enumerate(data):
|
||||||
|
dx = abs(sx-bx)
|
||||||
|
dy = abs(sy-by)
|
||||||
|
d = dx+dy
|
||||||
|
path = [(sx+d,sy),(sx,sy+d),(sx-d,sy),(sx,sy-d)]
|
||||||
|
s = "M %d %d" % (path[-1]) + " ".join("L %d %d" % (x,y) for x,y in path)
|
||||||
|
print('<path d="%s" style="fill:%s;fill-opacity:0.5;stroke:#000;stroke-width:5000px" />' % (s,colors[i]))
|
||||||
|
#print('<circle cx="3257428" cy="2573243" r="10000" fill="red" />')
|
||||||
|
print('</svg>')
|
Loading…
Reference in New Issue