index b33591e0407af3ce16d6f884e9777c295e984660..ce691508639e576d263769df370513f33f118d60 100755 (executable)
import inkex, cubicsuperpath, simplepath, cspsubdiv
class MyEffect(inkex.Effect):
- def __init__(self):
- inkex.Effect.__init__(self)
- self.OptionParser.add_option("-f", "--flatness",
- action="store", type="float",
- dest="flat", default=10.0,
- help="Minimum flatness of the subdivided curves")
- def effect(self):
- for id, node in self.selected.iteritems():
- if node.tagName == 'path':
- d = node.attributes.getNamedItem('d')
- p = cubicsuperpath.parsePath(d.value)
- cspsubdiv.cspsubdiv(p, self.options.flat)
- np = []
- for sp in p:
- first = True
- for csp in sp:
- cmd = 'L'
- if first:
- cmd = 'M'
- first = False
- np.append([cmd,[csp[1][0],csp[1][1]]])
- d.value = simplepath.formatPath(np)
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("-f", "--flatness",
+ action="store", type="float",
+ dest="flat", default=10.0,
+ help="Minimum flatness of the subdivided curves")
+ def effect(self):
+ for id, node in self.selected.iteritems():
+ if node.tag == inkex.addNS('path','svg'):
+ d = node.get('d')
+ p = cubicsuperpath.parsePath(d)
+ cspsubdiv.cspsubdiv(p, self.options.flat)
+ np = []
+ for sp in p:
+ first = True
+ for csp in sp:
+ cmd = 'L'
+ if first:
+ cmd = 'M'
+ first = False
+ np.append([cmd,[csp[1][0],csp[1][1]]])
+ node.set('d',simplepath.formatPath(np))
-e = MyEffect()
-e.affect()
+if __name__ == '__main__':
+ e = MyEffect()
+ e.affect()
+
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99