simpletransform.py revision 2e32ff209b5c6377292bb77dd3cb58cb1b77ad91
'''
Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr
Copyright (C) 2010 Alvin Penner, penner@vaxxine.com
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]))
if trans:
return mat
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:
def refinedBBox(path):
cmin, cmax = cubicExtrema(pathcomp[i-1][1][0], pathcomp[i-1][2][0], pathcomp[i][0][0], pathcomp[i][1][0])
cmin, cmax = cubicExtrema(pathcomp[i-1][1][1], pathcomp[i-1][2][1], pathcomp[i][0][1], pathcomp[i][1][1])
if (t > 0) and (t < 1):
if (t > 0) and (t < 1):
if (t > 0) and (t < 1):
bbox=None
m = composeTransform(mat,m)
#TODO: text not supported!
d = None
if rx is not None:
else:
if d is not None:
p = cubicsuperpath.parsePath(d)
applyTransformToPath(m,p)
return bbox
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99