Name

vertex()

Description

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.

Drawing a vertex in 3D using the z parameter requires the P3D parameter in combination with size, as shown in the above example.

This function is also used to map a texture onto geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode().

Examples

  • size(400, 400);
    beginShape(POINTS);
    vertex(120, 80);
    vertex(340, 80);
    vertex(340, 300);
    vertex(120, 300);
    endShape();
    Image output for example 1
  • // Drawing vertices in 3D requires P3D
    // as a parameter to size()
    size(400, 400, P3D);
    beginShape(POINTS);
    vertex(120, 80, -200);
    vertex(340, 80, -200);
    vertex(340, 300, -200);
    vertex(120, 300, -200);
    endShape();
    Image output for example 2
  • size(400, 400, P3D);
    PImage img = loadImage("laDefense.jpg");
    noStroke();
    beginShape();
    texture(img);
    // "laDefense.jpg" is 100x100 pixels in size so
    // the values 0 and 400 are used for the
    // parameters "u" and "v" to map it directly
    // to the vertex points
    vertex(40, 80, 0, 0);
    vertex(320, 20, 100, 0);
    vertex(380, 360, 100, 100);
    vertex(160, 380, 0, 100);
    endShape();
    Image output for example 3

Syntax

  • vertex(x, y)
  • vertex(x, y, z)
  • vertex(v)
  • vertex(x, y, u, v)
  • vertex(x, y, z, u, v)

Parameters

  • v(float[], float)vertex parameters, as a float array of length VERTEX_FIELD_COUNT
  • x(float)x-coordinate of the vertex
  • y(float)y-coordinate of the vertex
  • z(float)z-coordinate of the vertex
  • u(float)horizontal coordinate for the texture mapping
  • v(float, float[])vertical coordinate for the texture mapping

Return

  • void