• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python simplepath.formatPath函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中simplepath.formatPath函数的典型用法代码示例。如果您正苦于以下问题:Python formatPath函数的具体用法?Python formatPath怎么用?Python formatPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了formatPath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: inkscape

def inkscape(hpgl,svg,inkex):
	layer = inkex.etree.SubElement(svg, 'g')
	layer.set(inkex.addNS('label', 'inkscape'), 'InkCut Preview Layer')
	layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer')
	spPU = [['M',[0,0]]]
	spPD = []
	for c in hpgl.split(';'):
		if c[:2] == "PU":
			p = map(int,c[2:].split(','))
			spPD.append(['M',p])
			spPU.append(['L',p])
		elif c[:2] == "PD":
			p = map(int,c[2:].split(','))
			spPU.append(['M',p])
			spPD.append(['L',p])		
	
	pu = inkex.etree.Element(inkex.addNS('path','svg'))
	
	simplepath.scalePath(spPU,0.088582677,-0.088582677)
	simplepath.translatePath(spPU,0,float(svg.get('height')))
	
	style = {'fill' : 'none','stroke-opacity': '.8','stroke':'#116AAB'}
	pu.set('style', simplestyle.formatStyle(style))
	pu.set('d',simplepath.formatPath(spPU))
	
	
	pd = inkex.etree.Element(inkex.addNS('path','svg'))
	
	style = {'fill' : 'none','stroke-opacity': '.8','stroke':'#AB3011'}
	pd.set('style', simplestyle.formatStyle(style))
	pd.set('d',simplepath.formatPath(spPD))
	
	# Connect elements together.
	layer.append(pu)
	layer.append(pd)
开发者ID:shackspace,项目名称:inkcut_dmpl,代码行数:35,代码来源:preview.py


示例2: effect

    def effect(self):
        paths = []
        for id, node in self.selected.iteritems():
            if node.tag == '{http://www.w3.org/2000/svg}path':
                paths.append(node)
                if len(paths) == 2:
                    break
        else:
            sys.stderr.write('Need 2 paths selected\n')
            return


        pts = [cubicsuperpath.parsePath(paths[i].get('d'))
               for i in (0,1)]

        for i in (0,1):
            if 'transform' in paths[i].keys():
                trans = paths[i].get('transform')
                trans = simpletransform.parseTransform(trans)
                simpletransform.applyTransformToPath(trans, pts[i])

        verts = []
        for i in range(0, min(map(len, pts))):
            comp = []
            for j in range(0, min(len(pts[0][i]), len(pts[1][i]))):
                comp.append([pts[0][i][j][1][-2:], pts[1][i][j][1][-2:]])
            verts.append(comp)

        if self.options.mode.lower() == 'lines':
            line = []
            for comp in verts:
                for n,v in enumerate(comp):
                  line += [('M', v[0])]
                  line += [('L', v[1])]
            ele = inkex.etree.Element('{http://www.w3.org/2000/svg}path')
            paths[0].xpath('..')[0].append(ele)
            ele.set('d', simplepath.formatPath(line))
            ele.set('style', 'fill:none;stroke:#000000;stroke-opacity:1;stroke-width:1;')
        elif self.options.mode.lower() == 'polygons':
            g = inkex.etree.Element('{http://www.w3.org/2000/svg}g')
            g.set('style', 'fill:#000000;stroke:#000000;fill-opacity:0.3;stroke-width:2;stroke-opacity:0.6;')   
            paths[0].xpath('..')[0].append(g)
            for comp in verts:
                for n,v in enumerate(comp):
                    nn = n+1
                    if nn == len(comp): nn = 0
                    line = []
                    line += [('M', comp[n][0])]
                    line += [('L', comp[n][1])]
                    line += [('L', comp[nn][1])]
                    line += [('L', comp[nn][0])]
                    line += [('L', comp[n][0])]
                    ele = inkex.etree.Element('{http://www.w3.org/2000/svg}path')
                    g.append(ele)
                    ele.set('d', simplepath.formatPath(line))
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:55,代码来源:extrude.py


