KineticJS在对象创建(NOOB)后更改属性

KineticJS change property after object creation (NOOB)

本文关键字:属性 NOOB 对象 创建 KineticJS      更新时间:2023-09-26

大家好,我是 KineticJS 的菜鸟,我想知道如何更改属性值。例如,对于创建后的矩形:

var rect = new Kinetic.Rect({
          x: 239,
          y: 75,
          width: 100,
          height: 50,
          fill: "#00D2FF",
          stroke: "black",
          strokeWidth: 4
        });

我将如何做这样的事情:

rect.NewProperty({
      x: 100,
      y: 30,
      width: 100,
      height: 50,
      fill: "#cccccc",
    });

并保留其他属性不变?

像这样:

var rect = new Kinetic.Rect({
          x: 239,
          y: 75,
          width: 100,
          height: 50,
          fill: "#00D2FF",
          stroke: "black",
          strokeWidth: 4
        });
rect.setFill("#D200FF");
rect.setStrokeWidth(1);

感谢您提供的信息。

我也试过

rect.setWidth(100);

rect.setHeight(100);

它适用于:)