Py5Shape.set_path()#
Set many vertex points at the same time, using a numpy array.
Examples#
import numpy as np
def setup():
vertices = 100 * np.random.rand(25, 2)
s = py5.create_shape()
s.begin_shape()
s.no_fill()
s.vertices(vertices)
s.end_shape()
new_vertices = 100 * np.random.rand(25, 2)
s.set_path(new_vertices.shape[0], new_vertices)
py5.shape(s)
Description#
Set many vertex points at the same time, using a numpy array. This will be faster and more efficient than repeatedly calling Py5Shape.set_vertex() in a loop. Setting the vertex codes is not supported, so the vertices will be regular vertices and not bezier, quadratic or curve vertices.
The vcount
parameter cannot be larger than the first dimension of the verts
array.
Underlying Processing method: PShape.setPath
Signatures#
set_path(
vcount: int, # number of vertices
verts: npt.NDArray[np.floating], # 2D array of vertex coordinates
/,
) -> None
Updated on October 28, 2024 04:41:56am UTC