示例3: effect

    def effect(self):
        paths = []
        for id, node in self.selected.iteritems():
            if node.tag == "{http://www.w3.org/2000/svg}path":
                paths.append(node)
                if len(paths) == 2:
                    break
        else:
            sys.stderr.write("Need 2 paths selected\n")
            return

        pts = [cubicsuperpath.parsePath(paths[i].get("d")) for i in (0, 1)]

        for i in (0, 1):
            if "transform" in paths[i].keys():
                trans = paths[i].get("transform")
                trans = simpletransform.parseTransform(trans)
                simpletransform.applyTransformToPath(trans, pts[i])

        verts = []
        for i in range(0, min(map(len, pts))):
            comp = []
            for j in range(0, min(len(pts[0][i]), len(pts[1][i]))):
                comp.append([pts[0][i][j][1][-2:], pts[1][i][j][1][-2:]])
            verts.append(comp)

        if self.options.mode.lower() == "lines":
            line = []
            for comp in verts:
                for n, v in enumerate(comp):
                    line += [("M", v[0])]
                    line += [("L", v[1])]
            ele = inkex.etree.Element("{http://www.w3.org/2000/svg}path")
            paths[0].xpath("..")[0].append(ele)
            ele.set("d", simplepath.formatPath(line))
            ele.set("style", "fill:none;stroke:#000000;stroke-opacity:1;stroke-width:1;")
        elif self.options.mode.lower() == "polygons":
            g = inkex.etree.Element("{http://www.w3.org/2000/svg}g")
            g.set("style", "fill:#000000;stroke:#000000;fill-opacity:0.3;stroke-width:2;stroke-opacity:0.6;")
            paths[0].xpath("..")[0].append(g)
            for comp in verts:
                for n, v in enumerate(comp):
                    nn = n + 1
                    if nn == len(comp):
                        nn = 0
                    line = []
                    line += [("M", comp[n][0])]
                    line += [("L", comp[n][1])]
                    line += [("L", comp[nn][1])]
                    line += [("L", comp[nn][0])]
                    line += [("L", comp[n][0])]
                    ele = inkex.etree.Element("{http://www.w3.org/2000/svg}path")
                    g.append(ele)
                    ele.set("d", simplepath.formatPath(line))
开发者ID:wdmchaft,项目名称:DoonSketch,代码行数:54,代码来源:extrude.py


示例4: hpgl

def hpgl(plot):
	#create a preview svg
	svg = etree.Element(inkex.addNS('svg','svg'))
	svg.set('height',str(plot.dimensions[1]))
	svg.set('width',str(plot.getSize()[0]+plot.startPosition[0]+plot.finishPosition[0]))
	svg.set('version','1.1')
	"""
	bg = inkex.etree.Element(inkex.addNS('rect','svg'))
	style = {'fill' : 'none','stroke-opacity': '.8','stroke':'#212425','stroke-width':'10'}
	bg.set('style', simplestyle.formatStyle(style))
	bg.set('x','0')
	bg.set('y','0')
	bg.set('width',str(plot.dimensions[0]))
	bg.set('height',svg.get('height'))
	svg.append(bg)
	"""
	spPU = [['M',[0,0]]]
	spPD = []
	for c in plot.toHPGL().split(';'):
		if c[:2] == "PU":
			p = map(int,c[2:].split(','))
			spPD.append(['M',p])
			spPU.append(['L',p])
		elif c[:2] == "PD":
			p = map(int,c[2:].split(','))
			spPU.append(['M',p])
			spPD.append(['L',p])		
	
	pu = inkex.etree.Element(inkex.addNS('path','svg'))
	
	simplepath.scalePath(spPU,0.088582677,-0.088582677)
	simplepath.translatePath(spPU,0,float(svg.get('height')))
	
	style = {'fill' : 'none','stroke-opacity': '.8','stroke':'#116AAB'}
	pu.set('style', simplestyle.formatStyle(style))
	pu.set('d',simplepath.formatPath(spPU))
	
	
	pd = inkex.etree.Element(inkex.addNS('path','svg'))
	
	style = {'fill' : 'none','stroke-opacity': '.8','stroke':'#AB3011'}
	pd.set('style', simplestyle.formatStyle(style))
	pd.set('d',simplepath.formatPath(spPD))
	
	# Connect elements together.
	svg.append(pu)
	svg.append(pd)
	return svg
开发者ID:shackspace,项目名称:inkcut_dmpl,代码行数:48,代码来源:preview.py


