This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

clear()

Examples
PGraphics pg;

void setup() {
  size(200, 200);
  pg = createGraphics(100, 100);
}

void draw() {
  background(204);
  pg.beginDraw();
  pg.stroke(0, 102, 153);
  pg.line(0, 0, mouseX, mouseY);
  pg.endDraw();
  image(pg, 50, 50); 
}

// Click to clear the PGraphics object
void mousePressed() {
  pg.clear();
}
Description Clears the pixels within a buffer. This function only works on PGraphics objects created with the createGraphics() function; it won't work with the main display window. Unlike the main graphics context (the display window), pixels in additional graphics areas created with createGraphics() can be entirely or partially transparent. This function clears everything to make all of the pixels 100% transparent.
Syntax
clear()
Returnsvoid
Updated on May 19, 2014 05:30:02pm PDT

Creative Commons License