Skip to content

Can you "recycle" a Py5Shape? #413

Closed Answered by hx2A
villares asked this question in Q&A
Feb 5, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

I have experience with recycling Py5Shapes. You don't want to create a new Py5Shape object for each frame. It is better to create one in setup() and re-use it.

I don't think there is a way to change the number of vertices but you can change each of the vertex values with set_vertex(). If you want to reduce the number of vertices you can set the vertices to values off the edge of the screen. They will be culled by the renderer (OpenGL can do this quickly).

BTW, updating a Py5Shape object's vertices with set_vertex() is one of the things you are allowed to do in py5's new predraw_update() function. It doesn't draw to the screen so you can call it whenever you wish.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@villares
Comment options

villares Apr 28, 2024
Collaborator Author

@hx2A
Comment options

Answer selected by villares
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants