本文介绍了在FabricJS中,无法使用loadFromJSON加载填充在形状中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有矩形Rect物件的 JSON 资料。当我尝试使用 LoadFromJSON 将此 JSON 数据加载到布料画布上时,图形会完美加载,但是图形中填充的图案不会呈现。



我已经复制我的代码在布料厨房水槽执行模块,我试图执行它。



<$ p $

p> 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 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} :}';
canvas.loadFromJSON(jsonD);
canvas.renderAll();

如何解决这个问题?

解决方案

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



heck改变了?!


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?

解决方案

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?!

这篇关于在FabricJS中,无法使用loadFromJSON加载填充在形状中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 16:19