我已经使用fabric.loadSVGFromURL
功能加载SVG图像的画布。 大部分图片都是正确加载在画布上,但也有未在画布上正确加载一些SVG图像(SVG的一半作为加载黑色SVG)。
继SVG没有正确地装在画布上:
http://dev9.edisbest.com/Bat_B_020.svg
以下是我所使用的代码:
var src ="http://dev9.edisbest.com/Bat_B_020.svg";
fabric.loadSVGFromURL(src, function (objects, options) {
var shape = fabric.util.groupSVGElements(objects, options);
shape.set({
left: canvas.width/2,
top: canvas.height/2,
scaleY: canvas.height / (shape.height*3),
scaleX: canvas.width /(shape.width*3)
});
shape.setCoords();
canvas.add(shape);
canvas.setActiveObject(shape);
canvas.renderAll();
});
此屏幕截图时上述装载在画布SVG截取; 有我在SVG得到了不想要的黑色这实际上不是。