SVG是不是与Fabric.js帆布正确呈现(SVG is not rendering proper

2019-10-19 02:00发布

我已经使用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得到了不想要的黑色这实际上不是。

Answer 1:

这个问题是由Kangax解决。

请查看以下链接:

https://github.com/kangax/fabric.js/issues/1021

感谢你这么多Kangax ....!



文章来源: SVG is not rendering properly on canvas with Fabric.js