🧪 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 push_transform

Save current transformation state. This is part of the reference section.

Purpose

Save current sketch transformation state to the matrix history. This works as a stack (like a stack of plates) where this puts a new plate on the top of the pile. This will leave the current transformation matrix in the sketch unchanged.

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