Skip to content

Commit

Permalink
Merge pull request #1 from fdraeger/patch-1
Browse files Browse the repository at this point in the history
Check for Line elements in parseSVG paths
  • Loading branch information
OssiLehtinen authored Jul 25, 2017
2 parents 9e30fb7 + b1fb604 commit 126b451
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions uArmLaserRobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uArmRobot
import protocol_swiftpro as protocol
from svgpathtools import svg2paths2, wsvg
from svgpathtools.path import Line
import numpy as np
import time
from PIL import Image
Expand Down Expand Up @@ -80,9 +81,16 @@ def parseSVG(self, filename, targetWidth, xOffset, steps_per_seg):
if('stroke' in attribute or 'class' in attribute):
for seg in path:
segcoords = []
for p in range(steps_per_seg+1):
cp = seg.point(float(p)/float(steps_per_seg))
segcoords.append([scale*(np.real(cp)-xmin)+xOffset, scale*(np.imag(cp)-ymin) - scale*((ymax-ymin)/2.0)])
# no need to create segments, if we already have a Line.
if isinstance(seg, Line):
cp = seg.start
segcoords.append([scale*(np.real(cp)-xmin)+xOffset, scale*(np.imag(cp)-ymin) - scale*((ymax-ymin)/2.0)])
cp = seg.end
segcoords.append([scale*(np.real(cp)-xmin)+xOffset, scale*(np.imag(cp)-ymin) - scale*((ymax-ymin)/2.0)])
else:
for p in range(steps_per_seg+1):
cp = seg.point(float(p)/float(steps_per_seg))
segcoords.append([scale*(np.real(cp)-xmin)+xOffset, scale*(np.imag(cp)-ymin) - scale*((ymax-ymin)/2.0)])
coords.append(segcoords)

return coords
Expand Down

0 comments on commit 126b451

Please sign in to comment.