|
| 1 | +import re |
| 2 | +from collections.abc import Callable, Generator, Hashable |
| 3 | +from typing import Any, overload |
| 4 | +from typing_extensions import Self |
| 5 | + |
| 6 | +FLOAT_ERROR: float = 0.0000005 |
| 7 | + |
| 8 | +RGB_TO_COLOR_NAMES: dict[tuple[int, int, int], list[str]] |
| 9 | + |
| 10 | +COLOR_NAME_TO_RGB: dict[list[str], tuple[int, int, int]] |
| 11 | + |
| 12 | +LONG_HEX_COLOR: re.Pattern[str] |
| 13 | +SHORT_HEX_COLOR: re.Pattern[str] |
| 14 | + |
| 15 | +class C_HSL: |
| 16 | + def __getattr__(self, value: str) -> tuple[float, float, float]: ... |
| 17 | + |
| 18 | +class C_RGB: |
| 19 | + def __getattr__(self, value: str) -> tuple[float, float, float]: ... |
| 20 | + |
| 21 | +class C_HEX: |
| 22 | + def __getattr__(self, value: str) -> str: ... |
| 23 | + |
| 24 | +HSL: C_HSL |
| 25 | +RGB: C_RGB |
| 26 | +HEX: C_HEX |
| 27 | + |
| 28 | +def hsl2rgb(hsl: tuple[float, float, float]) -> tuple[float, float, float]: ... |
| 29 | +def rgb2hsl(rgb: tuple[float, float, float]) -> tuple[float, float, float]: ... |
| 30 | +def _hue2rgb(v1: float, v2: float, vH: float) -> float: ... |
| 31 | +def rgb2hex(rgb: tuple[float, float, float], force_long: bool = False) -> str: ... |
| 32 | +def hex2rgb(str_rgb: str) -> tuple[float, float, float]: ... |
| 33 | +def hex2web(hex: str) -> str: ... |
| 34 | +def web2hex(web: str, force_long: bool = False) -> str: ... |
| 35 | + |
| 36 | +hsl2hex: Callable[[tuple[float, float, float]], str] |
| 37 | +hex2hsl: Callable[[str], tuple[float, float, float]] |
| 38 | +rgb2web: Callable[[tuple[float, float, float]], str] |
| 39 | +web2rgb: Callable[[str], tuple[float, float, float]] |
| 40 | +web2hsl: Callable[[str], tuple[float, float, float]] |
| 41 | +hsl2web: Callable[[tuple[float, float, float]], str] |
| 42 | + |
| 43 | +def color_scale( |
| 44 | + begin_hsl: tuple[float, float, float], end_hsl: tuple[float, float, float], nb: int |
| 45 | +) -> tuple[float, float, float]: ... |
| 46 | +def RGB_color_picker(obj: Any) -> Color: ... |
| 47 | + |
| 48 | +@overload |
| 49 | +def hash_or_str(obj: Hashable) -> int: ... |
| 50 | +@overload |
| 51 | +def hash_or_str(obj: object) -> str: ... # type: ignore[overload-cannot-match] |
| 52 | + |
| 53 | +class Color: |
| 54 | + def __init__( |
| 55 | + self, |
| 56 | + color: Self | str | None = None, |
| 57 | + pick_for: object | None = None, |
| 58 | + picker: Callable[[object], Color] = ..., |
| 59 | + pick_key: Callable[[object], int | str] = ..., |
| 60 | + **kwargs: Any, |
| 61 | + ) -> None: ... |
| 62 | + def __getattr__(self, label: str) -> Any: ... |
| 63 | + def __setattr__(self, label: str, value: Any) -> None: ... |
| 64 | + def get_hsl(self) -> tuple[float, float, float]: ... |
| 65 | + def get_hex(self) -> str: ... |
| 66 | + def get_hex_l(self) -> str: ... |
| 67 | + def get_rgb(self) -> tuple[float, float, float]: ... |
| 68 | + def get_hue(self) -> float: ... |
| 69 | + def get_saturation(self) -> float: ... |
| 70 | + def get_luminance(self) -> float: ... |
| 71 | + def get_red(self) -> float: ... |
| 72 | + def get_green(self) -> float: ... |
| 73 | + def get_blue(self) -> float: ... |
| 74 | + def get_web(self) -> str: ... |
| 75 | + def set_hsl(self, value: float) -> None: ... |
| 76 | + def set_rgb(self, value: float) -> None: ... |
| 77 | + def set_hue(self, value: float) -> None: ... |
| 78 | + def set_saturation(self, value: float) -> None: ... |
| 79 | + def set_luminance(self, value: float) -> None: ... |
| 80 | + def set_red(self, value: float) -> None: ... |
| 81 | + def set_green(self, value: float) -> None: ... |
| 82 | + def set_blue(self, value: float) -> None: ... |
| 83 | + def set_hex(self, value: str) -> None: ... |
| 84 | + |
| 85 | + set_hex_l: Callable[[str], None] = ... |
| 86 | + |
| 87 | + def set_web(self, value: str) -> None: ... |
| 88 | + def range_to(self, value: str | Color | None, steps: int) -> Generator[Color]: ... |
| 89 | + def __eq__(self, other: object) -> bool | type[NotImplemented]: ... # type: ignore[override, valid-type] # pyright: ignore[reportInvalidTypeForm] |
| 90 | + |
| 91 | +RGB_equivalence: Callable[[Color, Color], bool] |
| 92 | +HSL_equivalence: Callable[[Color, Color], bool] |
| 93 | + |
| 94 | +def make_color_factory( |
| 95 | + **kwargs_defaults: Any, |
| 96 | +) -> Callable[ |
| 97 | + [Color | str | None, object | None, Callable[[object], Color], object | None, Callable[[object], int | str]], Color |
| 98 | +]: ... |
0 commit comments