# vertex()#

Add a new vertex to a shape.

## Examples# ```1def setup():
2    py5.begin_shape(py5.POINTS)
3    py5.vertex(30, 20)
4    py5.vertex(85, 20)
5    py5.vertex(85, 75)
6    py5.vertex(30, 75)
7    py5.end_shape()
``` ``` 1def setup():
2    py5.size(100, 100, py5.P3D)
3    # drawing vertices in 3D requires P3D
4    # as a parameter to size()
5    py5.begin_shape()
6    py5.vertex(30, 20, 10)
7    py5.vertex(85, 20, 10)
8    py5.vertex(85, 75, 10)
9    py5.vertex(30, 75, 10)
10    py5.end_shape(py5.CLOSE)
``` ``` 1def setup():
2    py5.size(100, 100, py5.P3D)
4    py5.no_stroke()
5    py5.begin_shape()
6    py5.texture(img)
7    # "laDefense.jpg" is 100x100 pixels in size so
8    # the values 0 and 100 are used for the
9    # parameters "u" and "v" to map it directly
10    # to the vertex points
11    py5.vertex(10, 20, 0, 0)
12    py5.vertex(80, 5, 100, 0)
13    py5.vertex(95, 90, 100, 100)
14    py5.vertex(40, 95, 0, 100)
15    py5.end_shape()
```

## Description#

Add a new vertex to a shape. All shapes are constructed by connecting a series of vertices. The `vertex()` method is used to specify the vertex coordinates for points, lines, triangles, quads, and polygons. It is used exclusively within the begin_shape() and end_shape() functions.

Drawing a vertex in 3D using the `z` parameter requires the `P3D` renderer, as shown in the second example.

This method 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 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 the Sketch’s texture_mode() method.

Underlying Processing method: vertex

## Syntax#

```vertex(v: npt.NDArray[np.floating], /) -> None
vertex(x: float, y: float, /) -> None
vertex(x: float, y: float, u: float, v: float, /) -> None
vertex(x: float, y: float, z: float, /) -> None
vertex(x: float, y: float, z: float, u: float, v: float, /) -> None
```

## Parameters#

• u: float - horizontal coordinate for the texture mapping

• v: float - vertical coordinate for the texture mapping

• v: npt.NDArray[np.floating] - vertical coordinate data for the texture mapping

• x: float - x-coordinate of the vertex

• y: float - y-coordinate of the vertex

• z: float - z-coordinate of the vertex

Updated on February 26, 2022 13:22:44pm UTC