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

Python simplestyle.parseStyle函数代码示例

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

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



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

示例1: expandGroupsUnlinkClones

    def expandGroupsUnlinkClones(self,aList,transferTransform=True,doReplace=True):
        for id in aList.keys()[:]:     
            node=aList[id]
            if node.tagName == 'g':
                self.expandGroups(aList,transferTransform)
                self.expandGroupsUnlinkClones(aList,transferTransform,doReplace)
		#Hum... not very efficient if there are many clones of groups...
            elif node.tagName == 'use':
                refid=node.getAttributeNS(inkex.NSS[u'xlink'],'href')
                path = '//*[@id="%s"]' % refid[1:]
                refnode = xml.xpath.Evaluate(path,self.document)[0]
                newnode=refnode.cloneNode(True)
		self.recursNewIds(newnode)

		if node.hasAttributeNS(None,u'style'):
		    style=simplestyle.parseStyle(node.getAttributeNS(None,u'style'))
		    refstyle=simplestyle.parseStyle(refnode.getAttributeNS(None,u'style'))
		    style.update(refstyle)
		    newnode.setAttributeNS(None,'style',simplestyle.formatStyle(style))
                applyTransformToNode(parseTransform(node.getAttributeNS(None,'transform')),newnode)
                if doReplace:
                    parent=node.parentNode
                    parent.insertBefore(newnode,node)
                    parent.removeChild(node)
                del aList[id]
		newid=newnode.getAttributeNS(None,'id')
                aList.update(self.expandGroupsUnlinkClones({newid:newnode},transferTransform,doReplace))
        return aList
开发者ID:NirBenTalLab,项目名称:find_motif,代码行数:28,代码来源:pathmodifier.py


示例2: decode_vector

	def decode_vector(self, img):
		self.data = [None] * (self.size ** 2)
		self.transform = img.attrib['transform']
		self.pos = (float('inf'), float('inf'))

		pixels = img.xpath('//svg:rect', namespaces=inkex.NSS)
		paths = img.xpath('//svg:path', namespaces=inkex.NSS)

		# Because svg groups have no set x,y coords we have to decern the
		# position from the contents which we can then use as an offset when
		# reconstructing the image.
		for pixel in pixels + paths:
			pos = (inkex.unittouu(pixel.attrib['x']),
				   inkex.unittouu(pixel.attrib['y']))
			self.pos[0] = self.pos[0] if self.pos[0] < pos[0] else pos[0]
			self.pos[1] = self.pos[1] if self.pos[1] < pos[1] else pos[1]

		for pixel in pixels:
			style = simplestyle.parseStyle(pixel.attrib['style'])
			pos = (inkex.unittouu(pixel.attrib['x']) - self.pos[0],
				   inkex.unittouu(pixel.attrib['y']) - self.pos[1])
			index = pos2index(self.size, *pos)
			self.data[index] = simplestyle.parseColor(style['fill'])

		last_point = (0, 0)
		for path in paths:
			for offset in re.findall('m\s(?P<x>-?\d+),(?P<y>-?\d+).*?z'):
				style = simplestyle.parseStyle(pixel.attrib['style'])
				pos = (inkex.unittouu(path.attrib['x']) - self.pos[0] + last_point[0],
					   inkex.unittouu(path.attrib['y']) - self.pos[1] + last_point[1])
				index = pos2index(self.size, *pos)
				self.data[index] = simplestyle.parseColor(style['fill'])

				last_point[0] += offset[0]
				last_point[1] += offset[1]
开发者ID:PatrickKennedy,项目名称:tileset-tools,代码行数:35,代码来源:tti_tools.py


