def setup
createCanvas(100, 100)
background(0)
button = createButton('Action')
button.position(0, 0)
button.mouseWheel do |event|
event = Native(`event`)
if event.deltaY > 0
@d += 10
else
@d -= 10
end
@d = constrain(@d, 10, 100)
@g = rand(255)
end
@g = 220
@d = 50
end
def draw
background(@g)
ellipse(width / 2, height / 2, @d, @d)
end
[p5.js] (p5.Element.obj).mouseWheel
要素上でマウスホイールイベントが検出されたときに実行する処理を登録します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| ... | ブロック | 実行される処理 |
なし
・ブロック引数として eventオブジェクトを受け取りますが、
rbCanvas/p5上でこのオブジェクトを扱うためには Nativeメソッドでの変換が必要です。