当前位置: 首页>>代码示例>>Python>>正文


Python Node.getCharacterCount方法代码示例

本文整理汇总了Python中Node.Node.getCharacterCount方法的典型用法代码示例。如果您正苦于以下问题:Python Node.getCharacterCount方法的具体用法?Python Node.getCharacterCount怎么用?Python Node.getCharacterCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


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

示例1: simplifyNodes

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getCharacterCount [as 别名]
    def simplifyNodes(self, nodes):
        '''remove v, V, h, and H command'''
        point = []
        for node in nodes:
            node.showCommand = True
            characterCount = Node.getCharacterCount(node.command)
            if characterCount > 1:
                point = node.getTarget()
            elif characterCount == 1:
                if node.command == "v":
                    point[0] = "0"
                    point[1] = node.attrib[0]
                elif node.command == "V":
                    point[1] = node.attrib[0]
                elif node.command == "h":
                    point[0] = node.attrib[0]
                    point[1] = "0"
                elif node.command == "H":
                    point[0] = node.attrib[0]
                    
                if node.command == "v" or node.command == "h":
                    node.command = "l"
                elif node.command == "V" or node.command == "H":
                    node.command = "L"
                    
#                node.showCommand = True
                node.attrib = [ point[0],  point[1] ]
开发者ID:fpermana,项目名称:svgbuild-gui,代码行数:29,代码来源:SVGBuild.py

示例2: build_path

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import getCharacterCount [as 别名]

#.........这里部分代码省略.........
        paths = re.findall('[^Z]+Z', d)
        if len(paths) == 0:
            paths = d.split('Z')
        
        built = [ ]
        tempBuilt = [ ]
        pathLastNode = None
        
        # each control point is a letter, followed by some floating-point pairs
        for pathIndex, path in enumerate(paths):
            if len(path) == 0:
                continue
                
            nodes = []
            command = ""
            point = ""
            characterCount = 0
            showCommand = False
            
            points = path.strip().split(' ')
            pointsCount = len(points)

            node = None
            while points:
                if not self.isRunning: return
                
                point = points[0]
                
                node = Node()
                attrib = []
                if re.match(r'^[a-zA-Z]$', point):
                    command = point
                    showCommand = True
                    characterCount = Node.getCharacterCount(command)
                    points.pop(0)
                else:
                    '''avoid sequential M or m command'''
                    if command == "M":
                        command = "L"
                    elif command == "m":
                        command = "l"
                    showCommand = False
            
                for j in range(0, characterCount):
                    if len(points) > 0:
                        attrib.append(points.pop(0))

                node.command = command
                node.attrib = attrib
                node.showCommand = showCommand
                
                nodes.append(node)
            
            #self.simplifyNodes(nodes)
            leftPath = []
            rightPath = []
            
            closedPath = False
            node = nodes[-1]
            lastNode = None
            if node.command == "Z":
                closedPath = True
                
                firstNode = nodes[0]
                n = Node()
                
开发者ID:fpermana,项目名称:svgbuild-gui,代码行数:69,代码来源:SVGBuild.py


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