# HG changeset patch # User Matti Hamalainen # Date 1349809692 -10800 # Node ID cac0b6cfebb45a3479b92896dce9d669523738ae # Parent 9c33e11c3d391bd4505b40e39b57ff83d8251d01 Improve python converter. diff -r 9c33e11c3d39 -r cac0b6cfebb4 svg2qd.py --- a/svg2qd.py Tue Oct 09 21:49:47 2012 +0300 +++ b/svg2qd.py Tue Oct 09 22:08:12 2012 +0300 @@ -34,17 +34,17 @@ return style -def printVertices(type, vertices, width) : +def printVertices(type, vertices, width, level) : if len(vertices) > 0 : list = map(lambda v:printVertex(v), vertices) - str = "# " + str = "# "+ type if type == "m" : str = "R" elif type == "M" : str = "L" - return str + "{} {} {}".format(len(vertices)-1, " ".join(list), width) - else : - return "" + elif type == "c" : + str = "R" + print "{}{}{} {} {}".format(" "*level, str, len(vertices)-1, " ".join(list), width) def printPath(path, level) : @@ -55,12 +55,12 @@ if trans : print "{}G{}".format(" "*level, printVertex(trans)) - out = "" vertices = [] type = "" for elem in path.attrib["d"].split(" ") : - if elem == "m" or elem == "M" or elem == "c": - out += printVertices(type, vertices, width) + if elem == "m" or elem == "M" or elem == "c" or elem == "C": + printVertices(type, vertices, width, level) + vertices = [] type = elem elif elem == "z" : vertices.append("Z") @@ -70,8 +70,7 @@ py = float(tmp[1]) vertices.append([px, py, 0]) - out += printVertices(type, vertices, width) - print "{}{}".format(" "*level, out) + printVertices(type, vertices, width, level) if trans : print "{}E\n".format(" "*level)