From: prokoudine Date: Thu, 5 Jun 2008 15:56:03 +0000 (+0000) Subject: added HPGL export extension, courtesy of Aaron Spike X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=e0f8c7119a43773d56c2c4e8236855311409f1de;p=inkscape.git added HPGL export extension, courtesy of Aaron Spike --- diff --git a/po/POTFILES.in b/po/POTFILES.in index 3c20358b3..a520095b7 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -373,6 +373,7 @@ share/extensions/svg_and_media_zip_output.py [type: gettext/xml] share/extensions/grid_cartesian.inx [type: gettext/xml] share/extensions/grid_polar.inx [type: gettext/xml] share/extensions/handles.inx +[type: gettext/xml] share/extensions/hpgl_output.inx [type: gettext/xml] share/extensions/inkscape_help_askaquestion.inx [type: gettext/xml] share/extensions/inkscape_help_commandline.inx [type: gettext/xml] share/extensions/inkscape_help_faq.inx diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am index 62fa9eeda..73b5ad78a 100644 --- a/share/extensions/Makefile.am +++ b/share/extensions/Makefile.am @@ -59,6 +59,7 @@ extensions = \ grid_cartesian.py \ grid_polar.py \ handles.py \ + hpgl_output.py \ ill2svg.pl \ inkex.py \ interp.py \ @@ -167,6 +168,7 @@ modules = \ grid_cartesian.inx \ grid_polar.inx \ handles.inx \ + hpgl_output.inx \ inkscape_help_askaquestion.inx \ inkscape_help_commandline.inx \ inkscape_help_faq.inx\ diff --git a/share/extensions/hpgl_output.inx b/share/extensions/hpgl_output.inx new file mode 100644 index 000000000..f351a79f4 --- /dev/null +++ b/share/extensions/hpgl_output.inx @@ -0,0 +1,19 @@ + + + <_name>HPGL Output + org.ekips.output.hpgl + org.inkscape.output.svg.inkscape + hpgl_output.py + inkex.py + + .hpgl + image/hpgl + <_filetypename>HP Graphics Language file (*.hpgl) + <_filetypetooltip>Export to an HP Graphics Language file + TRUE + + + diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py new file mode 100644 index 000000000..f94456a0c --- /dev/null +++ b/share/extensions/hpgl_output.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +''' +Copyright (C) 2008 Aaron Spike, aaron@ekips.org + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' +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") + self.hpgl = ['IN;SP1;'] + def output(self): + print ''.join(self.hpgl) + def effect(self): + path = '//svg:path' + for node in self.document.getroot().xpath(path, namespaces=inkex.NSS): + d = node.get('d') + p = cubicsuperpath.parsePath(d) + cspsubdiv.cspsubdiv(p, self.options.flat) + for sp in p: + first = True + for csp in sp: + cmd = 'PD' + if first: + cmd = 'PU' + first = False + self.hpgl.append('%s%s,%s;' % (cmd,csp[1][0],csp[1][1])) + +e = MyEffect() +e.affect() \ No newline at end of file