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