示例5: effect

    def effect(self):
        for id, node in self.selected.iteritems():
            if node.tag == inkex.addNS('path','svg'):
                p = simplepath.parsePath(node.get('d'))
                a =[]
                pen = None
                subPathStart = None
                for cmd,params in p:
                    if cmd == 'C':
                        a.extend([['M', params[:2]], ['L', pen],
                            ['M', params[2:4]], ['L', params[-2:]]])
                    if cmd == 'Q':
                        a.extend([['M', params[:2]], ['L', pen],
                            ['M', params[:2]], ['L', params[-2:]]])
                    
                    if cmd == 'M':
                        subPathStart = params

                    if cmd == 'Z':
                        pen = subPathStart
                    else:
                        pen = params[-2:]
                    
                if len(a) > 0:
                    s = {'stroke-linejoin': 'miter', 'stroke-width': '1.0px', 
                        'stroke-opacity': '1.0', 'fill-opacity': '1.0', 
                        'stroke': '#000000', 'stroke-linecap': 'butt', 
                        'fill': 'none'}
                    attribs = {'style':simplestyle.formatStyle(s),'d':simplepath.formatPath(a)}
                    inkex.etree.SubElement(node.getparent(), inkex.addNS('path','svg'), attribs)
开发者ID:AakashDabas,项目名称:inkscape,代码行数:30,代码来源:handles.py


示例6: effect

    def effect(self):
        for id, node in self.selected.iteritems():
            if node.tagName == 'path':
                self.group = self.document.createElement('svg:g')
                node.parentNode.appendChild(self.group)
                new = self.document.createElement('svg:path')
                
                try:
                    t = node.attributes.getNamedItem('transform').value
                    self.group.setAttribute('transform', t)
                except AttributeError:
                    pass

                s = simplestyle.parseStyle(node.attributes.getNamedItem('style').value)
                s['stroke-linecap']='round'
                s['stroke-width']=self.options.dotsize
                new.setAttribute('style', simplestyle.formatStyle(s))

                a =[]
                p = simplepath.parsePath(node.attributes.getNamedItem('d').value)
                num = 1
                for cmd,params in p:
                    if cmd != 'Z':
                        a.append(['M',params[-2:]])
                        a.append(['L',params[-2:]])
                        self.addText(self.group,params[-2],params[-1],num)
                        num += 1
                new.setAttribute('d', simplepath.formatPath(a))
                self.group.appendChild(new)
                node.parentNode.removeChild(node)
开发者ID:NirBenTalLab,项目名称:find_motif,代码行数:30,代码来源:dots.py


示例7: effect

    def effect(self):
        for id, node in self.selected.iteritems():
            if node.tagName == 'path':
                p = simplepath.parsePath(node.attributes.getNamedItem('d').value)
                a =[]
                pen = None
                subPathStart = None
                for cmd,params in p:
                    if cmd == 'C':
                        a.extend([['M', params[:2]], ['L', pen],
                            ['M', params[2:4]], ['L', params[-2:]]])
                    if cmd == 'Q':
                        a.extend([['M', params[:2]], ['L', pen],
                            ['M', params[:2]], ['L', params[-2:]]])
                    
                    if cmd == 'M':
                        subPathStart = params

                    if cmd == 'Z':
                        pen = subPathStart
                    else:
                        pen = params[-2:]
                    
                if len(a) > 0:
                    new = self.document.createElement('svg:path')
                    s = {'stroke-linejoin': 'miter', 'stroke-width': '1.0px', 
                        'stroke-opacity': '1.0', 'fill-opacity': '1.0', 
                        'stroke': '#000000', 'stroke-linecap': 'butt', 
                        'fill': 'none'}
                    new.setAttribute('style', simplestyle.formatStyle(s))
                    new.setAttribute('d', simplepath.formatPath(a))
                    node.parentNode.appendChild(new)
开发者ID:NirBenTalLab,项目名称:find_motif,代码行数:32,代码来源:handles.py


