Reference for push_transform
Save current transformation state. This is part of the reference section.
Arc
Buffer
Data
Dialog
Ellipse
Geo Utils
Image
Joystick (future)
Keyboard
Line
Mouse / Touchscreen
Pixel
Rectangle
Renderers
Shape
Sound (future)
Style
System
Text
Transform
push_transform
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.