跳转至

tkintertools.color.rgb

字数 169 个   代码 52 行   阅读时间 1 分钟   访问量

Support for RGB

🔵_str_to_rgba

function protected

1
2
3
4
5
def _str_to_rgba(
    color: str,
    *,
    reference: str,
) -> tuple[int, int, int]: ...
Experimental: Convert color strings(RGBA) to RGB codes

🔵_str_to_rgba

function protected

1
2
3
4
5
def _str_to_rgba(
    color: str,
    *,
    reference: str,
) -> tuple[int, int, int]: ...
Experimental: Convert color strings(RGBA) to RGB codes

🔵blend

function public

1
2
3
4
5
def blend(
    colors: list[tuple[int, int, int]],
    *,
    weights: list[tuple] | None = None,
) -> tuple[int, int, int]: ...

Mix colors by weight

  • colors: color list
  • weights: weight list

🔵contrast

function public

1
2
3
4
5
def contrast(
    rgb: tuple[int, int, int],
    *,
    channels: tuple[bool, bool, bool] = (True, True, True),
) -> tuple[int, int, int]: ...

Get a contrasting color of a color

  • rgb: a tuple, RGB codes
  • channels: three color channels

🔵convert

function public

1
2
3
4
5
6
7
def convert(
    first: tuple[int, int, int],
    second: tuple[int, int, int],
    rate: float,
    *,
    channels: tuple[bool, bool, bool] = (True, True, True),
) -> tuple[int, int, int]: ...

Convert one color to another proportionally

  • first: first color
  • second: second color
  • rate: conversion rate
  • channels: three color channels

🔵gradient

function public

1
2
3
4
5
6
7
8
9
def 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: typing.Callable[[float], float] = flat,
) -> list[tuple[int, int, int]]: ...

Get a list of color gradients from one color to another proportionally

  • first: first color
  • second: second color
  • count: number of gradients
  • rate: conversion rate
  • channels: three color channels
  • controller: control function

🔵rgb_to_str

function public

1
2
3
def rgb_to_str(
    rgb: tuple[int, int, int],
) -> str: ...
Convert RGB codes to color strings

🔵rgb_to_str

function public

1
2
3
def rgb_to_str(
    rgb: tuple[int, int, int],
) -> str: ...
Convert RGB codes to color strings

🔵str_to_rgb

function public

1
2
3
def str_to_rgb(
    color: str,
) -> tuple[int, int, int]: ...
Convert color strings to RGB codes

🔵str_to_rgb

function public

1
2
3
def str_to_rgb(
    color: str,
) -> tuple[int, int, int]: ...
Convert color strings to RGB codes

🟣MAX

constant public

MAX: tuple = (
    255, 255, 255,
)

🟣RGB

constant public

RGB: GenericAlias = tuple[int, int, int]