Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import drawSvg as draw
- import os
- d = draw.Drawing(2500,2500)
- lines = open("trueSvg.txt", "r").readlines()
- cpt = 0
- for line in lines:
- what = line.split(" ")[-1].strip("\n")
- coords = line.split(" ")[:len(line.split(" "))-1]
- if what == "m":
- m = coords
- pass
- """
- print("*****************")
- print(" ")
- print("Type : " + what )
- print("Coords : ")
- print(coords )
- print(" ")
- """
- p = draw.Path(stroke_width=1, stroke='black', fill='black', fill_opacity=1)
- try:
- p.m(float(m[0]),float(m[1]))
- except:
- pass
- if what == "l":
- p.l(float(coords[0]),float(coords[1]))
- elif what =="c":
- p.c(float(coords[0]),float(coords[1]), float(coords[2]), float(coords[3]), float(coords[4]), float(coords[5]))
- p.Z()
- d.append(p)
- d.setPixelScale(2) # Set number of pixels per geometry unit
- #d.setRenderSize(400,200) # Alternative to setPixelScale
- d.saveSvg('example.svg')
- d.savePng('example.png')
- # Display in iPython notebook
- d.rasterize() # Display as PNG
- d # Display as SVG
- #os.system("eog example.png")
- os.system("eog example.svg")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement