perspective.py revision 30bda02595fa0bcf215ceaf3f2e7044cb816c545
"""
Copyright (C) 2005 Aaron Spike, aaron@ekips.org
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
Perspective approach & math by Dmitry Platonov, shadowjack@mail.ru, 2006
"""
# standard library
import sys
import os
import re
try:
except:
# local library
import inkex
import simplepath
import cubicsuperpath
import simpletransform
from ffgeom import *
# third party
try:
from numpy import *
except:
inkex.errormsg(_("Failed to import the numpy or numpy.linalg modules. These modules are required by this extension. Please install them and try again. On a Debian-like system this can be done with the command, sudo apt-get install python-numpy."))
exit()
exit()
#obj is selected second
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()
exit()
for i in range(4):
#query inkscape about the bounding box of obj
q = {'x':0,'y':0,'width':0,'height':0}
if bsubprocess:
p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE)
else:
f.close()
sp = array([[q['x'], q['y']+q['height']],[q['x'], q['y']],[q['x']+q['width'], q['y']],[q['x']+q['width'], q['y']+q['height']]], dtype=float64)
else:
inkex.errormsg(_("The second selected object is a group, not a path.\nTry using the procedure Object->Ungroup."))
else:
inkex.errormsg(_("The second selected object is not a path.\nTry using the procedure Path->Object to Path."))
exit()
else:
inkex.errormsg(_("The first selected object is not a path.\nTry using the procedure Path->Object to Path."))
exit()
for i in (0,1,2,3):
projmatrix = array([[res[0],res[1],res[2]],[res[3],res[4],res[5]],[res[6],res[7],1.0]],dtype=float64)
p = cubicsuperpath.parsePath(d)
for subs in p:
def project_point(self,p,m):
x = p[0]
y = p[1]
return [(x*m[0][0] + y*m[0][1] + m[0][2])/(x*m[2][0]+y*m[2][1]+m[2][2]),(x*m[1][0] + y*m[1][1] + m[1][2])/(x*m[2][0]+y*m[2][1]+m[2][2])]
if __name__ == '__main__':
e = Project()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99