Py5Shape.set_fill()#

The set_fill() method defines the fill color of a Py5Shape.

Examples#

 1def setup():
 2    global c
 3    py5.size(640, 360, py5.P2D)
 4    c = py5.create_shape(py5.RECT, -20, -20, 40, 40)
 5    c.set_stroke("#FFFFFF")
 6
 7
 8def draw():
 9    py5.background(51)
10    c.set_fill(py5.color(py5.random_int(255)))
11    py5.translate(py5.mouse_x, py5.mouse_y)
12    py5.shape(c)

Description#

The set_fill() method defines the fill color of a Py5Shape. This method is used after shapes are created or when a shape is defined explicitly (e.g. create_shape(RECT, 20, 20, 60, 60)) as shown in the example. When a shape is created with Py5Shape.begin_shape() and Py5Shape.end_shape(), its attributes may be changed with Py5Shape.fill() and Py5Shape.stroke() between the calls to Py5Shape.begin_shape() and Py5Shape.end_shape(). However, after the shape is created, only the set_fill() method can define a new fill value for the Py5Shape.

Underlying Processing method: PShape.setFill

Syntax#

set_fill(fill: bool, /) -> None
set_fill(fill: int, /) -> None
set_fill(index: int, fill: int, /) -> None

Parameters#

  • fill: bool - allow fill

  • fill: int - any color value

  • index: int - vertex index

Updated on March 22, 2022 21:53:01pm UTC