Skip to content

[Bug]: fabric.js Polygon方法创建实例时候,再调用set({points:newPoints})方法,无法更新控制点 #10682

@Linpengfei-NB

Description

@Linpengfei-NB

CheckList

  • I agree to follow this project's Code of Conduct
  • I have read and followed the Contributing Guide
  • I have read and followed the Issue Tracker Guide
  • I have searched and referenced existing issues and discussions
  • I am filing a BUG report.
  • I have managed to reproduce the bug after upgrading to the latest version
  • I have created an accurate and minimal reproduction

Version

5.3.0

In What environments are you experiencing the problem?

No response

Node Version (if applicable)

None

Link To Reproduction

无在线链接

Steps To Reproduce

const canvas = new fabric.Canvas("game");
const rect = new fabric.Polygon(
[
{ x: 400, y: 250 },
{ x: 350, y: 350 },
{ x: 450, y: 350 },
],
{
fill: "#ffffff",
stroke: "#000000",
strokeWidth: 1,
customType: 'triangle',
evented: true, // 必须为 true(默认值)
objectCaching: false, // 禁用缓存以确保事件触发
selectable: true, // 确保对象可被选中
hasControls: true, // 显示控制点
}
);

canvas.add(rect);
rect.set({
points: [
{ x: 500, y: 350 },
{ x: 450, y: 450 },
{ x: 550, y: 450 },
],
});
rect.set("fill", "red");
rect.setCoords(); // 更新控制点坐标

Expected Behavior

更新控制点坐标

Actual Behavior

无法更新控制点坐标

Error Message & Stack Trace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions