我在更改矩形、圆形和图像的描边颜色或描边宽度时遇到错误。每次我更改这些值时,边界都会呈指数级变大。
var obj = canvas.getActiveObject();
obj.set("stroke", stroke);
obj.set("strokeWidth", strokeWidth);
canvas.renderAll();
我正在使用此代码来设置这些属性。
Image 1 shows the circle I added to canvas.
Image 2 shows the increased border after I change stroke color.
最佳答案
使用parseInt()
方法而不是直接设置其值。
obj.set("stroke", parseInt(stroke));
关于javascript - 在 Fabric.js 中更改矩形、圆形和图像的描边或描边宽度时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35055628/