pop_style()

The push_style() function saves the current style settings and pop_style() restores the prior settings; these functions are always used together.

Examples

example picture for pop_style()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
def setup():
    py5.ellipse(0, 50, 33, 33)  # left circle

    py5.push_style()  # start a new style
    py5.stroke_weight(10)
    py5.fill(204, 153, 0)
    py5.ellipse(50, 50, 33, 33)  # middle circle
    py5.pop_style()  # restore original style

    py5.ellipse(100, 50, 33, 33)  # right circle
example picture for pop_style()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def setup():
    py5.ellipse(0, 50, 33, 33)  # left circle

    py5.push_style()  # start a new style
    py5.stroke_weight(10)
    py5.fill(204, 153, 0)
    py5.ellipse(33, 50, 33, 33)  # left-middle circle

    py5.push_style()  # start another new style
    py5.stroke(0, 102, 153)
    py5.ellipse(66, 50, 33, 33)  # right-middle circle
    py5.pop_style()  # restore the previous style

    py5.pop_style()  # restore original style

    py5.ellipse(100, 50, 33, 33)  # right circle

Description

The push_style() function saves the current style settings and pop_style() restores the prior settings; these functions are always used together. They allow you to change the style settings and later return to what you had. When a new style is started with push_style(), it builds on the current style information. The push_style() and pop_style() method pairs can be nested to provide more control (see the second example for a demonstration.)

Underlying Java method: popStyle

Syntax

pop_style() -> None

Updated on September 11, 2021 16:51:34pm UTC