I’m currently using the engine.readPixels function to calculate the average color of the current frame every second.
However, this method is proving to be slow and affecting performance. I’m exploring the possibility of using the Offscreen API to call this function more efficiently.
Does anyone have experience or suggestions on implementing/using engine.readPixels with the Offscreen API to optimize performance?
You rarely need to sample every single pixel in the image to get good results with average color detection.
Try to use Color Thief with different quality settings.
You can try this option, I haven’t tried it.
One of the ways readPixels reduces time consumption is by reducing the number of pixels you get, but that doesn’t seem to work for you.
Or you can try reducing the canvas resolution.