Skip to content

Gradient

GradientColorStop

A single color stop in a gradient.

Each stop defines a color at a specific position along the gradient. The midpoint controls the interpolation bias between this stop and the next.

Attributes

color

color = _GradientField()

RGB color as (red, green, blue) with values 0.0 to 1.0.

midpoint

midpoint = _GradientField()

Interpolation midpoint to next stop (0.0 to 1.0).

offset

offset = _GradientField()

Position along the gradient (0.0 to 1.0).

GradientAlphaStop

A single alpha (opacity) stop in a gradient.

Each stop defines an opacity at a specific position along the gradient.

Attributes

alpha

alpha = _GradientField()

Opacity value (0.0 to 1.0).

midpoint

midpoint = _GradientField()

Interpolation midpoint to next stop (0.0 to 1.0).

offset

offset = _GradientField()

Position along the gradient (0.0 to 1.0).

Gradient

Parsed gradient color data from a gradient fill/stroke property.

Contains ordered lists of color stops and alpha stops that define the gradient appearance.

Attributes

alpha_stops

alpha_stops: tuple[GradientAlphaStop, ...]

Ordered alpha stops defining opacity along the gradient.

color_stops

color_stops: tuple[GradientColorStop, ...]

Ordered color stops defining the gradient.

version

version = _GradientField()

Gradient data format version.

Functions

add_alpha_stop

add_alpha_stop(
    offset: float, midpoint: float, alpha: float
) -> None

Add an alpha stop.

add_color_stop

add_color_stop(
    offset: float,
    midpoint: float,
    color: tuple[float, float, float],
) -> None

Add a color stop.

remove_alpha_stop

remove_alpha_stop(stop: int) -> None

Remove an alpha stop by index.

remove_color_stop

remove_color_stop(stop: int) -> None

Remove a color stop by index.