Mercurial > MadButterfly
diff nodejs/mbapp.js @ 1399:9cebe429508c
Override the clone_from_subtree to setup the parent and children for the coord object. However, the current children is incorrect since we can not copy it from the origin tree. Instead, we need to get coord_t from the cloned group and then modify all coord objects to include correct parent, children, add_shape and clone_from_subtree.
author | wycc |
---|---|
date | Sun, 03 Apr 2011 11:51:39 +0800 |
parents | a19f6cecf3c8 |
children | 2fc1f54a1a3b |
line wrap: on
line diff
--- a/nodejs/mbapp.js Sun Apr 03 11:48:39 2011 +0800 +++ b/nodejs/mbapp.js Sun Apr 03 11:51:39 2011 +0800 @@ -48,6 +48,7 @@ coord._mbapp_saved_rev_mtx = _reverse(coord._mbapp_saved_mtx); coord.parent = parent; coord._mbapp_saved_add_shape = coord.add_shape; + coord._mbapp_saved_clone_from_subtree = coord.clone_from_subtree; coord.add_shape = function(shape) { var coord; @@ -55,6 +56,14 @@ shape.parent = this; this.children.push(shape); } + coord.clone_from_subtree = function(coord) { + var newcoord = this._mbapp_saved_clone_from_subtree(coord); + newcoord.parent = this; + // FIXME: This is incorrect. However, we have no way to fix it for now. + // We need to implement a function which can get coord for a coord_t. + newcoord.children=coord.children; + return newcoord; + } parent.children.push(coord); @@ -71,12 +80,23 @@ coord[3], coord[4], coord[5]]; coord._mbapp_saved_rev_mtx = _reverse(coord._mbapp_saved_mtx); coord._mbapp_saved_add_shape = coord.add_shape; + coord._mbapp_saved_clone_from_subtree = coord.clone_from_subtree; coord.add_shape = function(shape) { var coord; this._mbapp_saved_add_shape(shape); shape.parent = this; } + coord.clone_from_subtree = function(coord) { + var newcoord; + + newcoord = this._mbapp_saved_clone_from_subtree(coord); + newcoord.parent = this; + // FIXME: This is incorrect. However, we have no way to fix it for now. + // We need to implement a function which can get coord for a coord_t. + newcoord.children=coord.children; + return newcoord; + } } app=function(display, w, h) { @@ -152,13 +172,15 @@ sys.puts("p="+ p); src.hide(); // Duplicate the group - var nodes = src.node.childNodes(); + var nodes = src.children; + sys.puts(src.node); + sys.puts(src.children); if (src.dup == null) { var dup = this.mb_rt.coord_new(src.parent); for (i in nodes) { var child_dup = this.mb_rt.coord_new(dup); - var n = nodes[i]; - var c = n.coord; + var c = nodes[i]; + var n = c.node; var k = child_dup.clone_from_subtree(c); n.coord.dup = child_dup; sys.puts(n); @@ -180,8 +202,8 @@ //sys.puts(dup); for(i in nodes) { - n= nodes[i]; - coord = n.coord; + coord= nodes[i]; + n = coord.node; var attr = n.attr('id'); if (attr == null) continue; var id = attr.value(); @@ -201,7 +223,7 @@ } app.prototype.generateScaleTweenObject=function(coord,src,dest,p,id) { - sys.puts(src.node); + sys.puts(dest.node); sys.puts("src=["+src.sx+","+src.sy+","+src.r+","+src.tx+","+src.ty); sys.puts("id="+dest.node.attr('id')+" dest=["+dest.sx+","+dest.sy+","+dest.r+","+dest.tx+","+dest.ty); sys.puts("src.center="+src.center); @@ -210,6 +232,8 @@ var p1 = 1-p; var x1 = src.center.x; var y1 = src.center.y; + var y1 = 0; + x1 = 0; // For the svg:use, the transform matrix is the transform of teh svg:use and the elements inside it var d,sx,sy,r,tx,ty; @@ -273,6 +297,9 @@ try { this.get(scenes[i].ref).hide(); if (nth >=scenes[i].start && nth <=scenes[i].end) { + this.get(scenes[i].ref).show(); + if (this.get(scenes[i].ref).dup) + this.get(scenes[i].ref).dup.show(); sys.puts("find"); if (scenes[i].type == 'normal' || i == scenes.length-1) { this.get(scenes[i].ref).show();