Is there a way to redraw or save pixels in near constant time?
Currently Im creating a grain overlay by drawing thousands of randomly placed rectangles. I have to draw this grain for every single frame. My issue is that looping through and drawing thousands of rects is time consuming. I was wondering if there is a way to draw my grain overlay once, save the pixel data, and then add the grain in every frame (in a way thats quicker than just re drawing the grain)
Im trying to keep my project small and just code based, so I’de like to find a way to do this without saving the grain as a png.
This may be a stupid question as I have very little knowledge of the backend to p5. I just figured that if I can pre load and re draw images quickly, I should be able to do the same with the canvas without actually making it an image.
Any reply is greatly appreciated!