Colors
random(exclude: list[Colors] | None = None, weights: dict[Colors, int] | None = None) -> Colors | None
#
Selects a random color, with optional exclusions and weights.
Parameters:
-
exclude
(list[Colors] | None
, default:None
) –A list of Colors to exclude from the selection.
-
weights
(dict[Colors, int] | None
, default:None
) –A dictionary mapping color members to their respective weights for weighted random selection.
Returns:
-
Colors | None
–A randomly selected color, or None if all members are excluded.
Examples:
with_opacity(opacity: int | float, color: ColorValue) -> str
#
Returns a color with the given opacity.
Parameters:
-
opacity
(int | float
) –The opacity value between
0.0
and1.0
. -
color
(ColorValue
) –The color to apply opacity to.
Returns:
Examples:
Raises:
-
AssertionError
–If the opacity is not between
0
and1
(inclusive).