(p5.Element).size

def setup
  background(220)

  b1 = createButton('b1')
  b2 = createButton('b2')
  b3 = createButton('b3')

  b1.size(50, 30)
  b2.size(50, 20)
  b3.size(50, AUTO)

  b1.position(10,  5)  
  b2.position(10, 40)  
  b3.position(10, 65)

  text(b1.size.height, 75, 25)
  text(b2.size.height, 75, 55)
  text(b3.size.height, 75, 85)
end

p5.jsリファレンス(参考情報)

[p5.js] (p5.Element).size

概要

要素のサイズを設定または取得します。

書式

r = size
size(w [, h])

引数

引数名内容備考オプションデフォルト値
w要素の幅数値または AUTO
h要素の高さ数値または AUTO未詳

戻値

r : ハッシュ {x: x座標, y: y座標}

備考

・幅または高さのいずれか一方を設定する場合、設定が必要ない要素の方に AUTOを指定してください。

関連