batgrl.colors.gradients#
Functions for blending colors and creating color gradients.
Functions
|
Return a color that is the minimum of each channel in a and b. |
|
Return a gradient from start to end with ncolors (> 1) colors. |
|
Linear interpolation from a to b with proportion p. |
|
Return a color that is the maximum of each channel in a and b. |
|
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 and b.
- Parameters:
- aColor
A color.
- bColor
A color.
- Returns:
- Color
A color with smallest components of a and b.
- batgrl.colors.gradients.gradient(start: T, end: T, ncolors: int) list[T] #
Return a gradient from start to end with ncolors (> 1) colors.
- Parameters:
- start(Color, AColor, tuple[int, …])
Start color of gradient.
- end(Color, AColor, tuple[int, …])
End color of gradient.
- ncolorsint
Number of colors in gradient.
- Returns:
- list[(Color, AColor, tuple[int, …])]
A gradient of colors from start to end.
- 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 byalpha
.
- Returns:
- list[Color | AColor]
A rainbow gradient of colors.