comparison nodejs/svg.js @ 1384:98ea7146cef3

Fix the parseImage to setup the transform attributes correctly.
author wycc
date Fri, 25 Mar 2011 02:03:17 +0800
parents 9a585df24e52
children 2ebb07ee455e
comparison
equal deleted inserted replaced
1383:bdacbdeb4447 1384:98ea7146cef3
1131 coord.center.x = 10000; 1131 coord.center.x = 10000;
1132 coord.center.y = 10000; 1132 coord.center.y = 10000;
1133 if (trans!=null) { 1133 if (trans!=null) {
1134 parseTransform(coord, trans.value()); 1134 parseTransform(coord, trans.value());
1135 } else { 1135 } else {
1136 tcoord.sx = 1; 1136 coord.sx = 1;
1137 tcoord.sy = 1; 1137 coord.sy = 1;
1138 tcoord.r = 0; 1138 coord.r = 0;
1139 tcoord.tx = 0; 1139 coord.tx = 0;
1140 tcoord.ty = 0; 1140 coord.ty = 0;
1141 1141
1142 } 1142 }
1143 multiply(accu,accu_matrix); 1143 multiply(accu,accu_matrix);
1144 multiply(accu,coord); 1144 multiply(accu,coord);
1145 1145
1177 this.parseImage(accu_matrix,coord, id, nodes[k]); 1177 this.parseImage(accu_matrix,coord, id, nodes[k]);
1178 } else if (c == "use") { 1178 } else if (c == "use") {
1179 this.parseUse(accu_matrix,coord, id, nodes[k]); 1179 this.parseUse(accu_matrix,coord, id, nodes[k]);
1180 } 1180 }
1181 attr = nodes[k].attr('duplicate-src'); 1181 attr = nodes[k].attr('duplicate-src');
1182 if (attr == null) continue; 1182 if (attr == null) continue;
1183 id = attr.value(); 1183 id = attr.value();
1184 try { 1184 try {
1185 this.mbnames[id].target = coord; 1185 this.mbnames[id].target = coord;
1186 } catch(e) { 1186 } catch(e) {
1187 sys.puts("id "+id+" is not defined"); 1187 sys.puts("id "+id+" is not defined");
1215 } else { 1215 } else {
1216 } 1216 }
1217 var w; 1217 var w;
1218 var h; 1218 var h;
1219 var x,y,nx,ny; 1219 var x,y,nx,ny;
1220 coord.center= new Object(); 1220 tcoord.center= new Object();
1221 coord.center.x = 10000; 1221 tcoord.center.x = 10000;
1222 coord.center.y = 10000; 1222 tcoord.center.y = 10000;
1223 if (trans!=null) { 1223 if (trans!=null) {
1224 parseTransform(coord, trans.value()); 1224 parseTransform(coord, trans.value());
1225 } 1225 } else {
1226 tcoord.sx = 1;
1227 tcoord.sy = 1;
1228 tcoord.r = 0;
1229 tcoord.tx = 0;
1230 tcoord.ty = 0;
1231 }
1226 1232
1227 w = n.attr("width"); 1233 w = n.attr("width");
1228 if (w == null) return; 1234 if (w == null) return;
1229 w = parseFloat(w.value()); 1235 w = parseFloat(w.value());
1230 h = n.attr("height"); 1236 h = n.attr("height");
1234 if (x == null) return; 1240 if (x == null) return;
1235 x = parseFloat(x.value()); 1241 x = parseFloat(x.value());
1236 y = n.attr("y"); 1242 y = n.attr("y");
1237 if (y == null) return; 1243 if (y == null) return;
1238 y = parseFloat(y.value()); 1244 y = parseFloat(y.value());
1245 tcoord.tx += x;
1246 tcoord.ty += y;
1247 attr = n.attr('duplicate-src');
1248 if (attr) {
1249 var id = attr.value();
1250 var orign = this.mb_rt.mbnames[id].node;
1251 sys.puts("xxxxxxxxxxxxxx");
1252 var nw = getInteger(orign,'width');
1253 var nh = getInteger(orign,'height');
1254 sys.puts("nw="+nw);
1255 sys.puts("nh="+nh);
1256 sys.puts("w="+w);
1257 sys.puts("h="+h);
1258 tcoord.sx *= w/nw;
1259 tcoord.sy *= h/nh;
1260 }
1239 nx = tcoord[0]*x+tcoord[1]*y+tcoord[2]; 1261 nx = tcoord[0]*x+tcoord[1]*y+tcoord[2];
1240 ny = tcoord[3]*x+tcoord[4]*y+tcoord[5]; 1262 ny = tcoord[3]*x+tcoord[4]*y+tcoord[5];
1241 if (coord.center.x > nx) 1263 if (tcoord.center.x > nx)
1242 coord.center.x = nx; 1264 tcoord.center.x = nx;
1243 if (coord.center.y > ny) 1265 if (tcoord.center.y > ny)
1244 coord.center.y = ny; 1266 tcoord.center.y = ny;
1245 var img = this.mb_rt.image_new(x,y,w,h); 1267 var img = this.mb_rt.image_new(x,y,w,h);
1246 var img_data = ldr.load(ref); 1268 var img_data = ldr.load(ref);
1247 var paint = this.mb_rt.paint_image_new(img_data); 1269 try {
1248 paint.fill(img); 1270 sys.puts('----'+ref);
1271 var paint = this.mb_rt.paint_image_new(img_data);
1272 paint.fill(img);
1273 } catch(e) {
1274 sys.puts(e);
1275 sys.puts("Can not load image "+ref);
1276 }
1249 tcoord.add_shape(img); 1277 tcoord.add_shape(img);
1250 1278
1251 this._set_bbox(n, img); 1279 this._set_bbox(n, tcoord);
1252 1280
1253 make_mbnames(this.mb_rt, n, img); 1281 make_mbnames(this.mb_rt, n, tcoord);
1254 }; 1282 };
1255 1283
1256 function _parse_stops(n) { 1284 function _parse_stops(n) {
1257 var children; 1285 var children;
1258 var child; 1286 var child;