annotate pyink/tween.py @ 1151:71c72e8d6755

Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene(). - updateTweenContent() use frameline.get_frame_blocks(), instead of frameline._keys, to get information of tweens and key frames. - MBScene.setCurrentScene() use 'ns0:duplicate-src' attribute to map nodes from a start scene to a stop scene.
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 26 Dec 2010 23:40:09 +0800
parents 6586cd10c92f
children ad9c44a08645
rev   line source
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
1 # -*- indent-tabs-mode: t; tab-width: 8; python-indent: 4; -*-
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
2 # vim: sw=4:ts=8:sts=4
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
3 import traceback
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
4 import math
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
5
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
6 class TweenObject:
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
7 TWEEN_TYPE_NORMAL = 0
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
8 TWEEN_TYPE_RELOCATE = 1
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
9 TWEEN_TYPE_SCALE = 2
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
10
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
11 def __init__(self,doc,dom):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
12 self.document = doc
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
13 self.dom = dom
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
14 try:
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
15 self.width = float(dom.getAttribute("width"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
16 self.height = float(dom.getAttribute("height"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
17 except:
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
18 self.width = 640
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
19 self.height = 480
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
20
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
21 def updateMapping(self):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
22 self.nodeToItem={}
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
23 root = self.dom
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
24 self.updateMappingNode(root)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
25 def updateMappingNode(self,node):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
26 for c in node.childList():
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
27 self.updateMappingNode(c)
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
28 try:
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
29 self.nodeToItem[c.getAttribute("id")] = c
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
30 except:
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
31 pass
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
32 def updateTweenContent(self, duplicate_group, tween_type,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
33 start_scene_group, stop_scene_group, percent):
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
34 """
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
35 Update the content of the duplicate scene group. We will
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
36 use precent, start_scene_group, stop_scene_group to
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
37 compute transform matrix and update duplicate scene group
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
38 specified.
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
39 """
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
40 # Collect ref from the obj
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
41 node = duplicate_group.firstChild()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
42 dup_nodes = {}
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
43 while node:
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
44 try:
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
45 ref = node.getAttribute("ref")
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
46 dup_nodes[ref] = node
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
47 except:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
48 ref = None
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
49 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
50 node = node.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
51 pass
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
52
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
53 # Collect all nodes in stop scene
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
54 stop_nodes = {}
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
55 node = stop_scene_group.firstChild()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
56 while node:
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
57 try:
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
58 node_label = node.getAttribute("ns0:duplicate-src")
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
59 stop_nodes[node_label] = node
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
60 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
61 pass
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
62 node = node.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
63 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
64
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
65 #
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
66 # Node ID of a node of start scene must be mapped to
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
67 # 'ns0:duplicate-src' attribute of a node of stop scene. The
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
68 # nodes which can not be mapped to a node of stop scene are
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
69 # not manipulated by the tween.
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
70 #
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
71 # When a scene is duplicated, 'ns0:duplicate-src' attribute of
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
72 # nodes, in the new scene, must be setted to ID of respective
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
73 # one in the duplicated scene.
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
74 #
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
75 start_node = start_scene_group.firstChild()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
76 while start_node:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
77 start_node_id = start_node.getAttribute('id')
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
78 try:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
79 stop_node = stop_nodes[start_node_id]
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
80 except KeyError:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
81 start_node = start_node.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
82 continue
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
83
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
84 dup_node = dup_nodes.setdefault(start_node_id, None)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
85
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
86 self.updateTweenObject(duplicate_group, tween_type,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
87 start_node, stop_node,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
88 percent, dup_node)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
89 start_node = start_node.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
90 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
91 pass
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
92
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
93 def parseTransform(self,obj):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
94 """
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
95 Return the transform matrix of an object
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
96 """
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
97 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
98 t = obj.getAttribute("transform")
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
99 print t
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
100 if t[0:9] == 'translate':
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
101 print "translate"
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
102 fields = t[10:].split(',')
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
103 x = float(fields[0])
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
104 fields = fields[1].split(')')
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
105 y = float(fields[0])
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
106 return [1,0,0,1,x,y]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
107 elif t[0:6] == 'matrix':
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
108 print "matrix"
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
109 fields=t[7:].split(')')
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
110 fields = fields[0].split(',')
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
111 return [float(fields[0]),float(fields[1]),float(fields[2]),float(fields[3]),float(fields[4]),float(fields[5])]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
112 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
113 #traceback.print_exc()
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
114 return [1,0,0,1,0,0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
115
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
116 def invA(self,m):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
117 d = m[0]*m[3]-m[2]*m[1]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
118 return [m[3]/d, -m[1]/d, -m[2]/d, m[0]/d, (m[1]*m[5]-m[4]*m[3])/d, (m[4]*m[2]-m[0]*m[5])/d]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
119
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
120 def mulA(self,a,b):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
121 return [a[0]*b[0]+a[1]*b[2],
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
122 a[0]*b[1]+a[1]*b[3],
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
123 a[2]*b[0]+a[3]*b[2],
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
124 a[2]*b[1]+a[3]*b[3],
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
125 a[0]*b[4]+a[1]*b[5]+a[4],
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
126 a[2]*b[4]+a[3]*b[5]+a[5]]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
127
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
128 def decomposition(self,m):
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
129 """
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
130 Decompose the affine matrix into production of translation,rotation,shear and scale.
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
131 The algorithm is documented at http://lists.w3.org/Archives/Public/www-style/2010Jun/0602.html
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
132 """
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
133 if m[0]*m[3] == m[1]*m[2]:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
134 print "The affine matrix is singular"
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
135 return [1,0,0,1,0,0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
136 A=m[0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
137 B=m[2]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
138 C=m[1]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
139 D=m[3]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
140 E=m[4]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
141 F=m[5]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
142 sx = math.sqrt(A*A+B*B)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
143 A = A/sx
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
144 B = B/sx
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
145 shear = m[0]*m[1]+m[2]*m[3]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
146 C = C - A*shear
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
147 D = D - B*shear
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
148 sy = math.sqrt(C*C+D*D)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
149 C = C/sy
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
150 D = D/sy
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
151 r = A*D-B*C
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
152 if r == -1:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
153 shear = -shear
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
154 sy = -sy
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
155 R = math.atan2(B,A)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
156 return [sx,sy, R, E,F]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
157
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
158
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
159 def updateTweenObject(self,obj,typ,s,d,p,newobj):
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
160 """
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
161 Generate tweened object in the @obj by using s and d in the @p percent
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
162 http://lists.w3.org/Archives/Public/www-style/2010Jun/0602.html
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
163 """
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
164 if typ == self.TWEEN_TYPE_RELOCATE:
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
165 if s.name() == 'svg:g':
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
166 if not newobj:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
167 newobj = s.duplicate(self.document)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
168 top = self.document.createElement("svg:g")
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
169 top.setAttribute("ref", s.getAttribute("id"))
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
170 top.appendChild(newobj)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
171 obj.appendChild(top)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
172 else:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
173 top = newobj
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
174 pass
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
175 # Parse the translate or matrix
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
176 sm = self.parseTransform(s)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
177 dm = self.parseTransform(d)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
178 top.setAttribute("transform","translate(%g,%g)" % ((dm[2]-sm[2])*p,(dm[5]-sm[5])*p))
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
179 else:
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
180 if not newobj:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
181 top = s.duplicate(self.document)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
182 top.setAttribute('ref', s.getAttribute('id'))
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
183 obj.appendChild(top)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
184 else:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
185 top = newobj
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1146
diff changeset
186 pass
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
187 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
188 sx = float(s.getAttribute("x"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
189 sy = float(s.getAttribute("y"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
190 dx = float(d.getAttribute("x"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
191 dy = float(d.getAttribute("y"))
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
192 tx = (dx-sx)*p
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
193 ty = (dy-sy)*p
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
194 print tx,ty
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
195 top.setAttribute("transform","translate(%g,%g)" % (tx,ty))
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
196 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
197 traceback.print_exc()
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
198 pass
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
199 pass
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
200 elif typ == self.TWEEN_TYPE_SCALE:
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
201 self.updateTweenObjectScale(obj,s,d,p,newobj)
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
202 pass
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
203 elif typ == self.TWEEN_TYPE_NORMAL:
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
204 newobj = s.duplicate(self.document)
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
205 newobj.setAttribute("ref", s.getAttribute("id"))
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
206 top = self.document.createElement("svg:g")
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
207 top.appendChild(newobj)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
208 obj.appendChild(top)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
209 pass
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
210
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
211 def updateTweenObjectScale(self,obj,s,d,p,newobj):
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
212 """
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
213 Generate a new group which contains the original group and then
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
214 add the transform matrix to generate a tween frame between the
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
215 origin and destination scene group.
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
216
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
217 We will parse the transform matrix of the @s and @d and then
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
218 generate the matrix which is (1-p) of @s and p percent of @d.
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
219 """
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
220 if newobj == None:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
221 newobj = s.duplicate(self.document)
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
222 top = self.document.createElement("svg:g")
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
223 top.setAttribute("ref",s.getAttribute("id"))
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
224 top.appendChild(newobj)
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
225 obj.appendChild(top)
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
226 else:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
227 top = newobj
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
228 newobj = top.firstChild()
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
229
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
230 if s.name() == 'svg:g':
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
231 # Parse the translate or matrix
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
232 #
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
233 # D = B inv(A)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
234 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
235 item = self.nodeToItem[s.getAttribute("id")]
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
236 (ox,oy) = item.getCenter()
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
237 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
238 ox = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
239 oy = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
240 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
241 item = self.nodeToItem[d.getAttribute("id")]
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
242 (dx,dy) = item.getCenter()
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
243 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
244 dx = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
245 dy = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
246
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
247 sm = self.parseTransform(s)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
248 ss = self.decomposition(sm)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
249 dm = self.parseTransform(d)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
250 dd = self.decomposition(dm)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
251 sx = (ss[0]*(1-p)+dd[0]*p)/ss[0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
252 sy = (ss[1]*(1-p)+dd[1]*p)/ss[0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
253 a = ss[2]*(1-p)+dd[2]*p-ss[2]
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
254 tx = ox*(1-p)+dx*p
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
255 ty = oy*(1-p)+dy*p
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
256 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
257 m = self.mulA([sx,0,0,sy,0,0],m)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
258 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height])
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
259 m = self.mulA([1,0,0,1,tx,self.height-ty],m)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
260
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
261 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5]))
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
262 else:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
263 try:
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
264 try:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
265 sw = float(s.getAttribute("width"))
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
266 except:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
267 sw = 1
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
268 try:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
269 sh = float(s.getAttribute("height"))
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
270 except:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
271 sh = 1
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
272 try:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
273 dw = float(d.getAttribute("width"))
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
274 except:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
275 dw = 1
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
276 try:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
277 dh = float(d.getAttribute("height"))
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
278 except:
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
279 dh = 1
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
280 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
281 item = self.nodeToItem[s.getAttribute("id")]
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
282 (ox,oy) = item.getCenter()
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
283 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
284 ox = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
285 oy = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
286 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140
diff changeset
287 item = self.nodeToItem[d.getAttribute("id")]
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
288 (dx,dy) = item.getCenter()
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
289 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
290 dx = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
291 dy = 0
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
292 try:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
293 sm = self.parseTransform(s)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
294 ss = self.decomposition(sm)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
295 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
296 ss = [1,1,0,0,0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
297 pass
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
298 try:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
299 dm = self.parseTransform(d)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
300 dd = self.decomposition(dm)
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
301 print "dd=",dd
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
302 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
303 dd = [1,1,0,0,0]
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
304 dd[0] = dd[0]*dw/sw
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
305 dd[1] = dd[1]*dh/sh
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
306 print "ss[0]=",ss[0],"dd[0]=",dd[0]
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
307 sx = (ss[0]*(1-p)+dd[0]*p)/ss[0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
308 sy = (ss[1]*(1-p)+dd[1]*p)/ss[1]
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
309 print "sx=",sx,"sy=",sy
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
310 a = ss[2]*(1-p)+dd[2]*p-ss[2]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
311 tx = ox*(1-p)+dx*p
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
312 ty = oy*(1-p)+dy*p
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
313 m = [math.cos(a),math.sin(a),-math.sin(a),math.cos(a),0,0]
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
314 m = self.mulA([sx,0,0,sy,0,0],m)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
315 m = self.mulA(m,[1,0,0,1,-ox,oy-self.height])
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
316 m = self.mulA([1,0,0,1,tx,self.height-ty],m)
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
317
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
318 top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5]))
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
319 except:
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents:
diff changeset
320 traceback.print_exc()