optimizePaths.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:inkscapeOptimizePath 作者: Daekkyn 项目源码 文件源码
def pathsToSVG(self, G, paths):
        svgPaths = []
        for path in paths:
            svgPath = []
            for nodeIndex, n in enumerate(path):
                command = None
                if nodeIndex == 0:
                    command = 'M'
                else:
                    command = 'L'
                svgPath.append([command, (G.node[n]['x'], G.node[n]['y'])])
            svgPaths.append(svgPath)

        #Create a group
        parent = inkex.etree.SubElement(self.current_layer, inkex.addNS('g','svg'))

        for pathIndex, svgPath in enumerate(svgPaths):
            #Generate a different color for every path
            color = colorsys.hsv_to_rgb(pathIndex/float(len(svgPaths)), 1.0, 1.0)
            color = tuple(x * 255 for x in color)
            color = self.rgbToHex( color )
            self.addPathToInkscape(svgPath, parent, color)

    #Computes the physical path length (it ignores the edge weight)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号