[−][src]Static p5_sys::global::vertex
pub static vertex: VertexInternalType
All shapes are constructed by connecting a series of vertices. vertex() is used to specify the vertex coordinates for points, lines, triangles, quads, and polygons. It is used exclusively within the beginShape() and endShape() functions.
Examples
strokeWeight(3); beginShape(POINTS); vertex(30, 20); vertex(85, 20); vertex(85, 75); vertex(30, 75); endShape();
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();
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();
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();
// Click to change the number of sides. // In WebGL mode, custom shapes will only // display hollow fill sections when // all calls to vertex() use the same z-value. let sides = 3; let angle, px, py; function setup() { createCanvas(100, 100, WEBGL); setAttributes('antialias', true); fill(237, 34, 93); strokeWeight(3); } function draw() { background(200); rotateX(frameCount * 0.01); rotateZ(frameCount * 0.01); ngon(sides, 0, 0, 80); } function mouseClicked() { if (sides > 6) { sides = 3; } else { sides++; } } function ngon(n, x, y, d) { beginShape(TESS); for (let i = 0; i < n + 1; i++) { angle = TWO_PI / n * i; px = x + sin(angle) * d / 2; py = y - cos(angle) * d / 2; vertex(px, py, 0); } for (let i = 0; i < n + 1; i++) { angle = TWO_PI / n * i; px = x + sin(angle) * d / 4; py = y - cos(angle) * d / 4; vertex(px, py, 0); } endShape(); }
Overloads
x
x-coordinate of the vertex
y
y-coordinate of the vertex
x
x-coordinate of the vertex
y
y-coordinate of the vertex
z
z-coordinate of the vertex
u?
the vertex's texture u-coordinate
v?
the vertex's texture v-coordinate