跳转至

maliang.color.hsl

字数 9 个   阅读时间不到 1 分钟   访问量

源代码:maliang/color/hsl.py

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 code
  • channels: 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 code
  • second: the second HSL code
  • rate: transition rate
  • channels: 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 codes
  • weights: 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 code
  • second: the second HSL code
  • count: the number of gradients
  • rate: transition rate
  • channels: three color channels
  • controller: control function