Pixels()
Browser availability: desktop-only.
This API requires the desktop runtime. Browser declarations may report the limitation without performing the operation.
The colours of everything a stage has drawn, one number per pixel.
Reached through stage.getPixels():
int[] colours = this.getPixels().main();
These layers live on the graphics card, and reading them back is both slow and
only possible while the stage is drawing. Asking from somewhere else - a
sprite's run(), say - gives an empty array. Treat this as a low-level
hook for drawing tricks rather than as a way to sense colours: a Scratch-style
"touching colour" check would have to read the whole screen back every frame,
which is far too slow for the machines this library is meant to run on.
Syntax
Java
new Pixels(mainBuffer, backgroundBuffer, foregroundBuffer)