Py5Shape.set_fill()
Contents
Py5Shape.set_fill()¶
The set_fill()
method defines the fill color of a Py5Shape
.
Examples¶
1 2 3 4 5 6 7 8 9 10 11 12 | def setup():
global c
py5.size(640, 360, py5.P2D)
c = py5.create_shape(py5.RECT, -20, -20, 40, 40)
c.set_stroke("#FFFFFF")
def draw():
py5.background(51)
c.set_fill(py5.color(py5.random_int(255)))
py5.translate(py5.mouse_x, py5.mouse_y)
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