Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1131:3ec0ad89e443
Fix the mtraix animation.
author | wycc |
---|---|
date | Sat, 18 Dec 2010 23:50:43 +0800 |
parents | 37a0f6ab2f91 |
children | bc619172bd2c |
comparison
equal
deleted
inserted
replaced
1130:37a0f6ab2f91 | 1131:3ec0ad89e443 |
---|---|
274 #obs = LayerAddRemoveWatcher(self) | 274 #obs = LayerAddRemoveWatcher(self) |
275 #doc.addObserver(obs) | 275 #doc.addObserver(obs) |
276 addEventListener(doc,'DOMNodeInserted',self.updateUI,None) | 276 addEventListener(doc,'DOMNodeInserted',self.updateUI,None) |
277 addEventListener(doc,'DOMNodeRemoved',self.updateUI,None) | 277 addEventListener(doc,'DOMNodeRemoved',self.updateUI,None) |
278 doc.childList() | 278 doc.childList() |
279 try: | |
280 self.width = float(doc.attribute("width")) | |
281 self.height= float(doc.attribute("height")) | |
282 except: | |
283 self.width = 640 | |
284 self.height=480 | |
285 | |
279 for node in doc.childList(): | 286 for node in doc.childList(): |
280 print node.name() | 287 print node.name() |
281 if node.name() == 'svg:metadata': | 288 if node.name() == 'svg:metadata': |
282 self.parseMetadata(node) | 289 self.parseMetadata(node) |
283 pass | 290 pass |
664 B=m[2] | 671 B=m[2] |
665 C=m[1] | 672 C=m[1] |
666 D=m[3] | 673 D=m[3] |
667 E=m[4] | 674 E=m[4] |
668 F=m[5] | 675 F=m[5] |
669 sx = math.sqrt(m[0]*m[0]+m[2]*m[2]) | 676 sx = math.sqrt(A*A+B*B) |
670 A = A/sx | 677 A = A/sx |
671 B = B/sx | 678 B = B/sx |
672 shear = m[0]*m[1]+m[2]*m[3] | 679 shear = m[0]*m[1]+m[2]*m[3] |
673 C = C - A*shear | 680 C = C - A*shear |
674 D = D - B*shear | 681 D = D - B*shear |
745 dm = self.parseTransform(d) | 752 dm = self.parseTransform(d) |
746 dd = self.decomposition(dm) | 753 dd = self.decomposition(dm) |
747 sx = ss[0]*(1-p)+dd[0]*p | 754 sx = ss[0]*(1-p)+dd[0]*p |
748 sy = ss[1]*(1-p)+dd[1]*p | 755 sy = ss[1]*(1-p)+dd[1]*p |
749 a = ss[2]*(1-p)+dd[2]*p | 756 a = ss[2]*(1-p)+dd[2]*p |
750 tx = sx*(1-p)+dx*p | 757 tx = ox*(1-p)+dx*p |
751 ty = sy*(1-p)+dy*p | 758 ty = oy*(1-p)+dy*p |
752 #m = self.mulA([math.cos(a),-math.sin(a),math.sin(a),math.cos(a),0,0],[sx,0,0,sy,0,0]) | 759 #m = self.mulA([math.cos(a),-math.sin(a),math.sin(a),math.cos(a),0,0],[sx,0,0,sy,0,0]) |
753 m = [sx,0,0,sy,0,0] | 760 #a=3.141592/2*p |
754 m = self.mulA(m,[1,0,0,1,-ox,-oy]) | 761 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0] |
755 m = [1,0,0,1,-ox,-oy] | 762 m = self.mulA([sx,0,0,sy,0,0],m) |
763 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) | |
765 | |
756 if dd[0] != ss[0]: | 766 if dd[0] != ss[0]: |
757 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[1],m[2],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])) |
758 else: | 768 else: |
759 try: | 769 try: |
760 sw = float(s.attribute("width")) | 770 sw = float(s.attribute("width")) |
761 sh = float(s.attribute("height")) | 771 sh = float(s.attribute("height")) |
762 dw = float(d.attribute("width")) | 772 dw = float(d.attribute("width")) |
955 self.setCurrentScene(self.last_frame+1) | 965 self.setCurrentScene(self.last_frame+1) |
956 self.selectSceneObject(self.last_line,self.last_frame+1) | 966 self.selectSceneObject(self.last_line,self.last_frame+1) |
957 pass | 967 pass |
958 | 968 |
959 def doInsertKeyScene(self,w): | 969 def doInsertKeyScene(self,w): |
970 self.lockui=True | |
960 self.insertKeyScene() | 971 self.insertKeyScene() |
972 self.lockui=False | |
961 # self.grid.show_all() | 973 # self.grid.show_all() |
962 return | 974 return |
963 def doDuplicateKeyScene(self,w): | 975 def doDuplicateKeyScene(self,w): |
976 self.lockui = True | |
964 self.duplicateKeyScene() | 977 self.duplicateKeyScene() |
978 self.lockui = False | |
965 | 979 |
966 def doRemoveScene(self,w): | 980 def doRemoveScene(self,w): |
981 self.lockui = True | |
967 self.removeKeyScene() | 982 self.removeKeyScene() |
983 self.lockui = False | |
968 return | 984 return |
969 | 985 |
970 | 986 |
971 def doExtendScene(self,w): | 987 def doExtendScene(self,w): |
988 self.lockui = True | |
972 self.extendScene() | 989 self.extendScene() |
990 self.lockui = False | |
973 #self.grid.show_all() | 991 #self.grid.show_all() |
974 pass | 992 pass |
975 def changeObjectLabel(self,w): | 993 def changeObjectLabel(self,w): |
976 o = self.desktop.selection.list()[0] | 994 o = self.desktop.selection.list()[0] |
977 o.setAttribute("inkscape:label", self.nameEditor.get_text()) | 995 o.setAttribute("inkscape:label", self.nameEditor.get_text()) |