示例8: effect

    def effect(self):
        for id, node in self.selected.iteritems():
            if node.tag == inkex.addNS('path','svg'):
                self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('g','svg'))
                new = inkex.etree.SubElement(self.group,inkex.addNS('path','svg'))
                
                try:
                    t = node.get('transform')
                    self.group.set('transform', t)
                except:
                    pass

                s = simplestyle.parseStyle(node.get('style'))
                s['stroke-linecap']='round'
                s['stroke-width']=self.options.dotsize
                new.set('style', simplestyle.formatStyle(s))

                a =[]
                p = simplepath.parsePath(node.get('d'))
                num = 1
                for cmd,params in p:
                    if cmd != 'Z':
                        a.append(['M',params[-2:]])
                        a.append(['L',params[-2:]])
                        self.addText(self.group,params[-2],params[-1],num)
                        num += 1
                new.set('d', simplepath.formatPath(a))
                node.clear()
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:28,代码来源:dots.py


示例9: snap_path_scale

    def snap_path_scale(self, elem, parent_transform=None):
        # If we have a Live Path Effect, modify original-d. If anyone clamours
        # for it, we could make an option to ignore paths with Live Path Effects
        original_d = '{%s}original-d' % inkex.NSS['inkscape']
        path = simplepath.parsePath(elem.attrib.get(original_d, elem.attrib['d']))
        transform = self.transform(elem, parent_transform=parent_transform)
        min_xy, max_xy = self.path_bounding_box(elem, parent_transform)
        
        width = max_xy[0] - min_xy[0]
        height = max_xy[1] - min_xy[1]
        rescale = round(width)/width, round(height)/height

        min_xy = transform_point(transform, min_xy, inverse=True)
        max_xy = transform_point(transform, max_xy, inverse=True)

        for i in range(len(path)):
            self.transform_path_node([[1, 0, -min_xy[0]], [0, 1, -min_xy[1]]], path, i)     # center transform
            self.transform_path_node([[rescale[0], 0, 0],
                                       [0, rescale[1], 0]],
                                       path, i)
            self.transform_path_node([[1, 0, +min_xy[0]], [0, 1, +min_xy[1]]], path, i)     # uncenter transform
        
        path = simplepath.formatPath(path)
        if original_d in elem.attrib: elem.attrib[original_d] = path
        else: elem.attrib['d'] = path
开发者ID:gaffel85,项目名称:notification-agenda,代码行数:25,代码来源:pixelsnap.py


示例10: movePath

    def movePath(self, node, x, y, origin):
        tagName = self.getTagName(node)

        if tagName != "path":
            inkex.debug('movePath only works on SVG Path elements. Argument was of type "' + tagName + '"')
            return False

        path = simplepath.parsePath(node.get("d"))
        id = node.get("id")

        box = list(simpletransform.computeBBox([node]))

        offset_x = box[0] - x
        offset_y = box[2] - (y)

        for cmd in path:
            params = cmd[1]
            i = 0

            while i < len(params):
                if i % 2 == 0:
                    # inkex.debug('x point at ' + str( round( params[i] )))
                    params[i] = params[i] - offset_x
                    # inkex.debug('moved to ' + str( round( params[i] )))
                else:
                    # inkex.debug('y point at ' + str( round( params[i]) ))
                    params[i] = params[i] - offset_y
                    # inkex.debug('moved to ' + str( round( params[i] )))
                i = i + 1

        return simplepath.formatPath(path)
开发者ID:brentini,项目名称:ExtractElements,代码行数:31,代码来源:larscwallin.inx.extractelements.py


示例11: effect

 def effect(self):
     for id, node in self.selected.iteritems():
         if node.tag == inkex.addNS('path', 'svg'):
             d = node.get('d')
             p = simplepath.parsePath(d)
             last = []
             subPathStart = []
             for cmd,params in p:
                 if cmd == 'C':
                     if self.options.behave <= 1:
                         #shorten handles towards end points
                         params[:2] = pointAtPercent(params[:2],last[:],self.options.percent)    
                         params[2:4] = pointAtPercent(params[2:4],params[-2:],self.options.percent)
                     else:
                         #shorten handles towards thirds of the segment                            
                         dest1 = pointAtPercent(last[:],params[-2:],33.3)
                         dest2 = pointAtPercent(params[-2:],last[:],33.3)
                         params[:2] = pointAtPercent(params[:2],dest1[:],self.options.percent)    
                         params[2:4] = pointAtPercent(params[2:4],dest2[:],self.options.percent)
                 elif cmd == 'Q':
                     dest = pointAtPercent(last[:],params[-2:],50)
                     params[:2] = pointAtPercent(params[:2],dest,self.options.percent)
                 if cmd == 'M':
                     subPathStart = params[-2:]
                 if cmd == 'Z':
                     last = subPathStart[:]
                 else:
                     last = params[-2:]
             node.set('d',simplepath.formatPath(p))
