Scratch for Java

Stage::getPixels()

Browser availability: desktop-only.

The desktop pixel buffer is not exposed by the browser renderer.

Returns the colours of everything this stage has drawn.

Example usage:

int[] colours = this.getPixels().main();

Examples

This example requires the desktop runtime in the current browser revision.

void main() {
  Stage myStage = new Stage(600, 240);
 
  // The raw pixels of the stage. Only the desktop version can reach them - in
  // the browser this prints a notice and hands back an empty array.
  int[] pixels = myStage.getPixels().main();
  System.out.println("the stage has " + pixels.length + " pixels");
}
 

View on GitHub

Syntax

Java

.getPixels()

Return

Pixels

getPixels()

Create Shareable URL

Select Sections