def setup
background(200)
translate(30, 20)
rect(0, 0, 55, 55)
end
def setup
background(200)
rect(0, 0, 55, 55) # Draw rect at original 0,0
translate(30, 20);
rect(0, 0, 55, 55) # Draw rect at new 0,0
translate(14, 14);
rect(0, 0, 55, 55) # Draw rect at new 0,0
end
def draw
background(200)
rectMode(CENTER)
translate(width / 2, height / 2)
translate(P5Vector.fromAngle(millis / 1000, 40))
rect(0, 0, 20, 20)
end
キャンバス上の座標系を平行移動します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| x | 左右移動 | 単位:ピクセル | ||
| y | 上下移動 | 単位:ピクセル | ||
| z | 前後移動 | 単位:ピクセル WEBGLモードのキャンバスでのみ有効 | ○ | 0 |
| vector | 移動量を示すベクトル | p5.Vectorオブジェクト |
なし
・座標系変換の効果は累積されていきます。
・ただし、drawメソッドの実行ごとに座標系変換の設定内容がリセットされます。