batgrl.colors.gradients#

Functions for blending colors and creating color gradients.

Functions

darken_only(a, b)

Return a color that is the minimum of each channel in a and b.

gradient(*color_stops, n[, easing])

Return a smooth gradient of length n between all colors in color_stops.

lerp_colors(a, b, p)

Linear interpolation from a to b with proportion p.

lighten_only(a, b)

Return a color that is the maximum of each channel in a and b.

rainbow_gradient(n, *[, alpha])

Return a rainbow gradient of n colors.

batgrl.colors.gradients.darken_only(a: Color, b: Color) Color#

Return a color that is the minimum of each channel in a and b.

Parameters:
aColor

A color.

bColor

A color.

Returns:
Color

A color with smallest components of a and b.

batgrl.colors.gradients.gradient(*color_stops: T, n: int, easing: Literal['linear', 'in_quad', 'out_quad', 'in_out_quad', 'in_cubic', 'out_cubic', 'in_out_cubic', 'in_quart', 'out_quart', 'in_out_quart', 'in_quint', 'out_quint', 'in_out_quint', 'in_sine', 'out_sine', 'in_out_sine', 'in_exp', 'out_exp', 'in_out_exp', 'in_circ', 'out_circ', 'in_out_circ', 'in_elastic', 'out_elastic', 'in_out_elastic', 'in_back', 'out_back', 'in_out_back', 'in_bounce', 'out_bounce', 'in_out_bounce'] = 'linear') list[T]#

Return a smooth gradient of length n between all colors in color_stops.

Parameters:
*color_stops(Color, AColor, tuple[int, …])

Colors between each gradient.

nint

Length of gradient. Must be equal to or larger than color_stops.

easingEasing, default: “linear”

Easing applied to interpolations between color stops.

Returns:
list[(Color, AColor, tuple[int, …])]

A smooth gradient between all colors in color_stops.

batgrl.colors.gradients.lerp_colors(a: T, b: T, p: float) T#

Linear interpolation from a to b with proportion p.

Parameters:
a(Color, AColor, tuple[int, …])

A color.

b(Color, AColor, tuple[int, …])

A color.

pfloat

Proportion from a to b.

Returns:
(Color, AColor, tuple[int, …])

The linear interpolation of a and b.

batgrl.colors.gradients.lighten_only(a: Color, b: Color) Color#

Return a color that is the maximum of each channel in a and b.

Parameters:
aColor

A color.

bColor

A color.

Returns:
Color

A color with largest components of a and b.

batgrl.colors.gradients.rainbow_gradient(n: int, *, alpha: int | None = None) list[Color | AColor]#

Return a rainbow gradient of n colors.

Parameters:
nint

Number of colors in gradient.

alphaint | None, default: None

If alpha is not given, gradient colors will have no alpha channel. Otherwise, the color’s alpha channel is given by alpha.

Returns:
list[Color | AColor]

A rainbow gradient of colors.