Py5Shape.get_vertex()#

The get_vertex() method returns a Py5Vector with the coordinates of the vertex point located at the position defined by the index parameter.

Examples#

 1def setup():
 2    global s
 3    s = py5.create_shape()
 4    s.begin_shape()
 5    s.vertex(0, 0)
 6    s.vertex(60, 0)
 7    s.vertex(60, 60)
 8    s.vertex(0, 60)
 9    s.end_shape(py5.CLOSE)
10
11
12def draw():
13    py5.translate(20, 20)
14    for i in range(0, s.get_vertex_count()):
15        v = s.get_vertex(i)
16        v.x += py5.random(-1, 1)
17        v.y += py5.random(-1, 1)
18        s.set_vertex(i, v)
19
20    py5.shape(s)

Description#

The get_vertex() method returns a Py5Vector with the coordinates of the vertex point located at the position defined by the index parameter. This method works when shapes are created as shown in the example, but won’t work properly when a shape is defined explicitly (e.g. create_shape(RECT, 20, 20, 80, 80).

Underlying Processing method: PShape.getVertex

Syntax#

get_vertex(index: int, /) -> Py5Vector
get_vertex(index: int, vec: Py5Vector, /) -> Py5Vector

Parameters#

  • index: int - vertex index

  • vec: Py5Vector - target object to place vertex coordinates into

Updated on January 16, 2022 16:51:21pm UTC