跳转至

maliang.color

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

源代码:maliang/color/__init__.py

A subpackage that provides color-related features.

Supports the processing of color strings in RGB and HSL formats, as well as the conversion between color names and color codes.

模块:

  • colortable

    Mapping table between the color names and the RGB codes.

  • convert

    Convert a format of color to another format.

  • hsl

    Some functions about HSL codes.

  • rgb

    Some functions about RGB codes.

函数:

  • rgb_to_hex

    Convert a RGB code to a hexadecimal code.

  • hex_to_rgb

    Convert a hexadecimal code to a RGB code.

  • rgba_to_hex

    Convert a RGBA code to a hexadecimal code.

  • hex_to_rgba

    Convert a hexadecimal code to a RGBA code.

  • hsl_to_rgb

    Convert a HSL code to a RGB code.

  • rgb_to_hsl

    Convert a RGB code to a HSL code.

  • hsl_to_hex

    Convert a HSL code to a hexadecimal code.

  • hex_to_hsl

    Convert a hexadecimal code to a HSL code.

  • name_to_rgb

    Convert a color name to a RGB code.

  • rgb_to_name

    Convert a RGB code to a color name.

  • name_to_hex

    Convert a color name to a hexadecimal code.

  • hex_to_name

    Convert a hexadecimal code to a color name.

  • fix_hex_length

    Fix the length of a hexadecimal code.

  • str_to_rgb

    Convert a color name or a hexadecimal code to a RGB code.

rgb_to_hex

rgb_to_hex(value: tuple[int, int, int]) -> str

Convert a RGB code to a hexadecimal code.

  • value: a RGB code

hex_to_rgb

hex_to_rgb(value: str) -> tuple[int, int, int]

Convert a hexadecimal code to a RGB code.

  • value: a hexadecimal code

rgba_to_hex

rgba_to_hex(value: tuple[int, int, int, float]) -> str

Convert a RGBA code to a hexadecimal code.

  • value: a RGBA code

hex_to_rgba

hex_to_rgba(value: str) -> tuple[int, int, int, float]

Convert a hexadecimal code to a RGBA code.

  • value: a hexadecimal code

hsl_to_rgb

hsl_to_rgb(value: tuple[float, float, float]) -> tuple[int, int, int]

Convert a HSL code to a RGB code.

  • value: a HSL code

rgb_to_hsl

rgb_to_hsl(value: tuple[int, int, int]) -> tuple[float, float, float]

Convert a RGB code to a HSL code.

  • value: a RGB code

hsl_to_hex

hsl_to_hex(value: tuple[float, float, float]) -> str

Convert a HSL code to a hexadecimal code.

  • value: a HSL code

hex_to_hsl

hex_to_hsl(value: str) -> tuple[float, float, float]

Convert a hexadecimal code to a HSL code.

  • value: a hexadecimal code

name_to_rgb

name_to_rgb(value: str) -> tuple[int, int, int]

Convert a color name to a RGB code.

  • value: a color name

rgb_to_name

rgb_to_name(value: tuple[int, int, int]) -> list[str]

Convert a RGB code to a color name.

  • value: a RGB code

name_to_hex

name_to_hex(value: str) -> str

Convert a color name to a hexadecimal code.

  • value: a color name

hex_to_name

hex_to_name(value: str) -> list[str]

Convert a hexadecimal code to a color name.

  • value: a hexadecimal code

fix_hex_length

fix_hex_length(value: str) -> str

Fix the length of a hexadecimal code.

  • value: a hexadecimal code

str_to_rgb

str_to_rgb(value: str) -> tuple[int, int, int]

Convert a color name or a hexadecimal code to a RGB code.

  • value: a color name or a hexadecimal code