示例3: effect

    def effect(self):
        defs = self.xpathSingle('/svg//defs')
        if not defs:
            defs = self.document.createElement('svg:defs')
            self.document.documentElement.appendChile(defs)

        for id, node in self.selected.iteritems():
            mprops = ['marker', 'marker-start', 'marker-mid', 'marker-end']
            try:
                style = simplestyle.parseStyle(
                    node.attributes.getNamedItem('style').value)
            except:
                inkex.debug("No style attribute found for id: %s" % id)
                continue

            stroke = style.get('stroke', '#000000')

            for mprop in mprops:
                if style.has_key(mprop) and style[mprop] != 'none' and style[
                        mprop][:5] == 'url(#':
                    marker_id = style[mprop][5:-1]
                    try:
                        old_mnode = self.xpathSingle(
                            '/svg//marker[@id="%s"]' % marker_id)
                        if not self.options.modify:
                            mnode = old_mnode.cloneNode(True)
                        else:
                            mnode = old_mnode
                    except:
                        inkex.debug("unable to locate marker: %s" % marker_id)
                        continue

                    new_id = self.uniqueId(marker_id, not self.options.modify)

                    style[mprop] = "url(#%s)" % new_id
                    mnode.attributes.getNamedItem('id').value = new_id
                    mnode.attributes.getNamedItemNS(inkex.NSS['inkscape'],
                                                    'stockid').value = new_id
                    defs.appendChild(mnode)

                    children = inkex.xml.xpath.Evaluate(
                        '/svg//marker[@id="%s"]//*[@style]' % new_id,
                        self.document,
                        context=self.ctx)
                    for child in children:
                        cstyle = simplestyle.parseStyle(
                            child.attributes.getNamedItem('style').value)
                        if ('stroke' in cstyle and cstyle['stroke'] != 'none'
                            ) or 'stroke' not in cstyle:
                            cstyle['stroke'] = stroke
                        if ('fill' in cstyle and cstyle['fill'] != 'none'
                            ) or 'fill' not in cstyle:
                            cstyle['fill'] = stroke
                        child.attributes.getNamedItem(
                            'style').value = simplestyle.formatStyle(cstyle)
            node.attributes.getNamedItem(
                'style').value = simplestyle.formatStyle(style)
开发者ID:NirBenTalLab,项目名称:proorigami-cde-package,代码行数:57,代码来源:markers_strokepaint.py


示例4: __call__

 def __call__(self, elem):
     style = elem.get("style")
     if style is None:
         return
     parsed = simplestyle.parseStyle(style)
     if "stroke" in parsed and parsed["stroke"] != "none":
         yield CheckerResult("element with stroke found", elem)
开发者ID:starshipfactory,项目名称:precut,代码行数:7,代码来源:precut.py


示例5: 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


示例6: change_attribute

 def change_attribute(self, node, attribute):
     for key, value in attribute.items():
         if key == 'preserveAspectRatio':
             # set presentation attribute
             if value != "unset":
                 node.set(key, str(value))
             else:
                 if node.get(key):
                     del node.attrib[key]
         elif key == 'image-rendering':
             node_style = simplestyle.parseStyle(node.get('style'))
             if key not in node_style:
                 # set presentation attribute
                 if value != "unset":
                     node.set(key, str(value))
                 else:
                     if node.get(key):
                         del node.attrib[key]
             else:
                 # set style property
                 if value != "unset":
                     node_style[key] = str(value)
                 else:
                     del node_style[key]
                 node.set('style', simplestyle.formatStyle(node_style))
         else:
             pass
开发者ID:Drooids,项目名称:inkscape,代码行数:27,代码来源:image_attributes.py


示例7: 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


示例8: setGradient

    def setGradient(self, href):
        try:
            g = self.svg.xpath("//*[@id='%s']" % href, namespaces=inkex.NSS)[0]
        except:
            return

        if g.get("r"):
            cx = float(g.get("cx"))
            cy = float(g.get("cy"))
            r = float(g.get("r"))
            self.createRadialGradient(href, cx, cy, r, cx, cy, r)
        else:
            x1 = float(g.get("x1"))
            y1 = float(g.get("y1"))
            x2 = float(g.get("x2"))
            y2 = float(g.get("y2"))
            self.createLinearGradient(href, x1, y1, x2, y2)

        #get gradient color stops
        gstops = g.get(inkex.addNS("href", "xlink"))
        gstops = self.svg.xpath("//svg:linearGradient[@id='%s']" % gstops[1:], namespaces=inkex.NSS)[0]
        for stop in gstops:
            style = simplestyle.parseStyle(stop.get("style"))
            stop_color = style["stop-color"]
            opacity = style["stop-opacity"]
            color = self.getColor(stop_color, opacity)
            pos = float(stop.get("offset"))
            self.addColorStop(href, pos, color)
        return href
