【问题标题】:How can I display size on the Rect shape by fabricjs?如何通过fabricjs在矩形形状上显示尺寸?
【发布时间】:2021-02-25 18:34:00
【问题描述】:

当我使用FabricJS 创建一个 Rect 形状时,我想显示 Rect 的宽度和高度,如下图所示。如果我缩放 Rect,文本应该更新。我该怎么做?

【问题讨论】:

标签: javascript fabricjs


【解决方案1】:

我们可以使用下面的代码来获取选定或活动的图像大小

// for getting active objects, here its Rectangle

this.selectedObj= this.canvas.getActiveObject().toObject().objects;

// if there is one object we get the resultant values like this.
var width = this.selectedData.objects[0].width;
var height = this.selectedData.objects[0].height;

【讨论】:

    猜你喜欢
    • 2016-01-31
    • 1970-01-01
    • 1970-01-01
    • 2013-04-16
    • 2017-09-09
    • 2022-08-29
    • 2023-03-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多