Mercurial > MadButterfly
changeset 1284:cbcb91b196fa
Use svg:use to duplicate the key frame. The current inkscape will not keep the extra attributes when we break the reference. Therefore, we may modify the inkscape directly or implemnet a break by ourself. In addition, we may need to improve the duplication to sync the new-added objects to an existed group.
author | wycc |
---|---|
date | Sat, 15 Jan 2011 02:43:20 +0800 |
parents | a6aba785656e |
children | e2d2532c3115 f6a28f473494 |
files | pyink/domview.py pyink/domview_ui.py pyink/tween.py |
diffstat | 3 files changed, 38 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/domview.py Fri Jan 14 00:39:21 2011 +0800 +++ b/pyink/domview.py Sat Jan 15 02:43:20 2011 +0800 @@ -732,15 +732,12 @@ def copy_group_children(self, src_group, dst_group): # Search for the duplicated group doc = self._doc - - dup_group = src_group.duplicate(doc) - old_nodes = _DOM_iterator(src_group) - new_nodes = _DOM_iterator(dup_group) new_gids = set() for old_node in old_nodes: old_node_id = old_node.getAttribute('id') - new_node = new_nodes.next() + new_node = doc.createElement("svg:use") + new_node.setAttribute("xlink:href",'#'+old_node_id) new_node.setAttribute('ns0:duplicate-src', old_node_id) # @@ -756,11 +753,7 @@ pass new_gids.add(gid) new_node.setAttribute('id', gid) - pass - - for child in dup_group.childList(): - dup_group.removeChild(child) # prvent from crash - dst_group.appendChild(child) + dst_group.appendChild(new_node) pass pass pass
--- a/pyink/domview_ui.py Fri Jan 14 00:39:21 2011 +0800 +++ b/pyink/domview_ui.py Sat Jan 15 02:43:20 2011 +0800 @@ -326,7 +326,6 @@ pass pass - # # Remove left key of the tween that right key frame is in removing # range. #
--- a/pyink/tween.py Fri Jan 14 00:39:21 2011 +0800 +++ b/pyink/tween.py Sat Jan 15 02:43:20 2011 +0800 @@ -245,8 +245,8 @@ top = newobj newobj = newobj.firstChild() pass - - if s.name() == 'svg:g': + print s.name() + if s.name() == 'svg:g' or s.name() == 'svg:use': # Parse the translate or matrix # # D = B inv(A) @@ -278,7 +278,7 @@ dm = self.parseTransform(d) dd = self.decomposition(dm) sx = (ss[0]*(1-p)+dd[0]*p)/ss[0] - sy = (ss[1]*(1-p)+dd[1]*p)/ss[0] + sy = (ss[1]*(1-p)+dd[1]*p)/ss[1] a = ss[2]*(1-p)+dd[2]*p-ss[2] tx = ox*(1-p)+dx*p ty = oy*(1-p)+dy*p @@ -290,31 +290,50 @@ top.setAttribute("transform","matrix(%g,%g,%g,%g,%g,%g)" % (m[0],m[2],m[1],m[3],m[4],m[5])) else: try: - try: - sw = float(s.getAttribute("width")) - except: + if d.name() == "svg:use": sw = 1 - try: - sh = float(s.getAttribute("height")) - except: sh = 1 - try: - dw = float(d.getAttribute("width")) - except: dw = 1 - try: - dh = float(d.getAttribute("height")) - except: dh = 1 + else: + try: + sw = float(s.getAttribute("width")) + except: + sw = 1 + try: + sh = float(s.getAttribute("height")) + except: + sh = 1 + + try: + dw = float(d.getAttribute("width")) + except: + dw = 1 + try: + dh = float(d.getAttribute("height")) + except: + dh = 1 + pass + try: start_opacity = parse_opacity(s) except: start_opacity = 1 + pass try: end_opacity =parse_opacity( d) + if d.name() == "svg:use": + end_opacity = end_opacity * start_opacity + pass + pass except: - end_opacity = 1 + if d.name() == "svg:use": + end_opacity = start_opacity + else: + end_opacity = 1 + pass + cur_opacity = start_opacity*(1-p)+end_opacity*p change_opacity(newobj,cur_opacity)