q5js / q5.js

A sequel to p5.js that's optimized for interactive art!
https://q5js.org
GNU Lesser General Public License v3.0
123 stars 9 forks source link

Image `tint` caching #30

Closed codingMASTER398 closed 3 months ago

codingMASTER398 commented 8 months ago

Looking over the code at school at the moment- tinted images seem to create their offscreen canvas, apply filters, then draw- every frame. If the tint stays the same, it makes sense to cache the canvas with the image, for quick drawing for subsequent frames. This would also help with changing tints, as they could simply change the pre-existing canvas without the need for overhead creating more canvases.

quinton-ashley commented 3 months ago

@codingMASTER398 I've tried to solve this issue by changing how tint works in v2.1. Now tint does not require temporary canvases to be made, it just uses native canvas API "multiply" blend mode compositing, and thus should be very fast for real time use.

I think tint caching could be done by users if it's still deemed necessary. I'm going to close this out as completed.

Let me know what you think of the changes!