开发者ID:wickedtribe,项目名称:Ink2canvas,代码行数:29,代码来源:canvas.py


示例9: isGroupVisible

 def isGroupVisible(self, group):
     style = group.get('style')
     if style:
         style = simplestyle.parseStyle(style)
         if 'display' in style and style['display'] == 'none':
             return False
     return True
开发者ID:AakashDabas,项目名称:inkscape,代码行数:7,代码来源:hpgl_encoder.py


示例10: 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


示例11: plotPath

   def plotPath(self, node, matTransform):
      """ Plot the path while applying the transformation defined by the matrix matTransform. """

      filledPath = (simplestyle.parseStyle(node.get("style")).get("fill", "none") != "none")

      # Plan: Turn this path into a cubicsuperpath (list of beziers)...
      d = node.get("d")
      if len(simplepath.parsePath(d)) == 0:
         return
      p = cubicsuperpath.parsePath(d)

      # ... and apply the transformation to each point.
      simpletransform.applyTransformToPath(matTransform, p)

      # p is now a list of lists of cubic beziers [cp1, cp2, endp]
      # where the start-point is the last point of the previous segment.
      # For some reason the inkscape extensions uses csp[1] as the coordinates of each point,
      # but that makes it seem like they are using control point 2 as line points.
      # Maybe that is a side-effect of the CSP subdivion process? TODO
      realPoints = []
      for sp in p:
         cspsubdiv.subdiv(sp, self.smoothness)
         for csp in sp:
            realPoints.append( (csp[1][0], csp[1][1]) )

      self.rawObjects.append( (filledPath, realPoints) )
开发者ID:wayneandlayne,项目名称:svg2kicadmod,代码行数:26,代码来源:SvgParser.py


示例12: split_letters

    def split_letters(self, node):
        """Returns a list of letters"""

        letters = []
        
        words = self.split_words(node)
        if not words:
            return letters

        for word in words:
            
            x = float(word.get("x"))
            y = word.get("y")
           
            #gets the font size. If element doesn't have a style attribute, it assumes font-size = 12px
            try:
                import simplestyle
                fontsize = simplestyle.parseStyle(word.get("style"))["font-size"]
            except:
                fontsize = "12px"
            fs = self.unittouu(fontsize)

            #for each letter in element string
            for letter in word[0].text:
                tspan = inkex.etree.Element(inkex.addNS("tspan", "svg"))
                tspan.text = letter

                text = inkex.etree.Element(inkex.addNS("text", "svg"), node.attrib)
                text.set("x", str(x))
                text.set("y", str(y))
                x += fs
                
                text.append(tspan)
                letters.append(text)
        return letters
开发者ID:Drooids,项目名称:inkscape,代码行数:35,代码来源:split.py


示例13: 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


示例14: checkStyle

def checkStyle(node):
    if node.hasAttributes():
        sa=node.getAttribute('style')
        if sa!='':
            styles=simplestyle.parseStyle(sa)
            for c in range(len(colortags)):
                if colortags[c] in styles.keys():
                    addColor(styles[colortags[c]])
开发者ID:NirBenTalLab,项目名称:find_motif,代码行数:8,代码来源:export_gimp_palette.py


示例15: checkStyle

