batgrl.colors.gradients#
Functions for blending colors and creating color gradients.
Functions
|
Return a color that is the minimum of each channel in |
|
Return a smooth gradient of length |
|
Linear interpolation from |
|
Return a color that is the maximum of each channel in |
|
Return a rainbow gradient of |
- batgrl.colors.gradients.darken_only(a: Color, b: Color) Color #
Return a color that is the minimum of each channel in
a
andb
.- Parameters:
- aColor
A color.
- bColor
A color.
- Returns:
- Color
A color with smallest components of
a
andb
.
- 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 incolor_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
tob
with proportionp
.- 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
andb
.
- batgrl.colors.gradients.lighten_only(a: Color, b: Color) Color #
Return a color that is the maximum of each channel in
a
andb
.- Parameters:
- aColor
A color.
- bColor
A color.
- Returns:
- Color
A color with largest components of
a
andb
.
- 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 byalpha
.
- Returns:
- list[Color | AColor]
A rainbow gradient of colors.