开发者ID:AakashDabas,项目名称:inkscape,代码行数:29,代码来源:straightseg.py


示例12: effect

  def effect(self):
    clippingLineSegments = None
    pathTag = inkex.addNS('path','svg')
    groupTag = inkex.addNS('g','svg')
    error_messages = []
    for id in self.options.ids:  # the selection, top-down
      node = self.selected[id]
      if node.tag == pathTag:
        if clippingLineSegments is None: # first path is the clipper
          (clippingLineSegments, errors) = self.simplepathToLineSegments(simplepath.parsePath(node.get('d')))
          error_messages.extend(['{}: {}'.format(id, err) for err in errors])
        else:
          # do all the work!
          segmentsToClip, errors = self.simplepathToLineSegments(simplepath.parsePath(node.get('d')))
          error_messages.extend(['{}: {}'.format(id, err) for err in errors])
          clippedSegments = self.clipLineSegments(segmentsToClip, clippingLineSegments)
          if len(clippedSegments) != 0:
            # replace the path
            node.set('d', simplepath.formatPath(self.linesgmentsToSimplePath(clippedSegments)))
          else:
            # don't put back an empty path(?)  could perhaps put move, move?
            inkex.debug('Object {} clipped to nothing, will not be updated.'.format(node.get('id')))
      elif node.tag == groupTag:  # we don't look inside groups for paths
        inkex.debug('Group object {} will be ignored. Please ungroup before running the script.'.format(id))
      else: # something else
        inkex.debug('Object {} is not of type path ({}), and will be ignored. Current type "{}".'.format(id, pathTag, node.tag))

    for error in error_messages:
        inkex.debug(error)
开发者ID:funnypolynomial,项目名称:DestructiveClip,代码行数:29,代码来源:destructiveclip.py


示例13: snap_path_scale

    def snap_path_scale(self, elem, parent_transform=None):
        # If we have a Live Path Effect, modify original-d. If anyone clamours
        # for it, we could make an option to ignore paths with Live Path Effects
        original_d = "{%s}original-d" % inkex.NSS["inkscape"]
        path = simplepath.parsePath(elem.attrib.get(original_d, elem.attrib["d"]))
        transform = self.transform(elem, parent_transform=parent_transform)
        min_xy, max_xy = self.path_bounding_box(elem, parent_transform)

        width = max_xy[0] - min_xy[0]
        height = max_xy[1] - min_xy[1]

        # In case somebody tries to snap a 0-high element,
        # or a curve/arc with all nodes in a line, and of course
        # because we should always check for divide-by-zero!
        if width == 0 or height == 0:
            return

        rescale = round(width) / width, round(height) / height

        min_xy = transform_point(transform, min_xy, inverse=True)
        max_xy = transform_point(transform, max_xy, inverse=True)

        for i in range(len(path)):
            self.transform_path_node([[1, 0, -min_xy[0]], [0, 1, -min_xy[1]]], path, i)  # center transform
            self.transform_path_node([[rescale[0], 0, 0], [0, rescale[1], 0]], path, i)
            self.transform_path_node([[1, 0, +min_xy[0]], [0, 1, +min_xy[1]]], path, i)  # uncenter transform

        path = simplepath.formatPath(path)
        if original_d in elem.attrib:
            elem.attrib[original_d] = path
        else:
            elem.attrib["d"] = path
开发者ID:Grandrogue,项目名称:inkscape_metal,代码行数:32,代码来源:pixelsnap.py


示例14: movePath

    def movePath(self,node,x,y,origin):
        path = node.get('path')
        box = node.get('box')

        #inkex.debug(box)

        offset_x = (box[0] - x)
        offset_y = (box[2] - (y))

        #inkex.debug('Will move path "'+id+'" from x, y ' + str(box[0]) + ', ' + str(box[2]))
        #inkex.debug('to x, y ' + str(x) + ', ' + str(y))

        #inkex.debug('The x offset is ' + str(offset_x))
        #inkex.debug('The y offset is = ' + str(offset_y))


        for cmd in path:
            params = cmd[1]
            i = 0

            while(i < len(params)):
                if(i % 2 == 0):
                    #inkex.debug('x point at ' + str( round( params[i] )))
                    params[i] = (params[i] - offset_x)
                    #inkex.debug('moved to ' + str( round( params[i] )))
                else:
                    #inkex.debug('y point at ' + str( round( params[i]) ))
                    params[i] = (params[i] - offset_y)
                    #inkex.debug('moved to ' + str( round( params[i] )))
                i = i + 1


        #inkex.debug(simplepath.formatPath(path))
        return simplepath.formatPath(path)
