beginShape

(別名: begin_shape)

def setup
  background(220)
  beginShape
  vertex(30, 20)
  vertex(85, 20)
  vertex(85, 75)
  vertex(30, 75)
  endShape(CLOSE)
end
def setup
  background(220)
  beginShape(POINTS)
  vertex(30, 20)
  vertex(85, 20)
  vertex(85, 75)
  vertex(30, 75)
  endShape
end
def setup
  background(220)
  beginShape(LINES)
  vertex(30, 20)
  vertex(85, 20)
  vertex(85, 75)
  vertex(30, 75)
  endShape
end
def setup
  background(220)
  noFill
  beginShape
  vertex(30, 20)
  vertex(85, 20)
  vertex(85, 75)
  vertex(30, 75)
  endShape
end
def setup
  background(220)
  noFill
  beginShape
  vertex(30, 20)
  vertex(85, 20)
  vertex(85, 75)
  vertex(30, 75)
  endShape(CLOSE)
end
def setup
  background(220)
  beginShape(TRIANGLES)
  vertex(30, 75)
  vertex(40, 20)
  vertex(50, 75)
  vertex(60, 20)
  vertex(70, 75)
  vertex(80, 20)
  endShape
end
def setup
  background(220)
  beginShape(TRIANGLE_STRIP)
  vertex(30, 75)
  vertex(40, 20)
  vertex(50, 75)
  vertex(60, 20)
  vertex(70, 75)
  vertex(80, 20)
  vertex(90, 75)
  endShape
end
def setup
  background(220)
  beginShape(TRIANGLE_FAN)
  vertex(57.5, 50)
  vertex(57.5, 15)
  vertex(92, 50)
  vertex(57.5, 85)
  vertex(22, 50)
  vertex(57.5, 15)
  endShape
end
def setup
  background(220)
  beginShape(QUADS)
  vertex(30, 20)
  vertex(30, 75)
  vertex(50, 75)
  vertex(50, 20)
  vertex(65, 20)
  vertex(65, 75)
  vertex(85, 75)
  vertex(85, 20)
  endShape
end
def setup
  background(220)
  beginShape(QUAD_STRIP)
  vertex(30, 20)
  vertex(30, 75)
  vertex(50, 20)
  vertex(50, 75)
  vertex(65, 20)
  vertex(65, 75)
  vertex(85, 20)
  vertex(85, 75)
  endShape
end
def setup
  background(220)
  beginShape(TESS)
  vertex(20, 20)
  vertex(80, 20)
  vertex(80, 40)
  vertex(40, 40)
  vertex(40, 60)
  vertex(80, 60)
  vertex(80, 80)
  vertex(20, 80)
  endShape(CLOSE)
end

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

[p5.js] beginShape

概要

指定された頂点座標を記録して図形を描画します。

書式

beginShape([kind])

引数

引数名内容備考オプションデフォルト値
kind種別POINTS
LINES
TRIANGLES
TRIANGLE_FAN
TRIANGLE_STRIP
QUADS
QUAD_STRIP
TESS

戻値

なし

備考

・必ず endShapeメソッドとペアで使用してください。
・「beginShape ~ endShape」を Rubyライクな構文にした「shape do ~ end」も同じ動作をします。

関連

endShape
shape