def setup
background(220)
ellipse(0, 50, 33, 33) # Left circle
push # Start a new drawing state
strokeWeight(10)
fill(204, 153, 0)
translate(50, 0)
ellipse(0, 50, 33, 33) # Middle circle
pop # Restore original state
ellipse(100, 50, 33, 33) # Right circle
end
def setup
background(220)
ellipse(0, 50, 33, 33) # Left circle
push do # Start a new drawing state
strokeWeight(10)
fill(204, 153, 0)
ellipse(33, 50, 33, 33) # Left-middle circle
push do # Start another new drawing state
stroke(0, 102, 153)
ellipse(66, 50, 33, 33) # Right-middle circle
end # Restore previous state
end # Restore original state
ellipse(100, 50, 33, 33) # Right circle
end
描画スタイルや座標系などの設定を保存します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| ... | ブロック | 任意の処理 |
なし
・「push do ~ end」は「push ~ pop」を Ruby風にアレンジした構文です。
・ブロック引数を指定する「push do ~ end」構文を用いない場合は、
必ず popメソッドとペアで使用してください。