GSDP:GAM100/CProcessing/restore()
From Inside
< GSDP:GAM100 | CProcessing
restore()
Description
Sets the draw settings back to the last time you called save(). Removes that save state from the stack. Make sure not to call restore() before calling save().
Example
void init()
{
rectMode(CENTER);
}
void update()
{
// Draw a white background
background(color(255, 255, 255, 255));
// Draw a red square in the top left corner
fill(color(255, 0, 0, 255));
stroke(color(0, 0, 255, 255));
rect(canvasWidth * 0.25f, canvasHeight * 0.20f, 100.0f, 100.0f);
// Save the settings of the first square
save();
// Draw a blue square in the top middle
fill(color(0, 0, 255, 255));
stroke(color(255, 0, 0, 255));
strokeWeight(5);
rect(canvasWidth * 0.5f, canvasHeight * 0.35f, 100.0f, 100.0f);
// Save the settings of the second square
save();
// Now draw a pink and green square on the right side of the screen
fill(color(200, 0, 200, 255));
stroke(color(0, 255, 0, 255));
strokeWeight(10);
rect(canvasWidth * 0.75f, canvasHeight * 0.5f, 100.0f, 100.0f);
// Restore the blue settings and draw a blue square in the bottom middle
restore();
rect(canvasWidth * 0.5f, canvasHeight * 0.65f, 100.0f, 100.0f);
// Restore the red settings and draw a red square in the bottom left
restore();
rect(canvasWidth * 0.25f, canvasHeight * 0.80f, 100.0f, 100.0f);
}