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