def checkStyle(node):
    if hasattr(node, "hasAttributes") and node.hasAttributes():
        sa = node.getAttribute("style")
        if sa != "":
            styles = simplestyle.parseStyle(sa)
            for c in range(len(colortags)):
                if colortags[c] in styles.keys():
                    addColor(styles[colortags[c]])
开发者ID:step21,项目名称:inkscape-osx-packaging-native,代码行数:8,代码来源:export_gimp_palette.py


示例16: 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


示例17: split_lines

    def split_lines(self, node):
        """Returns a list of lines"""

        lines = []
        count = 1

        for n in node:
            if not (n.tag == inkex.addNS("flowPara", "svg") or n.tag == inkex.addNS("tspan", "svg")):
                if n.tag == inkex.addNS("textPath", "svg"):
                    inkex.debug("This type of text element isn't supported. First remove text from path.")
                    break
                else:
                    continue

            text = inkex.etree.Element(inkex.addNS("text", "svg"), node.attrib)

            # handling flowed text nodes
            if node.tag == inkex.addNS("flowRoot", "svg"):
                try:
                    from simplestyle import parseStyle

                    fontsize = parseStyle(node.get("style"))["font-size"]
                except:
                    fontsize = "12px"
                fs = inkex.unittouu(fontsize)

                # selects the flowRegion's child (svg:rect) to get @X and @Y
                id = node.get("id")
                flowref = self.xpathSingle('/svg:svg//*[@id="%s"]/svg:flowRegion[1]' % id)[0]

                if flowref.tag == inkex.addNS("rect", "svg"):
                    text.set("x", flowref.get("x"))
                    text.set("y", str(float(flowref.get("y")) + fs * count))
                    count += 1
                else:
                    inkex.debug("This type of text element isn't supported. First unflow text.")
                    break

                # now let's convert flowPara into tspan
                tspan = inkex.etree.Element(inkex.addNS("tspan", "svg"))
                tspan.set(inkex.addNS("role", "sodipodi"), "line")
                tspan.text = n.text
                text.append(tspan)

            else:
                from copy import copy

                x = n.get("x") or node.get("x")
                y = n.get("y") or node.get("y")

                text.set("x", x)
                text.set("y", y)
                text.append(copy(n))

            lines.append(text)

        return lines
开发者ID:vabz7867,项目名称:inkscape,代码行数:57,代码来源:split.py


示例18: split_words

    def split_words(self, node):
        """Returns a list of words"""

        words = []

        # Function to recursively extract text
        def plain_str(elem):
            words = []
            if elem.text:
                words.append(elem.text)
            for n in elem:
                words.extend(plain_str(n))
                if n.tail:
                    words.append(n.tail)
            return words

        # if text has more than one line, iterates through elements
        lines = self.split_lines(node)
        if not lines:
            return words

        for line in lines:
            # gets the position of text node
            x = float(line.get("x"))
            y = line.get("y")

            # gets the font size. if element doesn't have a style attribute, it assumes font-size = 12px
            try:
                from simplestyle import parseStyle

                fontsize = parseStyle(line.get("style"))["font-size"]
            except:
                fontsize = "12px"
            fs = inkex.unittouu(fontsize)

            # extract and returns a list of words
            words_list = "".join(plain_str(line)).split()
            prev_len = 0

            # creates new text nodes for each string in words_list
            for word in words_list:
                tspan = inkex.etree.Element(inkex.addNS("tspan", "svg"))
                tspan.text = word

                text = inkex.etree.Element(inkex.addNS("text", "svg"), line.attrib)
                tspan.set(inkex.addNS("role", "sodipodi"), "line")

                # positioning new text elements
                x = x + prev_len * fs
                prev_len = len(word)
                text.set("x", str(x))
                text.set("y", str(y))

                text.append(tspan)
                words.append(text)

        return words
开发者ID:vabz7867,项目名称:inkscape,代码行数:57,代码来源:split.py


