addedd images
This commit is contained in:
@ -22,20 +22,35 @@ def main():
|
||||
graph[tokens[1]] = set()
|
||||
graph[tokens[1]].add(tokens[2])
|
||||
|
||||
import svg
|
||||
canvas = svg.SVG(
|
||||
width=40,
|
||||
height=40,
|
||||
elements=[
|
||||
svg.Circle(
|
||||
cx=20, cy=20, r=18,
|
||||
stroke="black",
|
||||
fill="yellow",
|
||||
stroke_width=2,
|
||||
),
|
||||
],
|
||||
)
|
||||
print(canvas)
|
||||
for (k, v) in graph.items():
|
||||
# svg base data
|
||||
color_circle_up="yellow"
|
||||
color_circle_down="yellow"
|
||||
color_rectangle="white"
|
||||
color_number="black"
|
||||
|
||||
if 'bus' in v:
|
||||
color_circle_down="green"
|
||||
if 'underground' in v:
|
||||
color_rectangle="red"
|
||||
color_number="white"
|
||||
|
||||
with open(f"../data/{k}.svg", "w") as f:
|
||||
f.write("<svg height=\"64\" width=\"64\" xmlns=\"http://www.w3.org/2000/svg\">\n")
|
||||
f.write(f"<circle cx=\"32\" cy=\"32\" r=\"30\" fill=\"{ color_circle_up }\" stroke=\"black\" stroke-width=\"2\"/>\n")
|
||||
f.write(f"<path d=\"M2,32 a1,1 0 0,0 60,0 Z\" fill=\"{ color_circle_down }\" stroke=\"black\" stroke-width=\"2\"/>\n")
|
||||
f.write(f"<rect x=\"15\" y=\"20\" width=\"35\" height=\"20\" stroke=\"black\" fill=\"{ color_rectangle }\" stroke-width=\"2\" />\n")
|
||||
f.write(f"<text x=\"50%\" y=\"50%\" fill=\"{ color_number }\" dominant-baseline=\"middle\" text-anchor=\"middle\">{ k }</text>\n")
|
||||
f.write('</svg>')
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
'''
|
||||
<svg height="64" width="64">
|
||||
<circle cx="32" cy="32" r="30" fill="yellow" stroke="black" stroke-width="2"/>
|
||||
<path d="M2,32 a1,1 0 0,0 60,0 Z" fill="green" stroke="black" stroke-width="2"/>
|
||||
<rect x="15" y="20" width="35" height="20" stroke="black" fill="red" stroke-width="2" />
|
||||
<text x="50%" y="50%" fill="white" dominant-baseline="middle" text-anchor="middle">9</text>
|
||||
</svg>
|
||||
'''
|
||||
Reference in New Issue
Block a user