fork download
  1. import sys
  2.  
  3. def next(s, str, list):
  4. global i1
  5. i0 = i1 + 1
  6. i1 = s.find(str, i0)
  7. if (i1 == -1): i1 = len(s)
  8. list.append(int(float(s[i0:i1])))
  9. return i1 == len(s)
  10.  
  11. i1 = 0
  12. lines = []
  13. for s in sys.stdin:
  14. l = []
  15. i1 = s.find("d=\"m ")
  16. if (i1 == -1): continue
  17. i1 = s.find(" ", i1)
  18. ends = s.find("\"", i1)
  19. s = s[i1 : ends]
  20. i1 = 0
  21. next(s, ",", l)
  22. next(s, " ", l)
  23. l[0] = 5000 + l[0]
  24. l[1] = 5000 - l[1]
  25. lines.append([l[0], l[1], 0, 0])
  26. while (True):
  27. l = []
  28. next(s, ",", l)
  29. done = next(s, " ", l)
  30. l[0] = lines[-1][0] + l[0]
  31. l[1] = lines[-1][1] - l[1]
  32. lines[-1][2] = l[0]
  33. lines[-1][3] = l[1]
  34. if (done): break
  35. lines.append([l[0], l[1], 0, 0])
  36. x0 = lines[-1][0]
  37. y0 = lines[-1][1]
  38. for i in range(len(lines)):
  39. lines[ i ][0] -= x0
  40. lines[ i ][2] -= x0
  41. lines[ i ][1] -= y0
  42. lines[ i ][3] -= y0
  43. for j in range(4): lines[ i ][ j ] *= 10
  44. for l in lines:
  45. print("L %d %d %d %d *" % (l[0], l[1], l[2], l[3]))
Success #stdin #stdout 0s 23296KB
stdin
<svg version="1.1"
xmlns:xlink="http://w...content-available-to-author-only...3.org/1999/xlink"
xmlns="http://w...content-available-to-author-only...3.org/2000/svg">
<path d="m 100,682.36218 80,90 80,50"
    style="fill:none;stroke:#000000;stroke-width:1"/>
<path d="m 260,1022.3622 70,-90.00002 60,-40 80,-20 120,-10 210,-10"
    style="fill:none;stroke:#000000;stroke-width:1"/>
<path d="m 100,1162.3622 100,-20 60,0"
    style="fill:none;stroke:#000000;stroke-width:1"/>
<path d="m 60,852.36218 790,0"
    style="fill:none;stroke:#000000;stroke-width:1"/>
<path d="m 60,1352.3622 790,0"
    style="fill:none;stroke:#000000;stroke-width:1"/>
<rect width="10" height="10" x="60" y="600"/>
<rect width="10" height="10" x="60" y="1400"/>
</svg>
stdout
L 400 6700 1200 5800 *
L 1200 5800 2000 5300 *
L 2000 3300 2700 4200 *
L 2700 4200 3300 4600 *
L 3300 4600 4100 4800 *
L 4100 4800 5300 4900 *
L 5300 4900 7400 5000 *
L 400 1900 1400 2100 *
L 1400 2100 2000 2100 *
L 0 5000 7900 5000 *
L 0 0 7900 0 *