comparison pyink/MBScene.py @ 1133:bc619172bd2c

Do translation for every elements.
author wycc
date Sun, 19 Dec 2010 00:02:31 +0800
parents 3ec0ad89e443
children 950076863b7e
comparison
equal deleted inserted replaced
1132:3de972a43d46 1133:bc619172bd2c
662 return [1,0,0,1,m[4],m[5]] 662 return [1,0,0,1,m[4],m[5]]
663 else: 663 else:
664 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] 664 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]
665 665
666 def decomposition(self,m): 666 def decomposition(self,m):
667 """
668 Decompose the affine matrix into production of translation,rotation,shear and scale.
669 The algorithm is documented at http://lists.w3.org/Archives/Public/www-style/2010Jun/0602.html
670 """
667 if m[0]*m[3] == m[1]*m[2]: 671 if m[0]*m[3] == m[1]*m[2]:
668 print "The affine matrix is singular" 672 print "The affine matrix is singular"
669 return [1,0,0,1,0,0] 673 return [1,0,0,1,0,0]
670 A=m[0] 674 A=m[0]
671 B=m[2] 675 B=m[2]
754 sx = ss[0]*(1-p)+dd[0]*p 758 sx = ss[0]*(1-p)+dd[0]*p
755 sy = ss[1]*(1-p)+dd[1]*p 759 sy = ss[1]*(1-p)+dd[1]*p
756 a = ss[2]*(1-p)+dd[2]*p 760 a = ss[2]*(1-p)+dd[2]*p
757 tx = ox*(1-p)+dx*p 761 tx = ox*(1-p)+dx*p
758 ty = oy*(1-p)+dy*p 762 ty = oy*(1-p)+dy*p
759 #m = self.mulA([math.cos(a),-math.sin(a),math.sin(a),math.cos(a),0,0],[sx,0,0,sy,0,0])
760 #a=3.141592/2*p
761 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0] 763 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0]
762 m = self.mulA([sx,0,0,sy,0,0],m) 764 m = self.mulA([sx,0,0,sy,0,0],m)
763 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height]) 765 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height])
764 m = self.mulA([1,0,0,1,tx,self.height-ty],m) 766 m = self.mulA([1,0,0,1,tx,self.height-ty],m)
765 767
766 if dd[0] != ss[0]: 768 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5]))
767 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5]))
768 else: 769 else:
769 try: 770 try:
770 sw = float(s.attribute("width")) 771 sw = float(s.attribute("width"))
771 sh = float(s.attribute("height")) 772 sh = float(s.attribute("height"))
772 dw = float(d.attribute("width")) 773 dw = float(d.attribute("width"))