def draw
background(204)
angleMode(DEGREES) # Change the mode to DEGREES
a = atan2(mouseY - height / 2, mouseX - width / 2)
translate(width / 2, height / 2)
push do
rotate(a)
rect(-20, -5, 40, 10) # Larger rectangle is rotating in degrees
end
angleMode(RADIANS) # Change the mode to RADIANS
rotate(a) # variable a stays the same
rect(-40, -5, 20, 10) # Smaller rectangle is rotating in radians
end
角度の単位を設定また取得します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| mode | モード | RADIANS : ラジアン DEGREES : 度数 |
r : 現在の角度の単位