27 lines
950 B
Python
27 lines
950 B
Python
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>')
|