Class Pixels
java.lang.Object
org.openpatch.scratch.extensions.pixels.Pixels
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.
-
Constructor Summary
ConstructorsConstructorDescriptionPixels(processing.core.PGraphics mainBuffer, processing.core.PGraphics backgroundBuffer, processing.core.PGraphics foregroundBuffer) Creates the pixel access for a stage. -
Method Summary
Modifier and TypeMethodDescriptionint[]Returns the pixels of the background layer, where the pen and stamps draw.int[]Returns the pixels of the foreground layer.int[]main()Returns the pixels of the layer the sprites are drawn on.
-
Constructor Details
-
Pixels
public Pixels(processing.core.PGraphics mainBuffer, processing.core.PGraphics backgroundBuffer, processing.core.PGraphics foregroundBuffer) Creates the pixel access for a stage.- Parameters:
mainBuffer- where the sprites are drawnbackgroundBuffer- where the background is drawnforegroundBuffer- where the foreground is drawn
-
-
Method Details
-
main
public int[] main()Returns the pixels of the layer the sprites are drawn on.- Returns:
- one colour per pixel
-
background
public int[] background()Returns the pixels of the background layer, where the pen and stamps draw.- Returns:
- one colour per pixel
-
foreground
public int[] foreground()Returns the pixels of the foreground layer.- Returns:
- one colour per pixel
-