animator.graphics.gradient.Gradient¶
- class animator.graphics.gradient.Gradient¶
Bases:
object
Utility class for building different gradients.
- __init__()¶
Methods
Conical
(x0, y0[, start_angle])Create a conical gradient from (x0, y0) with the given start_angle (in degrees).
Linear
(x0, y0, x1, y1, /)Create a linear gradient from (x0, y0) to (x1, y1).
Radial
(x0, y0, r0[, x1, y1, r1])Create a radial gradient from (x0, y0) with radius r0 to (x1, y1) with radius r1.
__init__
()add_color_stop
(offset, color)Add a color stop at offset (between 0 and 1) with the given color.
add_colors
(*colors)Add colors evenly spaced between 0 and 1.
build
()Build the gradient.
set_tile_mode
(mode)Set the tile mode.
- classmethod Conical(x0: float, y0: float, start_angle: float = 0, /) animator.graphics.gradient.Gradient ¶
Create a conical gradient from (x0, y0) with the given start_angle (in degrees).
- classmethod Linear(x0: float, y0: float, x1: float, y1: float, /) animator.graphics.gradient.Gradient ¶
Create a linear gradient from (x0, y0) to (x1, y1).
- classmethod Radial(x0: float, y0: float, r0: float, x1: Optional[float] = None, y1: Optional[float] = None, r1: Optional[float] = None, /) animator.graphics.gradient.Gradient ¶
Create a radial gradient from (x0, y0) with radius r0 to (x1, y1) with radius r1. If x1, y1, and r1 is
None
, the gradient will be a circle.
- add_color_stop(offset: float | tuple[float, float], color: Union[animator.skia.Color4f, int, float, Sequence[float], str]) animator.graphics.gradient.Gradient ¶
Add a color stop at offset (between 0 and 1) with the given color. If offset is a tuple, the color will be added between the two points.
- add_colors(*colors: Union[animator.skia.Color4f, int, float, Sequence[float], str]) animator.graphics.gradient.Gradient ¶
Add colors evenly spaced between 0 and 1.
- abstract build() animator.skia.Shader ¶
Build the gradient. Must be implemented by subclasses.
- set_tile_mode(mode: Union[animator.skia.TileMode, Literal['clamp', 'repeat', 'mirror', 'decal']]) animator.graphics.gradient.Gradient ¶
Set the tile mode.