23 lines
No EOL
1.3 KiB
Python
23 lines
No EOL
1.3 KiB
Python
import sys
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
|
d = """450.45798,248.27798 -23.6303,0.0664 -7.69319,408.97175 233.65406,3.23187 2.03872,-9.4214 4.88637,-15.06496 17.42406,-36.57514 -7.85182,-2.16593 -10.56419,-5.41477 -7.68274,-12.48124 -2.98455,-11.11106 1.02645,-17.16233 5.32697,-13.53813 6.51419,-11.46721 10.07042,-9.50106 8.70869,-3.29775 7.66614,0.14739 7.46874,-0.5736 18.19864,-3.23653 18.75678,-4.28752 14.10224,-0.50157 10.51818,0.46352 9.38096,3.84015 13.92544,5.97665 5.1419,5.4578 6.11697,5.28061 8.61655,-6.33149 10.09785,-4.48299 10.04956,-2.37885 6.99486,0.60644 5.39817,1.16256 4.19437,-170.27473 -9.00289,7.56953 -10.2301,5.85098 -25.02534,13.15514 -23.36016,7.15117 -34.75009,6.18661 -32.34141,-1.57705 -23.92586,-5.52174 -35.61785,-14.31835 -25.10646,-16.03692 -15.42024,-14.03395 -15.55185,-15.7378 -11.39434,-15.56362 -4.73117,-10.2233 -120.18327,2.26162"""
|
|
|
|
|
|
def rewrite_svg(fname: str):
|
|
tree = ET.parse(fname)
|
|
# print(tree.getroot())
|
|
root = tree.getroot()
|
|
for item in tree.getroot().iter("{http://www.w3.org/2000/svg}path"):
|
|
print(type(item))
|
|
item.tag = "polygon"
|
|
points = convert_path_to_polygon(item.get("d"))
|
|
item.clear()
|
|
item.set("points", points)
|
|
print(ET.dump(tree))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
INPUT_FNAME = sys.argv[1]
|
|
rewrite_svg(INPUT_FNAME) |