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