changeset 1376:4c5bcaba28ea

Check in so that we can check the crash issues.
author wycc
date Fri, 11 Mar 2011 14:07:55 +0800
parents 37dc1ce76bba
children 8ecee58c85c6
files nodejs/mbapp.js nodejs/svg.js
diffstat 2 files changed, 66 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/nodejs/mbapp.js	Fri Mar 11 14:05:09 2011 +0800
+++ b/nodejs/mbapp.js	Fri Mar 11 14:07:55 2011 +0800
@@ -145,6 +145,30 @@
     }
 }
 
+app.prototype.generateScaleTween=function(src,dest,p) {
+    sys.puts("p="+ p);
+    if (p == 0) {
+	if (src.dup) src.dup.hide();
+	src.show();
+	return;
+    }
+    src.hide();
+    // Duplicate the group
+    if (src.dup == null) {
+        dup = src.parent.clone_from_subtree(src);
+	src.dup = dup;
+    } else {
+	dup = src.dup;
+    }
+    dup.hide();
+    sys.puts(dup);
+
+
+    for(n in dup) {
+	
+        
+    }
+}
 
 app.prototype.changeScene=function(s) {
     var nth;
@@ -156,10 +180,21 @@
 	if (nth == -1) return;
     }
     var scenes = this.svg.scenes;
-    for(i=0;i<scenes.length;i++) {
+    for(i=0;i<scenes.length-1;i++) {
         try {
             if (nth >=scenes[i].start && nth <=scenes[i].end) {
-	        this.get(scenes[i].ref).show();
+		if (scenes[i].type == 'normal' || i == scenes.length-1) {
+	            this.get(scenes[i].ref).show();
+		} else if (scenes[i].type == 'scale') {
+		    if (scenes[i].end == (scenes[i+1].start-1)) {
+			var p = (nth-scenes[i].start)/(scenes[i].end-scenes[i].start+1);
+			this.generateScaleTween(this.get(scenes[i].ref),this.get(scenes[i+1].ref),p);
+		    } else {
+		        // If there is no second key frame defined, fall back to the normal
+	                this.get(scenes[i].ref).show();
+		    }
+		}
+
 	    } else {
 	        this.get(scenes[i].ref).hide();
 	    }
--- a/nodejs/svg.js	Fri Mar 11 14:05:09 2011 +0800
+++ b/nodejs/svg.js	Fri Mar 11 14:07:55 2011 +0800
@@ -41,6 +41,8 @@
 }
 
 loadSVG.prototype.load=function(mb_rt, root, filename) {
+    sys.puts(filename);
+    sys.puts(libxml);
     var doc = libxml.parseXmlFile(filename);
     var _root = doc.root();
     var nodes = _root.childNodes();
@@ -51,6 +53,7 @@
     this.stop_ref={};
     this.gradients={};
     this.radials = {};
+    this._groupMap={};
     coord.center=new Object();
     coord.center.x = 10000;
     coord.center.y = 10000;
@@ -940,6 +943,12 @@
     }
 }
 
+loadSVG.prototype.duplicateGroup=function(id,root) {
+    n =  this._groupMap[id];
+    var m = [1,0,0,1,0,0]
+    this.parseGroup(m,root,id, n)
+}
+
 loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) {
     var k;
     var nodes = n.childNodes();
@@ -990,6 +999,7 @@
 	root.center.y = coord.center.y;
 
     this._set_bbox(n, coord);
+    this._groupMap[n.name()] = n;
     
     make_mbnames(this.mb_rt, n, coord);
 };
@@ -1218,7 +1228,11 @@
 	        scene.end = scene.start;
 	    }
 	    scene.ref = node.attr('ref').value();
-	    scene.type = node.attr('type').value();
+	    try {
+	        scene.type = node.attr('type').value();
+	    } catch(e) {
+	        scene.type='normal';
+	    }
 
 	    try {
 	        this.scenenames[node.attr('name').value()] = scene.start;
@@ -1229,6 +1243,18 @@
     }
 }
 
+loadSVG.prototype.parseComponents=function(coord,node) {
+    
+    var nodes = node.childNodes();
+
+    for(k in nodes) {
+        var name = nodes[k].name();
+	if (name == 'component') {
+	    // Parse the component here
+	}
+    }
+}
+
 loadSVG.prototype.parseMetadata=function(coord,node) {
     var nodes = node.childNodes();
 
@@ -1238,6 +1264,8 @@
 	    this.scenes=[];
 	    this.scenenames={};
 	    this.parseScenes(coord,nodes[k]);
+	} else if (name == "components") {
+	    this.parseComponents(coord,nodes[k]);
 	}
     }
 }