Mercurial > MadButterfly
comparison nodejs/svg.js @ 1376:4c5bcaba28ea
Check in so that we can check the crash issues.
author | wycc |
---|---|
date | Fri, 11 Mar 2011 14:07:55 +0800 |
parents | 593a418ed8bf |
children | 9ce82873d406 |
comparison
equal
deleted
inserted
replaced
1375:37dc1ce76bba | 1376:4c5bcaba28ea |
---|---|
39 if (filename) | 39 if (filename) |
40 this.load(mb_rt,root,filename); | 40 this.load(mb_rt,root,filename); |
41 } | 41 } |
42 | 42 |
43 loadSVG.prototype.load=function(mb_rt, root, filename) { | 43 loadSVG.prototype.load=function(mb_rt, root, filename) { |
44 sys.puts(filename); | |
45 sys.puts(libxml); | |
44 var doc = libxml.parseXmlFile(filename); | 46 var doc = libxml.parseXmlFile(filename); |
45 var _root = doc.root(); | 47 var _root = doc.root(); |
46 var nodes = _root.childNodes(); | 48 var nodes = _root.childNodes(); |
47 var coord = mb_rt.coord_new(root); | 49 var coord = mb_rt.coord_new(root); |
48 var k; | 50 var k; |
49 var accu=[1,0,0,0,1,0]; | 51 var accu=[1,0,0,0,1,0]; |
50 this.mb_rt = mb_rt; | 52 this.mb_rt = mb_rt; |
51 this.stop_ref={}; | 53 this.stop_ref={}; |
52 this.gradients={}; | 54 this.gradients={}; |
53 this.radials = {}; | 55 this.radials = {}; |
56 this._groupMap={}; | |
54 coord.center=new Object(); | 57 coord.center=new Object(); |
55 coord.center.x = 10000; | 58 coord.center.x = 10000; |
56 coord.center.y = 10000; | 59 coord.center.y = 10000; |
57 if (this.pgstack.length > 0) | 60 if (this.pgstack.length > 0) |
58 this.pgstack[this.pgstack.length-1].hide(); | 61 this.pgstack[this.pgstack.length-1].hide(); |
938 sys.puts("Unknown style: "+kv[0]); | 941 sys.puts("Unknown style: "+kv[0]); |
939 } | 942 } |
940 } | 943 } |
941 } | 944 } |
942 | 945 |
946 loadSVG.prototype.duplicateGroup=function(id,root) { | |
947 n = this._groupMap[id]; | |
948 var m = [1,0,0,1,0,0] | |
949 this.parseGroup(m,root,id, n) | |
950 } | |
951 | |
943 loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) { | 952 loadSVG.prototype.parseGroup=function(accu_matrix,root, group_id, n) { |
944 var k; | 953 var k; |
945 var nodes = n.childNodes(); | 954 var nodes = n.childNodes(); |
946 var coord = this.mb_rt.coord_new(root); | 955 var coord = this.mb_rt.coord_new(root); |
947 // Parse the transform and style here | 956 // Parse the transform and style here |
988 root.center.x = coord.center.x; | 997 root.center.x = coord.center.x; |
989 if (root.center.y > coord.center.y) | 998 if (root.center.y > coord.center.y) |
990 root.center.y = coord.center.y; | 999 root.center.y = coord.center.y; |
991 | 1000 |
992 this._set_bbox(n, coord); | 1001 this._set_bbox(n, coord); |
1002 this._groupMap[n.name()] = n; | |
993 | 1003 |
994 make_mbnames(this.mb_rt, n, coord); | 1004 make_mbnames(this.mb_rt, n, coord); |
995 }; | 1005 }; |
996 | 1006 |
997 loadSVG.prototype.parseImage=function(accu,coord,id, n) | 1007 loadSVG.prototype.parseImage=function(accu,coord,id, n) |
1216 scene.end = parseInt(node.attr('end').value()); | 1226 scene.end = parseInt(node.attr('end').value()); |
1217 } catch(e) { | 1227 } catch(e) { |
1218 scene.end = scene.start; | 1228 scene.end = scene.start; |
1219 } | 1229 } |
1220 scene.ref = node.attr('ref').value(); | 1230 scene.ref = node.attr('ref').value(); |
1221 scene.type = node.attr('type').value(); | 1231 try { |
1232 scene.type = node.attr('type').value(); | |
1233 } catch(e) { | |
1234 scene.type='normal'; | |
1235 } | |
1222 | 1236 |
1223 try { | 1237 try { |
1224 this.scenenames[node.attr('name').value()] = scene.start; | 1238 this.scenenames[node.attr('name').value()] = scene.start; |
1225 } catch(e) { | 1239 } catch(e) { |
1226 } | 1240 } |
1227 this.scenes.push(scene); | 1241 this.scenes.push(scene); |
1242 } | |
1243 } | |
1244 } | |
1245 | |
1246 loadSVG.prototype.parseComponents=function(coord,node) { | |
1247 | |
1248 var nodes = node.childNodes(); | |
1249 | |
1250 for(k in nodes) { | |
1251 var name = nodes[k].name(); | |
1252 if (name == 'component') { | |
1253 // Parse the component here | |
1228 } | 1254 } |
1229 } | 1255 } |
1230 } | 1256 } |
1231 | 1257 |
1232 loadSVG.prototype.parseMetadata=function(coord,node) { | 1258 loadSVG.prototype.parseMetadata=function(coord,node) { |
1236 var name = nodes[k].name(); | 1262 var name = nodes[k].name(); |
1237 if (name == 'scenes') { | 1263 if (name == 'scenes') { |
1238 this.scenes=[]; | 1264 this.scenes=[]; |
1239 this.scenenames={}; | 1265 this.scenenames={}; |
1240 this.parseScenes(coord,nodes[k]); | 1266 this.parseScenes(coord,nodes[k]); |
1267 } else if (name == "components") { | |
1268 this.parseComponents(coord,nodes[k]); | |
1241 } | 1269 } |
1242 } | 1270 } |
1243 } | 1271 } |
1244 loadSVG.prototype.parseDefs=function(root,n) | 1272 loadSVG.prototype.parseDefs=function(root,n) |
1245 { | 1273 { |