开发者ID:larscwallin,项目名称:bansai,代码行数:34,代码来源:larscwallin.inx.bansai.py


示例15: d_path

 def d_path(self):
     a = list()
     a.append( ['M ', [self.x, self.y]] )
     a.append( [' l ', [self.width, 0]] )
     a.append( [' l ', [0, self.height]] )
     a.append( [' l ', [-self.width, 0]] )
     a.append( [' Z', []] )
     return simplepath.formatPath(a)     
开发者ID:vishpat,项目名称:Practice,代码行数:8,代码来源:shapes.py


示例16: effect

    def effect(self):
        for id, node in self.selected.iteritems():
            if node.tag == inkex.addNS("rect", "svg"):
                # create new path with basic dimensions of selected rectangle
                newpath = inkex.etree.Element(inkex.addNS("path", "svg"))
                x = float(node.get("x"))
                y = float(node.get("y"))
                w = float(node.get("width"))
                h = float(node.get("height"))

                # copy attributes of rect
                s = node.get("style")
                if s:
                    newpath.set("style", s)

                t = node.get("transform")
                if t:
                    newpath.set("transform", t)

                # top and bottom were exchanged
                newpath.set(
                    "d",
                    simplepath.formatPath(
                        drawfunction(
                            self.options.t_start,
                            self.options.t_end,
                            self.options.xleft,
                            self.options.xright,
                            self.options.ybottom,
                            self.options.ytop,
                            self.options.samples,
                            w,
                            h,
                            x,
                            y + h,
                            self.options.fofx,
                            self.options.fofy,
                            self.options.times2pi,
                            self.options.isoscale,
                            self.options.drawaxis,
                        )
                    ),
                )
                newpath.set("title", self.options.fofx + " " + self.options.fofy)

                # newpath.set('desc', '!func;' + self.options.fofx + ';' + self.options.fofy + ';'
                #                                      + `self.options.t_start` + ';'
                #                                      + `self.options.t_end` + ';'
                #                                      + `self.options.samples`)

                # add path into SVG structure
                node.getparent().append(newpath)
                # option wether to remove the rectangle or not.
                if self.options.remove:
                    node.getparent().remove(node)
开发者ID:wdmchaft,项目名称:DoonSketch,代码行数:55,代码来源:param_curves.py


示例17: effect

	def effect( self ):

		inkex.NSS[self.nsPrefix] = self.nsURI

		if self.options.bLace:
			func = 'lace'
		else:
			func = 'sine'

		fRecess = float( 1 )
		if self.options.fRecess > 0.0:
			fRecess = 1.0 - self.options.fRecess / float( 100 )
			if fRecess <= 0.0:
				fRecess = float( 0 )

		if self.options.ids:
			if len( self.options.ids ) == 2:
				attr = self.selected[self.options.ids[0]].attrib
				desc1 = self.selected[self.options.ids[0]].get( inkex.addNS( 'desc', self.nsPrefix ) )
				desc2 = self.selected[self.options.ids[1]].get( inkex.addNS( 'desc', self.nsPrefix ) )
				if ( not desc1 ) or ( not desc2 ):
					inkex.errormsg( 'Selected objects do not smell right' )
					return
				path_data, path_desc = drawSine( self.options.fCycles,
					self.options.nrN,
					self.options.nrM,
					self.options.nSamples,
					[ self.options.nOffsetX, self.options.nOffsetY ],
					self.options.nHeight,
					self.options.nWidth,
					fRecess,
					desc1, desc2, func, self.options.bSpline )
			else:
				inkex.errormsg( 'Exactly two objects must be selected' )
				return
		else:
			self.document.getroot().set( inkex.addNS( self.nsPrefix, 'xmlns' ), self.nsURI )

			path_data, path_desc = drawSine( self.options.fCycles,
				self.options.nrN,
				self.options.nrM,
				self.options.nSamples,
				[ self.options.nOffsetX, self.options.nOffsetY ],
				self.options.nHeight,
				self.options.nWidth,
				fRecess,
				None, None, func, self.options.bSpline )

		style = { 'stroke': 'black', 'stroke-width': '1', 'fill': 'none' }
		path_attrs = {
			'style': simplestyle.formatStyle( style ),
			'd': simplepath.formatPath( path_data ),
			inkex.addNS( 'desc', self.nsPrefix ): path_desc }
		newpath = inkex.etree.SubElement( self.document.getroot(),
			inkex.addNS( 'path', 'svg '), path_attrs, nsmap=inkex.NSS )
