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, os, simplepath, cubicsuperpath
from ffgeom import *
import gettext
_ = gettext.gettext
try:
from subprocess import Popen, PIPE
bsubprocess = True
except:
bsubprocess = False
class Project(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
def effect(self):
if len(self.options.ids) < 2:
inkex.errormsg(_("This extension requires two selected paths. \nThe second path must be exactly four nodes long."))
exit()
#obj is selected second
obj = self.selected[self.options.ids[0]]
trafo = self.selected[self.options.ids[1]]
if obj.get(inkex.addNS('type','sodipodi')):
inkex.errormsg(_("The first selected object is of type '%s'.\nTry using the procedure Path->Object to Path." % obj.get(inkex.addNS('type','sodipodi'))))
exit()
if obj.tag == inkex.addNS('path','svg') or obj.tag == inkex.addNS('g','svg'):
if trafo.tag == inkex.addNS('path','svg'):
#distil trafo into four node points
trafo = cubicsuperpath.parsePath(trafo.get('d'))
if len(trafo[0]) < 4:
inkex.errormsg(_("This extension requires that the second selected path be four nodes long."))
exit()
trafo = [[Point(csp[1][0],csp[1][1]) for csp in subs] for subs in trafo][0][:4]