示例19: effect

    def effect(self):
        # get number of digits
        prec = int(self.options.precision)
        total = 0
        stotal = 0
        totals = {}
        # loop over all selected paths
        for node in self.document.getroot().iterdescendants():
            # path = "*"
            # for node in self.document.xpath(path, namespaces=inkex.NSS):
            if node.tag == inkex.addNS("path", "svg"):
                id = node.get("id")
                self.group = inkex.etree.SubElement(node.getparent(), inkex.addNS("text", "svg"))
                t = node.get("transform")
                # inkex.debug(node.get("style"))
                d = node.get("d")
                if not ("stroke" in simplestyle.parseStyle(node.get("style")) and len(simplepath.parsePath(d))):
                    continue
                stroke = simplestyle.parseStyle(node.get("style"))["stroke"]
                a = []
                p = cubicsuperpath.parsePath(node.get("d"))
                num = 1
                factor = 1.0 / inkex.unittouu("1" + self.options.unit)
                if self.options.type == "length":
                    slengths, stotal = csplength(p)
                else:
                    stotal, x0, y0 = csparea(p)
                    stotal *= factor * self.options.scale
                total += stotal
                if stroke in totals:
                    totals[stroke] += stotal
                else:
                    totals[stroke] = stotal
                # Format the length as string

        for key in totals:
            lenstr = locale.format(
                "%(len)25." + str(prec) + "f", {"len": round(totals[key] * factor * self.options.scale, prec)}
            ).strip()
            val = key
            for color in simplestyle.svgcolors.keys():
                if simplestyle.svgcolors.get(color) == key:
                    val = color
            inkex.debug(val + ":\t" + lenstr + "\t" + self.options.unit)
开发者ID:dustinandrews,项目名称:InkscapeExtensions,代码行数:44,代码来源:measure_all.py


示例20: effect

 def effect(self):
     defs = self.xpathSingle('/svg:svg//svg:defs')
     if defs == None:
         defs = inkex.etree.SubElement(self.document.getroot(),inkex.addNS('defs','svg'))
     
     for id, node in self.selected.iteritems():
         mprops = ['marker','marker-start','marker-mid','marker-end']
         try:
             style = simplestyle.parseStyle(node.get('style'))
         except:
             inkex.errormsg(_("No style attribute found for id: %s") % id)
             continue
         
         stroke = style.get('stroke', '#000000')
         
         for mprop in mprops:
             if style.has_key(mprop) and style[mprop] != 'none'and style[mprop][:5] == 'url(#':
                 marker_id = style[mprop][5:-1]
                 try:
                     old_mnode = self.xpathSingle('/svg:svg//svg:marker[@id="%s"]' % marker_id)
                     if not self.options.modify:
                         mnode = copy.deepcopy(old_mnode)
                     else:
                         mnode = old_mnode
                 except:
                     inkex.errormsg(_("unable to locate marker: %s") % marker_id)
                     continue
                     
                 new_id = self.uniqueId(marker_id, not self.options.modify)
                 
                 style[mprop] = "url(#%s)" % new_id
                 mnode.set('id', new_id)
                 mnode.set(inkex.addNS('stockid','inkscape'), new_id)
                 defs.append(mnode)
                 
                 children = mnode.xpath('.//*[@style]', namespaces=inkex.NSS)
                 for child in children:
                     cstyle = simplestyle.parseStyle(child.get('style'))
                     if ('stroke' in cstyle and cstyle['stroke'] != 'none') or 'stroke' not in cstyle:
                         cstyle['stroke'] = stroke
                     if ('fill' in cstyle and cstyle['fill'] != 'none') or 'fill' not in cstyle:
                         cstyle['fill'] = stroke
                     child.set('style',simplestyle.formatStyle(cstyle))
         node.set('style',simplestyle.formatStyle(style))
开发者ID:DDRBoxman,项目名称:Spherebot-Host-GUI,代码行数:44,代码来源:markers_strokepaint.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python simpleTAL.compileHTMLTemplate函数代码示例发布时间:2022-05-27
下一篇:
Python simplestyle.parseColor函数代码示例发布时间: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