SHARE
TWEET

Untitled

a guest Apr 24th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import drawSvg as draw
  3. import os
  4.  
  5. d = draw.Drawing(2500,2500)
  6.  
  7. lines = open("trueSvg.txt", "r").readlines()
  8. cpt = 0
  9.  
  10. for line in lines:
  11.     what = line.split(" ")[-1].strip("\n")
  12.     coords =  line.split(" ")[:len(line.split(" "))-1]
  13.     if what == "m":
  14.         m = coords
  15.         pass
  16.     """
  17.    print("*****************")
  18.    print("                 ")
  19.    print("Type : " + what   )
  20.    print("Coords :         ")
  21.    print(coords             )
  22.    print("                 ")
  23.    """
  24.     p = draw.Path(stroke_width=1, stroke='black', fill='black', fill_opacity=1)
  25.     try:
  26.         p.m(float(m[0]),float(m[1]))
  27.     except:
  28.         pass
  29.     if what == "l":
  30.         p.l(float(coords[0]),float(coords[1]))
  31.     elif what =="c":
  32.         p.c(float(coords[0]),float(coords[1]), float(coords[2]), float(coords[3]), float(coords[4]), float(coords[5]))
  33.     p.Z()
  34.     d.append(p)
  35.  
  36. d.setPixelScale(2)  # Set number of pixels per geometry unit
  37. #d.setRenderSize(400,200)  # Alternative to setPixelScale
  38. d.saveSvg('example.svg')
  39. d.savePng('example.png')
  40.  
  41. # Display in iPython notebook
  42. d.rasterize()  # Display as PNG
  43. d  # Display as SVG
  44. #os.system("eog example.png")
  45. os.system("eog example.svg")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top