Name

clear

Examples
pg <- NULL

settings <- function() {
    size(200, 200)
}

setup <- function() {
    pg <- createGraphics(100, 100)
}

draw <- function() {
    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
mousePressed <- function() {
    pg$beginDraw()
    pg$clear()
    pg$endDraw()
}
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()
Creative Commons License