-
Something useful for performance reasons, when drawing on off-screen buffers, like, maybe on a Py5Graphics object, is that you can create it once and point a global name to it, and then redraw over it again and again. Is there a fast way of emptying a Py5Shape object made of vertices? I have looked at the Processing PShape methods and found only cumbersome ways of removing vertices... so I wonder if I would be able to avoid creating a new Py5Shape every time I want to draw my thousands of lines or triangles ;) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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 I don't think there is a way to change the number of vertices but you can change each of the vertex values with BTW, updating a Py5Shape object's vertices with |
Beta Was this translation helpful? Give feedback.
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 newpredraw_update()
function. It doesn't draw to the screen so you can call it whenever you wish.