def __fixPathDefinition(pathDefinition, cm): """ @type pathDefinition: string @param pathDefinition: path 'd' attribute value to be modified @type cm: NumPy array @param cm: Transformation matrix to be applied. @return: path difinition transformed using cm matrix """ pathPoints = parsePath(pathDefinition) for i in range(len(pathPoints)): for j in [j for j in range(0, len(pathPoints[i][1:][0]), 2)]: pathPoints[i][1:][0][j:j+2] = __transformPoint(pathPoints[i][1:][0][j:j+2], cm) return UnparsePath(pathPoints)
def __fixPathDefinition(pathDefinition, cm): """ @type pathDefinition: string @param pathDefinition: path 'd' attribute value to be modified @type cm: NumPy array @param cm: Transformation matrix to be applied. @return: path difinition transformed using cm matrix """ pathPoints = parsePath(pathDefinition) for i in range(len(pathPoints)): for j in [j for j in range(0, len(pathPoints[i][1:][0]), 2)]: pathPoints[i][1:][0][j:j + 2] = __transformPoint( pathPoints[i][1:][0][j:j + 2], cm) return UnparsePath(pathPoints)
def __fixPath(el,cm): """ @type el: DOM object @param el: Path SVG element to be modified. @type cm: NumPy array @param cm: Transformation matrix to be applied. @return : nothing - only element C{el} is modified. @requires: Segments of paths has to be separated by whitespace so we split 'd' string by whitespace. Funtion transforms all points in path one by one using provided transformation matrix. """ # Create table of path elements by splitting 'd' string SegmentsTable=split(el.attributes['d'].value) pathPoints = parsePath(el.attributes['d'].value) for i in range(len(pathPoints)): for j in [j for j in range(0, len(pathPoints[i][1:][0]), 2)]: pathPoints[i][1:][0][j:j+2] = __transformPoint(pathPoints[i][1:][0][j:j+2], cm) # Update path definition el.attributes['d'].value = UnparsePath(pathPoints)
def __fixPath(el, cm): """ @type el: DOM object @param el: Path SVG element to be modified. @type cm: NumPy array @param cm: Transformation matrix to be applied. @return : nothing - only element C{el} is modified. @requires: Segments of paths has to be separated by whitespace so we split 'd' string by whitespace. Funtion transforms all points in path one by one using provided transformation matrix. """ # Create table of path elements by splitting 'd' string SegmentsTable = split(el.attributes['d'].value) pathPoints = parsePath(el.attributes['d'].value) for i in range(len(pathPoints)): for j in [j for j in range(0, len(pathPoints[i][1:][0]), 2)]: pathPoints[i][1:][0][j:j + 2] = __transformPoint( pathPoints[i][1:][0][j:j + 2], cm) # Update path definition el.attributes['d'].value = UnparsePath(pathPoints)
#p.set('fill', color_hex) if color_hex == '#000000': p.set('fill', color_hex) p.set('stroke', color_hex) else: p.set('fill', '#808080') #p.set('stroke', color_hex) p.set('stroke','#808080') if id_ == 0 or id_ == 10000: continue else: #id_ = int(r, 16) d = svgpathparse.parsePath(p.get('d')) for cmd, vertices in d: if cmd == 'Z': # do nothing, the polygon algorithm should handle this better pass #line_coord.append(line_coord[0]) elif cmd == 'M': last = vertices _first_line = True if len(line_coord) > 0: line_coords.append([[_x * Coef[0], _y * Coef[1]] for _x, _y in line_coord]) line_coord = [] elif cmd == 'L': if _first_line: line_coord.append(tuple(last)) _first_line = False