Mercurial > MadButterfly
comparison pyink/tween.py @ 1359:5313bbfafa67
Fix issue of chain of reference for opacity and matrix
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 16 Feb 2011 15:07:44 +0800 |
parents | cd0c0c7547b4 |
children | f89d3ee130de |
comparison
equal
deleted
inserted
replaced
1358:cd0c0c7547b4 | 1359:5313bbfafa67 |
---|---|
187 _interp_value = interp(start_value, stop_value, percent) | 187 _interp_value = interp(start_value, stop_value, percent) |
188 return _interp_value | 188 return _interp_value |
189 | 189 |
190 | 190 |
191 def _apply_animation_attrs(ani_attrs, node): | 191 def _apply_animation_attrs(ani_attrs, node): |
192 for attr in ('x', 'y', 'width', 'height', 'opacity', 'display'): | 192 for attr in ('x', 'y', 'width', 'height'): |
193 if attr in ani_attrs: | 193 if attr in ani_attrs: |
194 node.setAttribute(attr, str(ani_attrs[attr])) | 194 node.setAttribute(attr, str(ani_attrs[attr])) |
195 pass | 195 pass |
196 pass | 196 pass |
197 | 197 |
305 del attrs['y'] | 305 del attrs['y'] |
306 pass | 306 pass |
307 pass | 307 pass |
308 pass | 308 pass |
309 | 309 |
310 if 'opacity' in names: | 310 defaults = {'x': 0, 'y': 0, |
311 if 'opacity' not in attrs1: | 311 'width': 0, 'height': 0, |
312 attrs1['opacity'] = 1.0 | 312 'opacity': 1.0, 'display': 'inline'} |
313 pass | 313 |
314 if 'opacity' not in attrs2: | 314 for attrname in defaults: |
315 attrs2['opacity'] = 1.0 | 315 if attrname in names: |
316 pass | 316 if attrname not in attrs1: |
317 | 317 attrs1[attrname] = defaults[attrname] |
318 if node2.name() == 'svg:use': | 318 pass |
319 attrs2['opacity'] = attrs2['opacity'] * attrs1['opacity'] | 319 if attrname not in attrs2: |
320 pass | 320 attrs2[attrname] = defaults[attrname] |
321 pass | 321 pass |
322 | 322 pass |
323 if 'display' in names: | 323 pass |
324 if 'display' not in attrs1: | 324 |
325 attrs1['display'] = '' | 325 if node2.name() == 'svg:use': |
326 pass | 326 accumulators = {'opacity': |
327 if 'display' not in attrs2: | 327 (lambda attr_v1, attr_v2: attr_v1 * attr_v2), |
328 attrs2['display'] = '' | 328 'transform': |
329 pass | 329 (lambda m1, m2: (_mulA(m2[0], m1[0]), m2[1])) |
330 pass | 330 } |
331 | 331 for attrname in accumulators: |
332 for name in 'x y width height'.split(): | 332 if attrname not in names: |
333 if name in names: | 333 continue |
334 if name not in attrs1: | 334 accumulator = accumulators[attrname] |
335 attrs1[name] = 0 | 335 acc = accumulator(attrs1[attrname], attrs2[attrname]) |
336 pass | 336 attrs2[attrname] = acc |
337 if name not in attrs2: | |
338 attrs2[name] = 0 | |
339 pass | |
340 pass | 337 pass |
341 pass | 338 pass |
342 pass | 339 pass |
340 | |
343 | 341 |
344 class TweenObject(object): | 342 class TweenObject(object): |
345 TWEEN_TYPE_NORMAL = 0 | 343 TWEEN_TYPE_NORMAL = 0 |
346 #TWEEN_TYPE_RELOCATE = 1 | 344 #TWEEN_TYPE_RELOCATE = 1 |
347 TWEEN_TYPE_SCALE = 1 | 345 TWEEN_TYPE_SCALE = 1 |