Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1136:950076863b7e
Fix the tween calculation for the inbetween frames. Now, we can use primitive instead og group to defin ethe animation. Currently, it has been tested against rectangle only. We need to check others as well.
author | wycc |
---|---|
date | Tue, 21 Dec 2010 14:35:42 +0800 |
parents | bc619172bd2c |
children | a2b068594412 d4dbcb93aee0 |
comparison
equal
deleted
inserted
replaced
1135:45fcbd54e873 | 1136:950076863b7e |
---|---|
559 else: | 559 else: |
560 if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1): | 560 if nth > (s.idx+1) and nth <= (layer._keys[i+1].idx+1): |
561 if i+2 < len(layer._keys): | 561 if i+2 < len(layer._keys): |
562 layer.duplicateGroup = self.document.createElement("svg:g") | 562 layer.duplicateGroup = self.document.createElement("svg:g") |
563 layer.duplicateGroup.setAttribute("inkscape:label","dup") | 563 layer.duplicateGroup.setAttribute("inkscape:label","dup") |
564 layer.duplicateGroup.setAttribute("sodipodi:insensitive","1") | |
564 s.ref.setAttribute("style","display:none") | 565 s.ref.setAttribute("style","display:none") |
565 s.ref.parent().appendChild(layer.duplicateGroup) | 566 s.ref.parent().appendChild(layer.duplicateGroup) |
566 self.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth) | 567 self.updateTweenContent(layer.duplicateGroup, layer.get_tween_type(s.idx),s, layer._keys[i+2], nth) |
567 else: | 568 else: |
568 s.ref.setAttribute("style","display:none") | 569 s.ref.setAttribute("style","display:none") |
753 | 754 |
754 sm = self.parseTransform(s) | 755 sm = self.parseTransform(s) |
755 ss = self.decomposition(sm) | 756 ss = self.decomposition(sm) |
756 dm = self.parseTransform(d) | 757 dm = self.parseTransform(d) |
757 dd = self.decomposition(dm) | 758 dd = self.decomposition(dm) |
758 sx = ss[0]*(1-p)+dd[0]*p | 759 sx = (ss[0]*(1-p)+dd[0]*p)/ss[0] |
759 sy = ss[1]*(1-p)+dd[1]*p | 760 sy = (ss[1]*(1-p)+dd[1]*p)/ss[0] |
760 a = ss[2]*(1-p)+dd[2]*p | 761 a = ss[2]*(1-p)+dd[2]*p-ss[2] |
761 tx = ox*(1-p)+dx*p | 762 tx = ox*(1-p)+dx*p-ox |
762 ty = oy*(1-p)+dy*p | 763 ty = oy*(1-p)+dy*p-oy |
763 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0] | 764 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0] |
764 m = self.mulA([sx,0,0,sy,0,0],m) | 765 m = self.mulA([sx,0,0,sy,0,0],m) |
765 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height]) | 766 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height]) |
766 m = self.mulA([1,0,0,1,tx,self.height-ty],m) | 767 m = self.mulA([1,0,0,1,tx,self.height-ty],m) |
767 | 768 |
770 try: | 771 try: |
771 sw = float(s.attribute("width")) | 772 sw = float(s.attribute("width")) |
772 sh = float(s.attribute("height")) | 773 sh = float(s.attribute("height")) |
773 dw = float(d.attribute("width")) | 774 dw = float(d.attribute("width")) |
774 dh = float(d.attribute("height")) | 775 dh = float(d.attribute("height")) |
775 tx = (dw-sw)*p+sw | 776 try: |
776 ty = (dh-sh)*p+sh | 777 item = self.nodeToItem[s.attribute("id")] |
777 print tx,ty | 778 (ox,oy) = item.getCenter() |
778 top.setAttribute("transform","matrix(%g,0,0,%g,0,0)" % (tx,ty)) | 779 except: |
780 ox = 0 | |
781 oy = 0 | |
782 try: | |
783 item = self.nodeToItem[d.attribute("id")] | |
784 (dx,dy) = item.getCenter() | |
785 except: | |
786 dx = 0 | |
787 dy = 0 | |
788 try: | |
789 sm = self.parseTransform(s) | |
790 ss = self.decomposition(sm) | |
791 except: | |
792 ss = [1,1,0,0,0] | |
793 pass | |
794 try: | |
795 dm = self.parseTransform(d) | |
796 dd = self.decomposition(dm) | |
797 except: | |
798 dd = [1,1,0,0,0] | |
799 pass | |
800 dd[0] = ss[0]*dw/sw | |
801 dd[1] = ss[1]*dh/sh | |
802 sx = (ss[0]*(1-p)+dd[0]*p)/ss[0] | |
803 sy = (ss[1]*(1-p)+dd[1]*p)/ss[1] | |
804 a = ss[2]*(1-p)+dd[2]*p-ss[2] | |
805 tx = ox*(1-p)+dx*p | |
806 ty = oy*(1-p)+dy*p | |
807 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0] | |
808 m = self.mulA([sx,0,0,sy,0,0],m) | |
809 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height]) | |
810 m = self.mulA([1,0,0,1,tx,self.height-ty],m) | |
811 | |
812 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5])) | |
779 except: | 813 except: |
780 traceback.print_exc() | 814 traceback.print_exc() |
781 pass | 815 pass |
782 pass | 816 pass |
783 | 817 |