popMatrix()

Examples

popMatrix() example
void draw() {
  stroke(BLACK);

  fill(WHITE);
  rect(0, 0, 50, 50);  // White rectangle

  pushMatrix();
  translate(30, 20);
  fill(BLACK);
  rect(0, 0, 50, 50);  // Black rectangle
  popMatrix();

  fill(WHITE);
  rect(60, 40, 50, 50);  // White rectangle
}

Description

Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in conjunction with the other transformation functions and may be embedded to control the scope of the transformations.

Syntax

popMatrix()

Returns

void

Related

pushMatrix()
translate()
rotate()

Back to index