🧪 Version 0.2.2 is our alpha release candidate. Please send us bug reports and suggestions!

Sketchingpy

Creative coding and interactive science everywhere for everyone: web, desktop, mobile, Jupyter, and more. Open source!

Reference for pop_transform

Restore a previously saved transformation state. This is part of the reference section.

Purpose

Restore the most recently transformation configuration saved in matrix history, removing that "transform matrix" from the history. This works as a stack (like a stack of plates) where the top of the pile is taken off and restored, removing it from that stack. This will overwrite the current transformation configuration in the sketch.

Snippet

Push and pop the transformation matrix such that things are translated by 50 pixels to the right.
sketch.translate(50, 0)  # Translate 50 pixels to the right
sketch.push_transform()  # Save the current transformation matrix
sketch.translate(50, 0)  # Translate so now 150 (50 + 100) pixels to the right
sketch.pop_transform()  # Restore saved matrix so we are 50 pixels to the right again
sketch.rect(0, 250, 150, 200)  # Draw the rectangle at an offset position of 50, 250.

Examples

Availability

Available on all platforms.

See also