簡體   English   中英

如何通過 fabricjs 在 Rect 形狀上顯示大小?

[英]How can I display size on the Rect shape by fabricjs?

當我使用FabricJS創建一個 Rect 形狀時,我想顯示 Rect 的寬度和高度,如下圖所示。 如果我縮放 Rect,文本應該更新。 我怎樣才能做到這一點?

圖像尺寸

為了獲得選定的或活動的圖像大小,我們可以使用下面的代碼

// 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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM