Py5Shape.get_vertex_count()#

The get_vertex_count() method returns the number of vertices that make up a Py5Shape.

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[0] += py5.random(-1, 1)
17        v[1] += py5.random(-1, 1)
18        s.set_vertex(i, v)
19
20    py5.shape(s)

Description#

The get_vertex_count() method returns the number of vertices that make up a Py5Shape. In the example, the value 4 is returned by the get_vertex_count() method because 4 vertices are defined in setup().

Underlying Processing method: PShape.getVertexCount

Syntax#

get_vertex_count() -> int

Updated on November 12, 2021 11:30:58am UTC