Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for Line elements in parseSVG paths #1

Merged
merged 1 commit into from
Jul 25, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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