Mercurial > MadButterfly
comparison nodejs/svg.js @ 1398:6fa4a53c3fca
Use clone_from_subtree to generate content for the svg:use.
author | wycc |
---|---|
date | Sun, 03 Apr 2011 11:48:39 +0800 |
parents | a768d74e5f49 |
children | 18215e577fe0 |
comparison
equal
deleted
inserted
replaced
1397:a19f6cecf3c8 | 1398:6fa4a53c3fca |
---|---|
631 loadSVG.prototype._set_bbox = function(node, tgt) { | 631 loadSVG.prototype._set_bbox = function(node, tgt) { |
632 var a; | 632 var a; |
633 var vstr; | 633 var vstr; |
634 var bbox, center; | 634 var bbox, center; |
635 var orig; | 635 var orig; |
636 | 636 |
637 a = node.attr("bbox-x"); | 637 a = node.attr("bbox-x"); |
638 if(!a) { | 638 if(!a) { |
639 tgt.center = new Object(); | 639 tgt.center = new Object(); |
640 tgt.center.x=0; | 640 tgt.center.x=0; |
641 tgt.center.y=0; | 641 tgt.center.y=0; |
1131 }; | 1131 }; |
1132 | 1132 |
1133 loadSVG.prototype.parseUse=function(accu_matrix,root, use_id, n) { | 1133 loadSVG.prototype.parseUse=function(accu_matrix,root, use_id, n) { |
1134 var k; | 1134 var k; |
1135 var nodes; | 1135 var nodes; |
1136 var coord = this.mb_rt.coord_new(root); | 1136 var coord; |
1137 // Parse the transform and style here | 1137 // Parse the transform and style here |
1138 var trans = n.attr('transform'); | 1138 var trans = n.attr('transform'); |
1139 var accu=[1,0,0,0,1,0]; | 1139 var accu=[1,0,0,0,1,0]; |
1140 var style; | 1140 var style; |
1141 var attr = n.attr('duplicate-src'); | |
1142 if (attr) { | |
1143 var src = this.mb_rt.mbnames[attr.value()]; | |
1144 coord = root.clone_from_subtree(src); | |
1145 } else { | |
1146 coord = this.mb_rt.coord_new(root); | |
1147 } | |
1141 n.coord = coord; | 1148 n.coord = coord; |
1142 coord.node = n; | 1149 coord.node = n; |
1143 this._check_duplicate_src(n,coord); | 1150 this._check_duplicate_src(n,coord); |
1144 | 1151 |
1145 coord.center= new Object(); | 1152 coord.center= new Object(); |
1155 coord.r = 0; | 1162 coord.r = 0; |
1156 coord.tx = 0; | 1163 coord.tx = 0; |
1157 coord.ty = 0; | 1164 coord.ty = 0; |
1158 | 1165 |
1159 } | 1166 } |
1160 var attr = n.attr('duplicate-src'); | |
1161 if (attr) { | |
1162 var src = this.mb_rt.mbnames[attr.value()]; | |
1163 multiply(coord, coord,src); | |
1164 } | |
1165 multiply(accu,accu_matrix); | 1167 multiply(accu,accu_matrix); |
1166 multiply(accu,coord); | 1168 multiply(accu,coord); |
1167 | 1169 |
1168 style = {}; | 1170 style = {}; |
1169 parseGroupStyle(style, n); | 1171 parseGroupStyle(style, n); |
1174 | 1176 |
1175 if (root.center.x > coord.center.x) | 1177 if (root.center.x > coord.center.x) |
1176 root.center.x = coord.center.x; | 1178 root.center.x = coord.center.x; |
1177 if (root.center.y > coord.center.y) | 1179 if (root.center.y > coord.center.y) |
1178 root.center.y = coord.center.y; | 1180 root.center.y = coord.center.y; |
1179 | |
1180 this._set_bbox(n, coord); | 1181 this._set_bbox(n, coord); |
1181 this._groupMap[n.name()] = n; | 1182 this._groupMap[n.name()] = n; |
1182 | 1183 |
1183 make_mbnames(this.mb_rt, n, coord); | 1184 make_mbnames(this.mb_rt, n, coord); |
1184 }; | 1185 }; |