本文整理汇总了Python中simpletransform.composeTransform函数的典型用法代码示例。如果您正苦于以下问题:Python composeTransform函数的具体用法?Python composeTransform怎么用?Python composeTransform使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了composeTransform函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getHpgl
def getHpgl(self):
# dryRun to find edges
groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, 0.0], [0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, 0.0]]
groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')'))
self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]]
self.processGroups(self.doc, groupmat)
if self.divergenceX == 'False' or self.divergenceY == 'False' or self.sizeX == 'False' or self.sizeY == 'False':
raise Exception('NO_PATHS')
# live run
self.dryRun = False
if self.options.center:
self.divergenceX += (self.sizeX - self.divergenceX) / 2
self.divergenceY += (self.sizeY - self.divergenceY) / 2
elif self.options.useToolOffset:
self.options.offsetX += self.options.toolOffset
self.options.offsetY += self.options.toolOffset
groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, - self.divergenceX + self.options.offsetX],
[0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, - self.divergenceY + self.options.offsetY]]
groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')'))
self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]]
# store first hpgl commands
self.hpgl = 'IN;SP%d' % self.options.pen
# add precut
if self.options.useToolOffset and self.options.precut:
self.processOffset('PU', 0, 0)
self.processOffset('PD', 0, self.options.toolOffset * 8)
# start conversion
self.processGroups(self.doc, groupmat)
# shift an empty node in in order to process last node in cache
self.processOffset('PU', 0, 0)
# add return to zero point
self.hpgl += ';PU0,0;'
return self.hpgl
开发者ID:zanqi,项目名称:inkscape,代码行数:33,代码来源:hpgl_encoder.py
示例2: match
def match( p1, p2, a1, a2 ):
x = 0
y = 1
# distances
dp = [ p2[x]-p1[x], p2[y]-p1[y] ]
da = [ a2[x]-a1[x], a2[y]-a1[y] ]
# angles
angle_p = math.atan2( dp[x], dp[y] )
angle_a = math.atan2( da[x], da[y] )
# radians
#rp = math.sqrt( dp[x]*dp[x] + dp[y]*dp[y] )
#ra = math.sqrt( da[x]*da[x] + da[y]*da[y] )
rp = math.hypot( dp[x], dp[y] )
ra = math.hypot( da[x], da[y] )
# scale
scale = ra / rp
# transforms in the order they are applied
t1 = simpletransform.parseTransform( "translate(%f,%f)"%(-p1[x],-p1[y]) )
#t2 = simpletransform.parseTransform( "rotate(%f)"%(-angle_p) )
#t3 = simpletransform.parseTransform( "scale(%f,%f)"%(scale,scale) )
#t4 = simpletransform.parseTransform( "rotate(%f)"%angle_a )
t2 = rotateTransform(-angle_p)
t3 = scaleTransform( scale, scale )
t4 = rotateTransform( angle_a )
t5 = simpletransform.parseTransform( "translate(%f,%f)"%(a1[x],a1[y]) )
# transforms in the order they are multiplied
t = t5
t = simpletransform.composeTransform( t, t4 )
t = simpletransform.composeTransform( t, t3 )
t = simpletransform.composeTransform( t, t2 )
t = simpletransform.composeTransform( t, t1 )
# return the combined transform
return t
开发者ID:shlomif,项目名称:Bezier-Envelope-for-Inkscape,代码行数:33,代码来源:bezierenvelope.py
示例3: process_clone
def process_clone(self, node):
trans = node.get('transform')
x = node.get('x')
y = node.get('y')
mat = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
if trans:
mat = simpletransform.composeTransform(mat, simpletransform.parseTransform(trans))
if x:
mat = simpletransform.composeTransform(mat, [[1.0, 0.0, float(x)], [0.0, 1.0, 0.0]])
if y:
mat = simpletransform.composeTransform(mat, [[1.0, 0.0, 0.0], [0.0, 1.0, float(y)]])
# push transform
if trans or x or y:
self.groupmat.append(simpletransform.composeTransform(self.groupmat[-1], mat))
# get referenced node
refid = node.get(inkex.addNS('href','xlink'))
refnode = self.getElementById(refid[1:])
if refnode is not None:
if refnode.tag == inkex.addNS('g','svg'):
self.process_group(refnode)
elif refnode.tag == inkex.addNS('use', 'svg'):
self.process_clone(refnode)
else:
self.process_shape(refnode, self.groupmat[-1])
# pop transform
if trans or x or y:
self.groupmat.pop()
开发者ID:Drooids,项目名称:inkscape,代码行数:27,代码来源:print_win32_vector.py
示例4: get_transform
def get_transform(c1,c2,a1,a2):
[c1x,c1y], [c2x,c2y] = c1,c2
# move c1 to 0
transform = [ [1,0,-c1x], [0,1,-c1y] ]
# Rotate to a1 to 0
transform = simpletransform.composeTransform([ [math.cos(a1), -math.sin(a1), 0], [math.sin(a1), math.cos(a1), 0] ], transform )
# Move c2 to 0
transform = simpletransform.composeTransform( [ [1,0,-c2x+c1x], [0,1,-c2y+c1y] ], transform)
# Rotate to a2 to 0
transform = simpletransform.composeTransform( [ [math.cos(a2), -math.sin(a2), 0], [math.sin(a2), math.cos(a2), 0] ] , transform)
# move c2 back to c2
transform = simpletransform.composeTransform([ [1,0,c2x], [0,1,c2y] ], transform)
return transform
开发者ID:cnc-club,项目名称:unordinary-gears,代码行数:13,代码来源:unordinary-gears.py
示例5: process_group
def process_group(self, group):
if group.get(inkex.addNS('groupmode', 'inkscape')) == 'layer':
style = group.get('style')
if style:
style = simplestyle.parseStyle(style)
if style.has_key('display'):
if style['display'] == 'none' and self.options.layer_option and self.options.layer_option=='visible':
return
layer = group.get(inkex.addNS('label', 'inkscape'))
if self.options.layer_name and self.options.layer_option and self.options.layer_option=='name' and not layer.lower() in self.options.layer_name:
return
layer = layer.replace(' ', '_')
if layer in self.layers:
self.layer = layer
trans = group.get('transform')
if trans:
self.groupmat.append(simpletransform.composeTransform(self.groupmat[-1], simpletransform.parseTransform(trans)))
for node in group:
if node.tag == inkex.addNS('g','svg'):
self.process_group(node)
elif node.tag == inkex.addNS('use', 'svg'):
self.process_clone(node)
else:
self.process_shape(node, self.groupmat[-1])
if trans:
self.groupmat.pop()
开发者ID:AakashDabas,项目名称:inkscape,代码行数:27,代码来源:dxf_outlines.py
示例6: mergeTransform
def mergeTransform(self, doc, matrix):
# get and merge two matrixes into one
trans = doc.get('transform')
if trans:
return simpletransform.composeTransform(matrix, simpletransform.parseTransform(trans))
else:
return matrix
开发者ID:AakashDabas,项目名称:inkscape,代码行数:7,代码来源:hpgl_encoder.py
示例7: get_ancestor_transform
def get_ancestor_transform(self, elem):
""" Returns the cumulative transform of all this element's ancestors
(excluding this element's own transform)
"""
transform = [[1,0,0], [0,1,0], [0,0,1]]
for a in self.ancestors(elem):
transform = simpletransform.composeTransform(transform, self.get_transform(a))
return transform
开发者ID:KingNapz,项目名称:pixelsnap,代码行数:8,代码来源:pixelsnap.py
示例8: recursiveFuseTransform
def recursiveFuseTransform(self, node, transf=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]):
transf = composeTransform(transf, parseTransform(node.get("transform", None)))
if 'transform' in node.attrib:
del node.attrib['transform']
if 'style' in node.attrib:
style = node.attrib.get('style')
style = simplestyle.parseStyle(style)
update = False
if 'stroke-width' in style:
try:
stroke_width = self.unittouu(style.get('stroke-width').strip())
# pixelsnap ext assumes scaling is similar in x and y
# and uses the x scale...
# let's try to be a bit smarter
stroke_width *= math.sqrt(transf[0][0]**2 + transf[1][1]**2)
style['stroke-width'] = str(stroke_width)
update = True
except AttributeError:
pass
if update:
style = simplestyle.formatStyle(style)
node.attrib['style'] = style
node = ApplyTransform.objectToPath(node)
if 'd' in node.attrib:
d = node.get('d')
p = cubicsuperpath.parsePath(d)
applyTransformToPath(transf, p)
node.set('d', cubicsuperpath.formatPath(p))
elif node.tag in [inkex.addNS('polygon', 'svg'),
inkex.addNS('polyline', 'svg')]:
points = node.get('points')
points = points.strip().split(' ')
for k,p in enumerate(points):
if ',' in p:
p = p.split(',')
p = [float(p[0]),float(p[1])]
applyTransformToPoint(transf, p)
p = [str(p[0]),str(p[1])]
p = ','.join(p)
points[k] = p
points = ' '.join(points)
node.set('points', points)
elif node.tag in [inkex.addNS('rect', 'svg'),
inkex.addNS('text', 'svg'),
inkex.addNS('image', 'svg'),
inkex.addNS('use', 'svg')]:
node.set('transform', formatTransform(transf))
for child in node.getchildren():
self.recursiveFuseTransform(child, transf)
开发者ID:Klowner,项目名称:inkscape-applytransforms,代码行数:58,代码来源:applytransform.py
示例9: effect
def effect(self):
""" This method is called first, and sets up the self.commands list for later output. """
svg = self.document.getroot()
# find document width and height, used to scale down
self.doc_width = inkex.unittouu(svg.get('width'))
self.doc_height = inkex.unittouu(svg.get('height'))
# add header
self.commands.append("^DF;")
self.commands.append("! 1;")
self.commands.append("H;")
self.commands.append("@ %d %d;" % (self.options.z_down, self.options.z_up))
self.commands.append("V {0};F {0};\n".format(self.options.feed_rate_moving))
self.commands.append("Z 0 0 %d;" % self.options.z_up)
# mostly borrowed from hgpl_output.py
lastX = 0
lastY = 0
# find paths in layers
i = 0
layerPath = '//svg:g[@inkscape:groupmode="layer"]'
for layer in svg.xpath(layerPath, namespaces=inkex.NSS):
i += 1
nodePath = ('//svg:g[@inkscape:groupmode="layer"][%d]/descendant::svg:path') % i
for node in svg.xpath(nodePath, namespaces=inkex.NSS):
# these next lines added from this patch to fix the transformation issues - http://launchpadlibrarian.net/36269154/hpgl_output.py.patch
# possibly also want to try this code: https://bugs.launchpad.net/inkscape/+bug/600472/+attachment/1475310/+files/hpgl_output.py
transforms = node.xpath("./ancestor-or-self::svg:*[@transform]",namespaces=inkex.NSS)
matrix = [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]
for parenttransform in transforms:
newmatrix = simpletransform.parseTransform(parenttransform.get("transform"))
matrix = simpletransform.composeTransform(matrix, newmatrix)
d = node.get('d')
if len(simplepath.parsePath(d)):
p = cubicsuperpath.parsePath(d)
simpletransform.applyTransformToPath(matrix, p) # this line is also from the transform-fixing patch mentioned above
cspsubdiv.cspsubdiv(p, self.options.flat)
for sp in p:
first = True
for csp in sp:
if first:
x, y = self.conv_coords(csp[1][0], self.doc_height - csp[1][1])
self.commands.append("Z %d %d %d;" % (x, y, self.options.z_up))
self.commands.append("V {0};F {0};".format(self.options.feed_rate_cutting))
first = False
x, y = self.conv_coords(csp[1][0], self.doc_height - csp[1][1])
self.commands.append("Z %d %d %d;" % (x, y, self.options.z_down))
lastX = x
lastY = y
self.commands.append("V {0};F {0};".format(self.options.feed_rate_moving))
self.commands.append("Z %d %d %d;" % (lastX, lastY, self.options.z_up))
self.commands.append("Z 0 0 %d;" % self.options.z_up)
self.commands.append("H;")
开发者ID:matthewbeckler,项目名称:modela_inkscape_extension,代码行数:57,代码来源:modela.py
示例10: recursivelyTraverseSvg
def recursivelyTraverseSvg(self, nodeList=None, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]], parent_visibility='visible' ):
""" Based on the Eggbot extension for Inkscape.
Recursively traverse the svg file to plot out all the paths. Keeps track of the composite transformation that should be applied to each path.
Handles path, group.
Doesn't yet handle line, text, rect, polyline, polygon, circle, ellipse and use (clone) elements.
Unhandled elements should be converted to paths in Inkscape.
Probably want to avoid paths with holes inside.
"""
if not nodeList:
nodeList = self.svgRoot
# get svg document width and height
width, units_width = self.parseLengthAndUnits(nodeList.get("width"))
height, units_height = self.parseLengthAndUnits(nodeList.get("height"))
if units_width != units_height:
print "Weird, units for SVG root document width and height differ..."
print nodeList.get("width")
print nodelist.get("height")
sys.exit(1)
# set initial viewbox from document root
viewbox = nodeList.get("viewBox")
print "Document size: %f x %f (%s)" % (width, height, units_width)
if viewbox:
vinfo = viewbox.strip().replace(',', ' ').split(' ')
if (vinfo[2] != 0) and (vinfo[3] != 0):
sx = width / float(vinfo[2])
sy = height / float(vinfo[3])
matCurrent = simpletransform.parseTransform("scale(%f, %f) translate(%f, %f)" % (sx, sy, -float(vinfo[0]), -float(vinfo[1])))
print "Initial transformation matrix:", matCurrent
for node in nodeList:
# Ignore invisible nodes
v = node.get('visibility', parent_visibility)
if v == 'inherit':
v = parent_visibility
if v == 'hidden' or v == 'collapse':
pass
# first apply the current matrix transform to this node's transform
matNew = simpletransform.composeTransform( matCurrent, simpletransform.parseTransform(node.get("transform")) )
if node.tag in [self.svgQName("g"), "g"]:
print "group tag - Might not be handled right!"
self.recursivelyTraverseSvg( list(node), matNew, v )
elif node.tag in [self.svgQName("path")]:
self.plotPath( node, matNew )
else:
print "Other tag: '%s'" % node.tag
开发者ID:wayneandlayne,项目名称:svg2kicadmod,代码行数:56,代码来源:SvgParser.py
示例11: get_transforms
def get_transforms(self,g):
root = self.document.getroot()
trans = []
while (g!=root):
if 'transform' in g.keys():
t = g.get('transform')
t = simpletransform.parseTransform(t)
trans = simpletransform.composeTransform(t,trans) if trans != [] else t
g=g.getparent()
return trans
开发者ID:cnc-club,项目名称:unordinary-gears,代码行数:10,代码来源:unordinary-gears.py
示例12: process_shape
def process_shape(self, node, mat):
rgb = (0,0,0) # stroke color
fillcolor = None # fill color
stroke = 1 # pen width in printer pixels
# Very NB : If the pen width is greater than 1 then the output will Not be a vector output !
style = node.get('style')
if style:
style = simplestyle.parseStyle(style)
if style.has_key('stroke'):
if style['stroke'] and style['stroke'] != 'none' and style['stroke'][0:3] != 'url':
rgb = simplestyle.parseColor(style['stroke'])
if style.has_key('stroke-width'):
stroke = self.unittouu(style['stroke-width'])
stroke = int(stroke*self.scale)
if style.has_key('fill'):
if style['fill'] and style['fill'] != 'none' and style['fill'][0:3] != 'url':
fill = simplestyle.parseColor(style['fill'])
fillcolor = fill[0] + 256*fill[1] + 256*256*fill[2]
color = rgb[0] + 256*rgb[1] + 256*256*rgb[2]
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
if not d:
return
p = cubicsuperpath.parsePath(d)
elif node.tag == inkex.addNS('rect','svg'):
x = float(node.get('x'))
y = float(node.get('y'))
width = float(node.get('width'))
height = float(node.get('height'))
p = [[[x, y],[x, y],[x, y]]]
p.append([[x + width, y],[x + width, y],[x + width, y]])
p.append([[x + width, y + height],[x + width, y + height],[x + width, y + height]])
p.append([[x, y + height],[x, y + height],[x, y + height]])
p.append([[x, y],[x, y],[x, y]])
p = [p]
else:
return
trans = node.get('transform')
if trans:
mat = simpletransform.composeTransform(mat, simpletransform.parseTransform(trans))
simpletransform.applyTransformToPath(mat, p)
hPen = mygdi.CreatePen(0, stroke, color)
mygdi.SelectObject(self.hDC, hPen)
self.emit_path(p)
if fillcolor is not None:
brush = LOGBRUSH(0, fillcolor, 0)
hBrush = mygdi.CreateBrushIndirect(addressof(brush))
mygdi.SelectObject(self.hDC, hBrush)
mygdi.BeginPath(self.hDC)
self.emit_path(p)
mygdi.EndPath(self.hDC)
mygdi.FillPath(self.hDC)
return
开发者ID:Drooids,项目名称:inkscape,代码行数:53,代码来源:print_win32_vector.py
示例13: effect
def effect(self):
if len(self.options.ids)<2:
inkex.debug("This extension requires that you select two paths.")
return
self.prepareSelectionList()
#center at (0,0)
bbox=pathmodifier.computeBBox([self.patternNode])
mat=[[1,0,-(bbox[0]+bbox[1])/2],[0,1,-(bbox[2]+bbox[3])/2]]
if self.options.vertical:
bbox=[-bbox[3],-bbox[2],bbox[0],bbox[1]]
mat=simpletransform.composeTransform([[0,-1,0],[1,0,0]],mat)
mat[1][2] += self.options.noffset
simpletransform.applyTransformToNode(mat,self.patternNode)
width=bbox[1]-bbox[0]
dx=width+self.options.space
for skelnode in self.skeletons.itervalues():
self.curSekeleton=cubicsuperpath.parsePath(skelnode.get('d'))
for comp in self.curSekeleton:
self.skelcomp,self.lengths=linearize(comp)
#!!!!>----> TODO: really test if path is closed! end point==start point is not enough!
self.skelcompIsClosed = (self.skelcomp[0]==self.skelcomp[-1])
length=sum(self.lengths)
if self.options.stretch:
dx=width+self.options.space
n=int((length-self.options.toffset+self.options.space)/dx)
if n>0:
dx=(length-self.options.toffset)/n
xoffset=self.skelcomp[0][0]-bbox[0]+self.options.toffset
yoffset=self.skelcomp[0][1]-(bbox[2]+bbox[3])/2-self.options.noffset
s=self.options.toffset
while s<=length:
mat=self.localTransformAt(s,self.options.follow)
clone=copy.deepcopy(self.patternNode)
#!!!--> should it be given an id?
#seems to work without this!?!
myid = self.patternNode.tag.split('}')[-1]
clone.set("id", self.uniqueId(myid))
self.gNode.append(clone)
simpletransform.applyTransformToNode(mat,clone)
s+=dx
self.patternNode.getparent().remove(self.patternNode)
开发者ID:josemlp91,项目名称:Ardufocuser-INDI,代码行数:52,代码来源:pathscatter.py
示例14: process_shape
def process_shape(self, node, mat):
rgb = (0,0,0)
style = node.get('style')
if style:
style = simplestyle.parseStyle(style)
if style.has_key('stroke'):
if style['stroke'] and style['stroke'] != 'none' and style['stroke'][0:3] != 'url':
rgb = simplestyle.parseColor(style['stroke'])
hsl = coloreffect.ColorEffect.rgb_to_hsl(coloreffect.ColorEffect(),rgb[0]/255.0,rgb[1]/255.0,rgb[2]/255.0)
self.closed = 0 # only for LWPOLYLINE
self.color = 7 # default is black
if hsl[2]:
#self.color = 1 + (int(6*hsl[0] + 0.5) % 6) # use 6 hues
self.color = 1 + (int(10*hsl[0] + 0.5) % 10) # use 6 hues
if node.tag == inkex.addNS('path','svg'):
d = node.get('d')
if not d:
return
if (d[-1] == 'z' or d[-1] == 'Z'):
self.closed = 1
p = cubicsuperpath.parsePath(d)
elif node.tag == inkex.addNS('rect','svg'):
self.closed = 1
x = float(node.get('x'))
y = float(node.get('y'))
width = float(node.get('width'))
height = float(node.get('height'))
p = [[[x, y],[x, y],[x, y]]]
p.append([[x + width, y],[x + width, y],[x + width, y]])
p.append([[x + width, y + height],[x + width, y + height],[x + width, y + height]])
p.append([[x, y + height],[x, y + height],[x, y + height]])
p.append([[x, y],[x, y],[x, y]])
p = [p]
else:
return
trans = node.get('transform')
if trans:
mat = simpletransform.composeTransform(mat, simpletransform.parseTransform(trans))
simpletransform.applyTransformToPath(mat, p)
for sub in p:
for i in range(len(sub)-1):
s = sub[i]
e = sub[i+1]
if s[1] == s[2] and e[0] == e[1]:
if (self.options.POLY == 'true'):
self.LWPOLY_line([s[1],e[1]])
else:
self.dxf_line([s[1],e[1]])
elif (self.options.ROBO == 'true'):
self.ROBO_spline([s[1],s[2],e[0],e[1]])
else:
self.dxf_spline([s[1],s[2],e[0],e[1]])
开发者ID:MakeICT,项目名称:inkscape-lasercut-dxf,代码行数:52,代码来源:lasercut-dxf.py
示例15: effect
def effect(self):
object2path.ObjectToPath.effect(self)
transformMatrix = [[1,0,0],[0,1,0]]
dims = self.determine_dims(transformMatrix)
[x,y,X,Y] = dims
width = X - x
height = Y - y
# Longest side is vertical
if width > height:
scale = 480.0 / height
if scale * width > 999.0:
inkex.errormsg("Plot area is to large (%f > 999)." % scale*height)
exit()
transformMatrix = parseTransform('translate(%f,%f)' % (-x,-y))
transformMatrix = composeTransform(parseTransform('rotate(-90)'), transformMatrix)
transformMatrix = composeTransform(parseTransform('scale(%f,%f)' % (scale,scale)), transformMatrix)
else:
scale = 480.0 / width
if scale * height > 999.0:
inkex.errormsg("Plot area is to large (%f > 999)." % scale*height)
exit()
transformMatrix = parseTransform('translate(%f,%f)' % (-x,-y))
transformMatrix = composeTransform(parseTransform('rotate(180)'), transformMatrix)
transformMatrix = composeTransform(parseTransform('translate(%f,0)' % width), transformMatrix)
transformMatrix = composeTransform(parseTransform('scale(%f,%f)' % (-scale,scale)), transformMatrix)
transformMatrix = composeTransform(parseTransform('translate(480,0)'), transformMatrix)
paths = []
for [path, node] in self.processPaths(transformMatrix):
color = (0, 0, 0)
style = node.get('style')
if style:
style = simplestyle.parseStyle(style)
if 'stroke' in style:
if style['stroke'] and style['stroke'] != 'none':
color = simplestyle.parseColor(style['stroke'])
points = []
for point in self.processPath(path):
points.append(point)
paths.append({'color':color, 'points':points})
dims = self.determine_dims(transformMatrix)
if self.options.debug:
print >>sys.stderr, "VC1520 debug info"
print >>sys.stderr, "-----------------"
print >>sys.stderr, "plot area: minX:%d, minY:%d, maxX:%d, maxY:%d" % tuple(dims)
print >>sys.stderr, "nr paths: %d" % len(paths)
i = 0
print >>sys.stderr, "path;color;points"
for path in paths:
print >>sys.stderr, "%d;%s;%d" % (i,self.find_color(path['color']),len(path['points']))
i += 1
for path in paths:
print >>sys.stderr, path
else:
self.plot(paths, dims[1])
开发者ID:nanoflite,项目名称:inkscape-VC1520,代码行数:59,代码来源:sendto_vc1520.py
示例16: processPaths
def processPaths(self, transformMatrix):
path = '//svg:path'
pm = pathmodifier.PathModifier()
for node in self.document.getroot().xpath(path, namespaces=inkex.NSS):
pm.objectToPath(node, True)
d = node.get('d')
p = cubicsuperpath.parsePath(d)
t = node.get('transform')
if t is not None:
transformMatrix = composeTransform(transformMatrix, parseTransform(t))
applyTransformToPath(transformMatrix, p)
yield [p, node]
开发者ID:nanoflite,项目名称:inkscape-VC1520,代码行数:14,代码来源:sendto_vc1520.py
示例17: get_transform
def get_transform(self, elem, parent_transform=None):
""" Get this element's transform as a matrix. If parent_transform is
specified, return the cumulative transform.
"""
transform = elem.attrib.get('transform', '').strip()
if transform:
transform = simpletransform.parseTransform(transform)
else:
transform = [[1,0,0], [0,1,0], [0,0,1]]
if parent_transform:
transform = simpletransform.composeTransform(parent_transform, transform)
return transform
开发者ID:KingNapz,项目名称:pixelsnap,代码行数:14,代码来源:pixelsnap.py
示例18: i2d_affine
def i2d_affine(self, node, use_cache=True):
'''
Get the "item to document" transformation matrix.
Note: use_cache showed 20% speed improvement for a big SVG document
'''
if use_cache and node in self.i2d_cache:
return self.i2d_cache[node]
import simpletransform
m2 = simpletransform.parseTransform(node.get('transform'))
parent = node.getparent()
if parent is not None:
m1 = self.i2d_affine(parent, use_cache)
m2 = simpletransform.composeTransform(m1, m2)
else:
m2 = simpletransform.composeTransform(self.r2d, m2)
m2 = simpletransform.composeTransform([[th2pref.basescale, 0.0, 0.0],
[0.0, th2pref.basescale, 0.0]], m2)
self.i2d_cache[node] = m2
return m2
开发者ID:speleo3,项目名称:inkscape-speleo,代码行数:23,代码来源:th2ex.py
示例19: getGlobalTransform
def getGlobalTransform(self,node):
parent = node.getparent()
myTrans = simpletransform.parseTransform(node.get('transform'))
if myTrans:
if parent is not None:
parentTrans = self.getGlobalTransform(parent)
if parentTrans:
return simpletransform.composeTransform(parentTrans,myTrans)
else:
return myTrans
else:
if parent is not None:
return self.getGlobalTransform(parent)
else:
return None
开发者ID:AakashDabas,项目名称:inkscape,代码行数:15,代码来源:voronoi2svg.py
示例20: process_path
def process_path(self, node, mat):
d = node.get('d')
if d:
p = cubicsuperpath.parsePath(d)
trans = node.get('transform')
if trans:
mat = simpletransform.composeTransform(mat, simpletransform.parseTransform(trans))
simpletransform.applyTransformToPath(mat, p)
cspsubdiv.cspsubdiv(p, self.options.flat)
for sp in p:
first = True
for csp in sp:
cmd = 'PD'
if first:
cmd = 'PU'
first = False
self.hpgl.append('%s%d,%d;' % (cmd,csp[1][0],csp[1][1]))
开发者ID:Spin0za,项目名称:inkscape,代码行数:17,代码来源:hpgl_output.py
注:本文中的simpletransform.composeTransform函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论