Mercurial > MadButterfly
changeset 1133:bc619172bd2c
Do translation for every elements.
author | wycc |
---|---|
date | Sun, 19 Dec 2010 00:02:31 +0800 |
parents | 3de972a43d46 |
children | bd0cfb8666b8 |
files | pyink/MBScene.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/MBScene.py Sat Dec 18 23:51:22 2010 +0800 +++ b/pyink/MBScene.py Sun Dec 19 00:02:31 2010 +0800 @@ -664,6 +664,10 @@ return [m[0],m[1],m[2],m[3],(m[4]-m[3]*m[4]+m[1]*m[5])/d,(m[5]-m[0]*m[5]+m[2]*m[4])/d] def decomposition(self,m): + """ + Decompose the affine matrix into production of translation,rotation,shear and scale. + The algorithm is documented at http://lists.w3.org/Archives/Public/www-style/2010Jun/0602.html + """ if m[0]*m[3] == m[1]*m[2]: print "The affine matrix is singular" return [1,0,0,1,0,0] @@ -756,15 +760,12 @@ a = ss[2]*(1-p)+dd[2]*p tx = ox*(1-p)+dx*p ty = oy*(1-p)+dy*p - #m = self.mulA([math.cos(a),-math.sin(a),math.sin(a),math.cos(a),0,0],[sx,0,0,sy,0,0]) - #a=3.141592/2*p m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0] m = self.mulA([sx,0,0,sy,0,0],m) m = self.mulA(m,[1,0,0,1,-ox,oy-self.height]) m = self.mulA([1,0,0,1,tx,self.height-ty],m) - if dd[0] != ss[0]: - top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5])) + top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5])) else: try: sw = float(s.attribute("width"))