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

Save current styling. This is part of the reference section.

Purpose

Save current sketch styling to the style 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 style configuration in the sketch unchanged.

Snippet

Save a green fill and restore it later to draw a green rectangle.
sketch.set_fill('#00C000')  # Set fill to green
sketch.push_style()  # Save the current styling
sketch.set_fill('#C00000')  # Set it to red
sketch.pop_style()  # Restore saved styling so fill is green again
sketch.rect(50, 100, 150, 200)

Examples

Availability

Available on all platforms.

See also