comparison nodejs/svg.js @ 978:78312b44f48c

Implement Scene API.
author wycc
date Sat, 20 Nov 2010 20:04:31 +0800
parents a9abcdac0ae5
children 593a418ed8bf
comparison
equal deleted inserted replaced
977:5cefabccfb76 978:78312b44f48c
70 70
71 for(k in nodes) { 71 for(k in nodes) {
72 var n = nodes[k].name(); 72 var n = nodes[k].name();
73 if (n == "defs") { 73 if (n == "defs") {
74 this.parseDefs(coord,nodes[k]); 74 this.parseDefs(coord,nodes[k]);
75 } else if (n == "metadata") {
76 this.parseMetadata(coord,nodes[k]);
75 } else if (n == "g") { 77 } else if (n == "g") {
76 this.parseGroup(accu,coord,'root_coord',nodes[k]); 78 this.parseGroup(accu,coord,'root_coord',nodes[k]);
77 } 79 }
78 } 80 }
79 } 81 }
82
83
80 84
81 loadSVG.prototype.leaveSVG=function() 85 loadSVG.prototype.leaveSVG=function()
82 { 86 {
83 var p = this.pgstack.pop(); 87 var p = this.pgstack.pop();
84 p.hide(); 88 p.hide();
101 } 105 }
102 mbname = n.attr("label"); 106 mbname = n.attr("label");
103 if(mbname&&(mbname.value()!="")) { 107 if(mbname&&(mbname.value()!="")) {
104 name = mbname.value(); 108 name = mbname.value();
105 mb_rt.mbnames[name] = obj; 109 mb_rt.mbnames[name] = obj;
110 }
111 try {
112 var gname = n.attr('id').value();
113 sys.puts(gname);
114 mb_rt.mbnames[gname] = obj;
115 } catch(e) {
106 } 116 }
107 } 117 }
108 118
109 function getInteger(n,name) 119 function getInteger(n,name)
110 { 120 {
1115 var href = n.attr('href'); 1125 var href = n.attr('href');
1116 if(href != null) { 1126 if(href != null) {
1117 href = href.value(); 1127 href = href.value();
1118 var hrefid = href.substring(1); 1128 var hrefid = href.substring(1);
1119 pstops = this.stop_ref[hrefid]; 1129 pstops = this.stop_ref[hrefid];
1120 stops = pstops.concat(stops); 1130 if (pstops)
1131 stops = pstops.concat(stops);
1121 1132
1122 var hrefgr = this.gradients[hrefid]; 1133 var hrefgr = this.gradients[hrefid];
1123 if(typeof x1 == "undefined") 1134 if(typeof x1 == "undefined")
1124 x1 = hrefgr[0]; 1135 x1 = hrefgr[0];
1125 if(typeof y1 == "undefined") 1136 if(typeof y1 == "undefined")
1189 1200
1190 this.radials[id] = [cx, cy, r]; 1201 this.radials[id] = [cx, cy, r];
1191 this.stop_ref[id] = stops; 1202 this.stop_ref[id] = stops;
1192 } 1203 }
1193 1204
1205 loadSVG.prototype.parseScenes=function(coord,node) {
1206 var nodes = node.childNodes();
1207
1208 for(k in nodes) {
1209 var name = nodes[k].name();
1210 if (name == 'scene') {
1211 var node = nodes[k];
1212
1213 scene = new Object();
1214 scene.start = parseInt(node.attr('start').value());
1215 try {
1216 scene.end = parseInt(node.attr('end').value());
1217 } catch(e) {
1218 scene.end = scene.start;
1219 }
1220 scene.ref = node.attr('ref').value();
1221
1222 try {
1223 this.scenenames[node.attr('name').value()] = scene.start;
1224 } catch(e) {
1225 }
1226 this.scenes.push(scene);
1227 }
1228 }
1229 }
1230
1231 loadSVG.prototype.parseMetadata=function(coord,node) {
1232 var nodes = node.childNodes();
1233
1234 for(k in nodes) {
1235 var name = nodes[k].name();
1236 if (name == 'scenes') {
1237 this.scenes=[];
1238 this.scenenames={};
1239 this.parseScenes(coord,nodes[k]);
1240 }
1241 }
1242 }
1194 loadSVG.prototype.parseDefs=function(root,n) 1243 loadSVG.prototype.parseDefs=function(root,n)
1195 { 1244 {
1196 var k; 1245 var k;
1197 var nodes = n.childNodes(); 1246 var nodes = n.childNodes();
1198 1247