[ Web Proxy ]
URL:
Viewing: https://processing.org/reference/pushMatrix_.html [Back]  [Original]

pushMatrix() / Reference / Processing.org
Skip to main content

Name

pushMatrix()

Description

Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() 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 thetransformations.

Examples

  • Copy
    size(400, 400);
    
    fill(255);
    rect(0, 0, 200, 200);  // White rectangle
    
    pushMatrix();
    translate(120, 80);
    fill(0);  
    rect(0, 0, 200, 200);  // Black rectangle
    popMatrix();
    
    fill(100);  
    rect(60, 40, 200, 200);  // Gray rectangle

Syntax

  • pushMatrix()

Return

  • void

Web Proxy Viewer  |  New URL  |  Original Page