Mercurial > MadButterfly
comparison pyink/tween.py @ 1150:6586cd10c92f
Refactory frameline.py
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 26 Dec 2010 19:17:12 +0800 |
parents | e14ec6d1a661 |
children | 71c72e8d6755 |
comparison
equal
deleted
inserted
replaced
1149:0ffef2df6201 | 1150:6586cd10c92f |
---|---|
24 self.nodeToItem[c.getAttribute("id")] = c | 24 self.nodeToItem[c.getAttribute("id")] = c |
25 except: | 25 except: |
26 pass | 26 pass |
27 def updateTweenContent(self,obj, typ, source,dest,cur): | 27 def updateTweenContent(self,obj, typ, source,dest,cur): |
28 """ | 28 """ |
29 Update the content of the duplicate scene group. We will use the (start,end) and cur to calculate the percentage of | 29 Update the content of the duplicate scene group. We will |
30 the tween motion effect and then use it to update the transform matrix of the duplicated scene group. | 30 use the (start,end) and cur to calculate the percentage of |
31 the tween motion effect and then use it to update the | |
32 transform matrix of the duplicated scene group. | |
31 """ | 33 """ |
32 | 34 |
33 start = source.idx | 35 start = source.idx |
34 end = dest.idx | 36 end = dest.idx |
35 print cur,start,end | 37 print cur,start,end |
74 o = None | 76 o = None |
75 try: | 77 try: |
76 label = s.getAttribute("inkscape:label") | 78 label = s.getAttribute("inkscape:label") |
77 # Use i8nkscape:label to identidy the equipvalent objects | 79 # Use i8nkscape:label to identidy the equipvalent objects |
78 if label: | 80 if label: |
79 if dests.hasattr(label.value()): | 81 if dests.has_key(label): |
80 self.updateTweenObject(obj,typ,s,dests[label.value()],percent,o) | 82 self.updateTweenObject(obj, typ, s, |
83 dests[label], percent, o) | |
81 s = s.next() | 84 s = s.next() |
82 continue | 85 continue |
83 except: | 86 except: |
84 pass | 87 pass |
85 # Search obejcts in the destination | 88 # Search obejcts in the destination |
166 def updateTweenObject(self,obj,typ,s,d,p,newobj): | 169 def updateTweenObject(self,obj,typ,s,d,p,newobj): |
167 """ | 170 """ |
168 Generate tweened object in the @obj by using s and d in the @p percent | 171 Generate tweened object in the @obj by using s and d in the @p percent |
169 http://lists.w3.org/Archives/Public/www-style/2010Jun/0602.html | 172 http://lists.w3.org/Archives/Public/www-style/2010Jun/0602.html |
170 """ | 173 """ |
171 if typ == 'relocate': | 174 if typ == 1: |
172 newobj = s.duplicate(self.document) | |
173 top = self.document.createElement("svg:g") | |
174 top.setAttribute("ref", s.getAttribute("id")) | |
175 top.appendChild(newobj) | |
176 obj.appendChild(top) | |
177 if s.name() == 'svg:g': | 175 if s.name() == 'svg:g': |
176 if not newobj: | |
177 newobj = s.duplicate(self.document) | |
178 top = self.document.createElement("svg:g") | |
179 top.setAttribute("ref", s.getAttribute("id")) | |
180 top.appendChild(newobj) | |
181 obj.appendChild(top) | |
182 else: | |
183 top = newobj | |
184 pass | |
178 # Parse the translate or matrix | 185 # Parse the translate or matrix |
179 sm = self.parseTransform(s) | 186 sm = self.parseTransform(s) |
180 dm = self.parseTransform(d) | 187 dm = self.parseTransform(d) |
181 top.setAttribute("transform","translate(%g,%g)" % ((dm[2]-sm[2])*p,(dm[5]-sm[5])*p)) | 188 top.setAttribute("transform","translate(%g,%g)" % ((dm[2]-sm[2])*p,(dm[5]-sm[5])*p)) |
182 else: | 189 else: |
190 if not newobj: | |
191 top = s.duplicate(self.document) | |
192 top.setAttribute('ref', s.getAttribute('id')) | |
193 obj.appendChild(top) | |
194 else: | |
195 top = newobj | |
196 pass | |
183 try: | 197 try: |
184 sx = float(s.getAttribute("x")) | 198 sx = float(s.getAttribute("x")) |
185 sy = float(s.getAttribute("y")) | 199 sy = float(s.getAttribute("y")) |
186 dx = float(d.getAttribute("x")) | 200 dx = float(d.getAttribute("x")) |
187 dy = float(d.getAttribute("y")) | 201 dy = float(d.getAttribute("y")) |
191 top.setAttribute("transform","translate(%g,%g)" % (tx,ty)) | 205 top.setAttribute("transform","translate(%g,%g)" % (tx,ty)) |
192 except: | 206 except: |
193 traceback.print_exc() | 207 traceback.print_exc() |
194 pass | 208 pass |
195 pass | 209 pass |
196 elif typ == 'scale': | 210 elif typ == 2: |
197 self.updateTweenObjectScale(obj,s,d,p,newobj) | 211 self.updateTweenObjectScale(obj,s,d,p,newobj) |
198 pass | 212 pass |
199 elif typ == 'normal': | 213 elif typ == 0: |
200 newobj = s.duplicate(self.document) | 214 newobj = s.duplicate(self.document) |
201 newobj.setAttribute("ref", s.getAttribute("id")) | 215 newobj.setAttribute("ref", s.getAttribute("id")) |
202 top = self.document.createElement("svg:g") | 216 top = self.document.createElement("svg:g") |
203 top.appendChild(newobj) | 217 top.appendChild(newobj) |
204 obj.appendChild(top) | 218 obj.appendChild(top) |