Images filled in the shapes are not loading with loadFromJSON in FabricJS

我们两清 提交于 2019-12-22 18:09:04

问题


I have JSON data with fabric Rect object. When I try to load this JSON data on to fabric canvas with LoadFromJSON, Shapes are loading perfectly but patterns filled in the shapes are not rendering. The patterns are rendered only after clicking on shape.

I have copied my code in fabric Kitchen sink execute module and i tried to execute it. But it is also not working as expected.

My Code:

var jsonD = '{"objects":[{"type":"rect","originX":"center","originY":"center","left":222.92,"top":237,"width":100,"height":100,"fill":{"source":"http://www.convertingquarterly.com/Portals/1/images/industry-news/Brushfoil%20cross-hatch,%20Tru-Stainless%20paaterns.jpg","repeat":"repeat","offsetX":0,"offsetY":0},"overlayFill":null,"stroke":"black","strokeWidth":1,"strokeDashArray":null,"strokeLineCap":"butt","strokeLineJoin":"miter","strokeMiterLimit":10,"scaleX":1,"scaleY":1,"angle":0,"flipX":false,"flipY":false,"opacity":1,"selectable":true,"hasControls":true,"hasBorders":true,"hasRotatingPoint":true,"transparentCorners":true,"perPixelTargetFind":false,"shadow":null,"visible":true,"clipTo":null,"rx":0,"ry":0,"x":0,"y":0}],"background":""}';
canvas.loadFromJSON(jsonD);
canvas.renderAll();

How to solve this problem?


回答1:


I have just updated from 1.1.6 to 1.2.9 and my image assets are also not showing when using loadFromJson!

What the heck changed?!



来源:https://stackoverflow.com/questions/18356638/images-filled-in-the-shapes-are-not-loading-with-loadfromjson-in-fabricjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!