def setup
background(220)
strokeWeight(3)
beginShape(POINTS)
vertex(30, 20)
vertex(85, 20)
vertex(85, 75)
vertex(30, 75)
endShape
end
def setup
createCanvas(100, 100, WEBGL)
background(240, 240, 240)
fill(237, 34, 93)
noStroke
beginShape
vertex(0, 35)
vertex(35, 0)
vertex(0, -35)
vertex(-35, 0)
endShape()
end
def setup
createCanvas(100, 100, WEBGL)
background(240, 240, 240)
fill(237, 34, 93)
noStroke
beginShape
vertex(-10, 10)
vertex(0, 35)
vertex(10, 10)
vertex(35, 0)
vertex(10, -8)
vertex(0, -35)
vertex(-10, -8)
vertex(-35, 0)
endShape
end
def setup
strokeWeight(3)
stroke(237, 34, 93)
beginShape(LINES)
vertex(10, 35)
vertex(90, 35)
vertex(10, 65)
vertex(90, 65)
vertex(35, 10)
vertex(35, 90)
vertex(65, 10)
vertex(65, 90)
endShape
end
def setup
createCanvas(100, 100, WEBGL)
@sides = 3
fill(237, 34, 93)
strokeWeight(3)
end
def draw
background(200)
rotateX(frameCount * 0.01)
rotateZ(frameCount * 0.01)
ngon(@sides, 0, 0, 80)
end
def mouseClicked
if (@sides > 6)
@sides = 3
else
@sides += 1
end
end
def ngon(n, x, y, d)
beginShape(TESS)
(0..n).each do |i|
angle = TWO_PI / n * i
px = x + sin(angle) * d / 2
py = y - cos(angle) * d / 2
vertex(px, py, 0)
end
(0..n).each do |i|
angle = TWO_PI / n * i
px = x + sin(angle) * d / 4
py = y - cos(angle) * d / 4
vertex(px, py, 0)
end
endShape
end
多角形などの頂点座標を指定します。
| 引数名 | 内容 | 備考 | オプション | デフォルト値 |
|---|---|---|---|---|
| x | 頂点の x座標 | |||
| y | 頂点の y座標 | |||
| z | 頂点の z座標 | ○ | 0 | |
| u | 頂点のテクスチャの u座標 | ○ | ||
| v | 頂点のテクスチャの v座標 | ○ |
なし
・「beginShape ~ endShape」構文または「shape do ~ end」構文の中でのみ有効です。