maliang.color.hsl¶
字数 9 个 阅读时间不到 1 分钟 访问量
Some functions about HSL codes.
函数:
-
contrast–Get the contrasting color of a HSL code.
-
transition–Transition one color to another proportionally.
-
blend–Mix colors by weight.
-
gradient–Get a list of color gradients from one color to another proportionally.
contrast ¶
contrast(
value: tuple[float, float, float], /, *, channels: tuple[bool, bool, bool] = (True, True, True)
) -> tuple[float, float, float]
Get the contrasting color of a HSL code.
value: a HSL codechannels: three color channels
transition ¶
transition(
first: tuple[float, float, float],
second: tuple[float, float, float],
rate: float,
*,
channels: tuple[bool, bool, bool] = (True, True, True)
) -> tuple[float, float, float]
Transition one color to another proportionally.
first: the first HSL codesecond: the second HSL coderate: transition ratechannels: three color channels
blend ¶
blend(
*values: tuple[float, float, float], weights: list[float] | None = None
) -> tuple[float, float, float]
Mix colors by weight.
values: HSL codesweights: weight list, default value indicates the same weights
gradient ¶
gradient(
first: tuple[float, float, float],
second: tuple[float, float, float],
count: int,
rate: float = 1,
*,
channels: tuple[bool, bool, bool] = (True, True, True),
contoller: collections.abc.Callable[[float], float] = controllers.linear
) -> list[tuple[float, float, float]]
Get a list of color gradients from one color to another proportionally.
first: the first HSL codesecond: the second HSL codecount: the number of gradientsrate: transition ratechannels: three color channelscontroller: control function