# HG changeset patch # User Thinker K.F. Li # Date 1297840064 -28800 # Node ID 5313bbfafa67e7fb1dc076823178a34b8d10989b # Parent cd0c0c7547b4cd37257ea8c933f236e5ef803e15 Fix issue of chain of reference for opacity and matrix diff -r cd0c0c7547b4 -r 5313bbfafa67 pyink/dom_event.py --- a/pyink/dom_event.py Wed Feb 16 15:07:44 2011 +0800 +++ b/pyink/dom_event.py Wed Feb 16 15:07:44 2011 +0800 @@ -13,7 +13,7 @@ def notifyChildRemoved(self, node, child, prev): if self.type == 'DOMNodeRemoved': self.func(node, child) - def notifyChildOrderChanged(self,node,child,prev): + def notifyChildOrderChanged(self, node, child, old_prev, new_prev): pass def notifyContentChanged(self,node,old_content,new_content): if self.type == 'DOMSubtreeModified': diff -r cd0c0c7547b4 -r 5313bbfafa67 pyink/tween.py --- a/pyink/tween.py Wed Feb 16 15:07:44 2011 +0800 +++ b/pyink/tween.py Wed Feb 16 15:07:44 2011 +0800 @@ -189,7 +189,7 @@ def _apply_animation_attrs(ani_attrs, node): - for attr in ('x', 'y', 'width', 'height', 'opacity', 'display'): + for attr in ('x', 'y', 'width', 'height'): if attr in ani_attrs: node.setAttribute(attr, str(ani_attrs[attr])) pass @@ -307,40 +307,38 @@ pass pass - if 'opacity' in names: - if 'opacity' not in attrs1: - attrs1['opacity'] = 1.0 - pass - if 'opacity' not in attrs2: - attrs2['opacity'] = 1.0 - pass - - if node2.name() == 'svg:use': - attrs2['opacity'] = attrs2['opacity'] * attrs1['opacity'] + defaults = {'x': 0, 'y': 0, + 'width': 0, 'height': 0, + 'opacity': 1.0, 'display': 'inline'} + + for attrname in defaults: + if attrname in names: + if attrname not in attrs1: + attrs1[attrname] = defaults[attrname] + pass + if attrname not in attrs2: + attrs2[attrname] = defaults[attrname] + pass pass pass - if 'display' in names: - if 'display' not in attrs1: - attrs1['display'] = '' - pass - if 'display' not in attrs2: - attrs2['display'] = '' - pass - pass - - for name in 'x y width height'.split(): - if name in names: - if name not in attrs1: - attrs1[name] = 0 - pass - if name not in attrs2: - attrs2[name] = 0 - pass + if node2.name() == 'svg:use': + accumulators = {'opacity': + (lambda attr_v1, attr_v2: attr_v1 * attr_v2), + 'transform': + (lambda m1, m2: (_mulA(m2[0], m1[0]), m2[1])) + } + for attrname in accumulators: + if attrname not in names: + continue + accumulator = accumulators[attrname] + acc = accumulator(attrs1[attrname], attrs2[attrname]) + attrs2[attrname] = acc pass pass pass + class TweenObject(object): TWEEN_TYPE_NORMAL = 0 #TWEEN_TYPE_RELOCATE = 1