16
16
along with this program; if not, write to the Free Software
17
17
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
import inkex, cubicsuperpath, simplepath, cspsubdiv
19
import inkex, cubicsuperpath, simplepath, simplestyle, cspsubdiv
21
21
class MyEffect(inkex.Effect):
22
22
def __init__(self):
23
23
inkex.Effect.__init__(self)
24
24
self.OptionParser.add_option("-f", "--flatness",
25
25
action="store", type="float",
26
dest="flat", default=10.0,
26
dest="flat", default=0.2,
27
27
help="Minimum flatness of the subdivided curves")
28
self.OptionParser.add_option("-m", "--mirror",
29
action="store", type="inkbool",
30
dest="mirror", default="FALSE",
32
self.OptionParser.add_option("-x", "--xOrigin",
33
action="store", type="float",
34
dest="xOrigin", default=0.0,
35
help="X Origin (pixels)")
36
self.OptionParser.add_option("-y", "--yOrigin",
37
action="store", type="float",
38
dest="yOrigin", default=0.0,
39
help="Y Origin (pixels)")
40
self.OptionParser.add_option("-p", "--plotInvisibleLayers",
41
action="store", type="inkbool",
42
dest="plotInvisibleLayers", default="FALSE",
43
help="Plot invisible layers")
28
45
self.hpgl = ['IN;SP1;']
30
47
print ''.join(self.hpgl)
33
for node in self.document.getroot().xpath(path, namespaces=inkex.NSS):
35
if len(simplepath.parsePath(d)):
36
p = cubicsuperpath.parsePath(d)
37
cspsubdiv.cspsubdiv(p, self.options.flat)
45
self.hpgl.append('%s%s,%s;' % (cmd,csp[1][0],csp[1][1]))
50
if self.options.mirror:
52
x0 = self.options.xOrigin
53
y0 = self.options.yOrigin
56
layerPath = '//svg:g[@inkscape:groupmode="layer"]'
57
for layer in self.document.getroot().xpath(layerPath, namespaces=inkex.NSS):
59
style = layer.get('style')
61
style = simplestyle.parseStyle(style)
62
if style['display']=='none':
63
if not self.options.plotInvisibleLayers:
65
nodePath = ('//svg:g[@inkscape:groupmode="layer"][%d]/descendant::svg:path') % i
66
for node in self.document.getroot().xpath(nodePath, namespaces=inkex.NSS):
68
if len(simplepath.parsePath(d)):
69
p = cubicsuperpath.parsePath(d)
70
cspsubdiv.cspsubdiv(p, self.options.flat)
78
self.hpgl.append('%s%d,%d;' % (cmd,(csp[1][0] - x0)*scale,(csp[1][1] - y0)*scale*mirror))
47
80
if __name__ == '__main__': #pragma: no cover
84
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99