simpletransform.py revision 4a61cb7241913c1b27d6c30c84ce4ab91915a6f2
'''
Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr
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
barraud@math.univ-lille1.fr
This code defines several functions to make handling of transform
attribute easier.
'''
return(mat)
#-- translate --
dy=0.0
else:
#-- scale --
else:
#-- rotate --
else:
#-- skewX --
#-- skewY --
#-- matrix --
else:
return matrix
def formatTransform(mat):
return ("matrix(%f,%f,%f,%f,%f,%f)" % (mat[0][0], mat[1][0], mat[0][1], mat[1][1], mat[0][2], mat[1][2]))
pt[0]=x
pt[1]=y
def fuseTransform(node):
#FIXME: how do you raise errors?
raise AssertionError, 'can not fuse "transform" of elements that have no "d" attribute'
if t == None:
return
m = parseTransform(t)
p = cubicsuperpath.parsePath(d)
applyTransformToPath(m,p)
####################################################################
##-- Some functions to compute a rough bbox of a given list of objects.
##-- this should be shipped out in an separate file...
if b1 is None:
return b2
elif b2 is None:
return b1
else:
bbox=None
m = composeTransform(mat,m)
#TODO: text not supported!
p = cubicsuperpath.parsePath(d)
applyTransformToPath(m,p)
C = [x + w , y + h ]
return bbox
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99