开发者ID:DDRBoxman,项目名称:Spherebot-Host-GUI,代码行数:55,代码来源:eggbot_sineandlace.py


示例18: load

 def load(self, node, mat):
   newpath = new_path_from_node(node)
   x1 = float(node.get('x1'))
   y1 = float(node.get('y1'))
   x2 = float(node.get('x2'))
   y2 = float(node.get('y2'))
   a = []
   a.append(['M ', [x1,y1]])
   a.append([' L ', [x2,y2]])
   newpath.set('d', simplepath.formatPath(a))
   SvgPath.load(self,newpath,mat)
开发者ID:FinucaneDesign,项目名称:inkscape-unicorn,代码行数:11,代码来源:svg_parser.py


示例19: connect

def connect (parent, start_node, end_node, style_dict, overwrite=False) :
	if overwrite or not already_connected(parent,start_node,end_node) :
		con = inkex.etree.SubElement(parent,inkex.addNS('path','svg'))
		#con.set("id",self.uniqueId("con"))
		con.set(inkex.addNS('connection-start','inkscape'),"#%s" % start_node.get("id"))
		con.set(inkex.addNS('connection-end','inkscape'),"#%s" % end_node.get("id"))
		con.set(inkex.addNS('connector-type','inkscape'),"polyline")
		path=[['M',element_center(start_node)],['L',element_center(end_node)]]
		con.set("d",simplepath.formatPath(path))
		style={"stroke":simplestyle.svgcolors["magenta"]}
		con.set("style",simplestyle.formatStyle(style_dict))
		return con
开发者ID:MarieLatutu,项目名称:openalea-components,代码行数:12,代码来源:simpleprimitive.py


示例20: effect

    def effect(self):
        newpath = None
        for id, node in self.selected.iteritems():
            if node.tag == inkex.addNS('rect','svg'):
                # create new path with basic dimensions of selected rectangle
                newpath = inkex.etree.Element(inkex.addNS('path','svg'))
                x = float(node.get('x'))
                y = float(node.get('y'))
                w = float(node.get('width'))
                h = float(node.get('height'))

                #copy attributes of rect
                s = node.get('style')
                if s:
                    newpath.set('style', s)
                
                t = node.get('transform')
                if t:
                    newpath.set('transform', t)
                    
                # top and bottom were exchanged
                newpath.set('d', simplepath.formatPath(
                            drawfunction(self.options.xstart,
                                self.options.xend,
                                self.options.ybottom,
                                self.options.ytop,
                                self.options.samples, 
                                w,h,x,y+h,
                                self.options.fofx, 
                                self.options.fpofx,
                                self.options.fponum,
                                self.options.times2pi,
                                self.options.polar,
                                self.options.isoscale,
                                self.options.drawaxis,
                                self.options.endpts)))
                newpath.set('title', self.options.fofx)
                
                #newpath.setAttribute('desc', '!func;' + self.options.fofx + ';' 
                #                                      + self.options.fpofx + ';'
                #                                      + `self.options.fponum` + ';'
                #                                      + `self.options.xstart` + ';'
                #                                      + `self.options.xend` + ';'
                #                                      + `self.options.samples`)
                                
                # add path into SVG structure
                node.getparent().append(newpath)
                # option wether to remove the rectangle or not.
                if self.options.remove:
                    node.getparent().remove(node)
        if newpath is None:
            inkex.errormsg(_("Please select a rectangle"))
开发者ID:Spin0za,项目名称:inkscape,代码行数:52,代码来源:funcplot.py



注:本文中的simplepath.formatPath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python simplepath.parsePath函数代码示例发布时间:2022-05-27
下一篇:
Python parser.Parser类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap