填充在形状中的图像未在FabricJS中加载loadFromJSON

时间:2013-08-21 11:50:19

标签: image canvas html5-canvas loading fabricjs

我有使用Fabric Rect对象的 JSON 数据。当我尝试使用 LoadFromJSON 将此 JSON 数据加载到结构画布时,形状正在加载完美,但形状中填充的图案不会呈现。只有在点击形状后才会渲染图案。

我已将我的代码复制到Fabric Kitchen sink执行模块中,我试图执行它。但它也没有按预期工作。

我的代码:

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();

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我刚刚从1.1.6更新到1.2.9,使用loadFromJson时我的图像资源也没有显示!

什么改变了?!