gpt4 book ai didi

javascript - 在 Fabric.js 中更改矩形、圆形和图像的描边或描边宽度时出错

转载 作者:行者123 更新时间:2023-12-02 15:06:57 27 4
gpt4 key购买 nike

我在更改矩形、圆形和图像的描边颜色或描边宽度时遇到错误。每次我更改这些值时,边界都会呈指数级变大。

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com