from the reference "The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system."
look at the examples on the reference pages
http://processing.org/reference/pushMatrix_.htmlhttp://processing.org/reference/popMatrix_.htmlbasically it means, someone correct me if i'm wrong.
you reset the coordinates of back to whatever the previous transformation was, and if there weren't any, it would revert back to (0,0)
examples.
-----
if you want to move a shape over 10 pixels you would do it like this:
Code:
translate(10,0);
rect(0,0, 20,20);
now your shape has moved 10 pixels to the right.
----
however let's say you have two shapes and you want the first one to move 10 pxiels to the right of the origin point and the second one to move 10 pixels to the left of the origin point
you could do it like this
Code:
translate(10,0);
rect(0,0, 20,20);
translate(-20,0);
rect(0,20, 20,20);
however, if you were to do this you would just undo the first translate, (as opposed to moving the second shape to the left 10 pixels), back to the origin point.
Code:
translate(10,0); //set the X translate to 10 pixels right
rect(0,0, 20,20);
translate(-10,0); //just reset the X translate to 0
rect(0,20, 20,20);
but if you were to the same thing using pushMatrix() and popMatrix() you'll see that our second shape is now left of the origin by 10 pixels
Code:
pushMatrix();
translate(10,0); //move shpae right 10 pixels
rect(0,0, 20,20);
popMatrix(); //reset coordinates
translate(-10,0); //move shape left 10 pixels
rect(0,20, 20,20);
make sense?
Ken