Skip to main content

PaintLinearGradient

PaintLinearGradient class has the following properties:

begin

An instance of Offset. The offset at which stop 0.0 of the gradient is placed.

colors

The colors the gradient should obtain at each of the stops. This list must contain at least two colors.

If stops is provided, this list must have the same length as stops.

end

An instance of Offset. The offset at which stop 1.0 of the gradient is placed.

stops

A list of values from 0.0 to 1.0 that denote fractions along the gradient.

If provided, this list must have the same length as colors. If the first value is not 0.0, then a stop with position 0.0 and a color equal to the first color in colors is implied. If the last value is not 1.0, then a stop with position 1.0 and a color equal to the last color in colors is implied.

tile_mode

How this gradient should tile the plane beyond in the region before begin and after end. The value is GradientTileMode enum with supported values: CLAMP (default), DECAL, MIRROR, REPEATED. More info here.

rotation

Rotation for the gradient, in radians, around the center-point of its bounding box.

More information on Linear gradient here.

Usage example

cv.Rect(
10,
10,
100,
100,
5,
ft.Paint(
gradient=ft.PaintLinearGradient(
(0, 10), (0, 100), colors=[ft.Colors.BLUE, ft.Colors.YELLOW]
),
style=ft.PaintingStyle.FILL,
),
)