textual-paint/typings/ochre/spaces.pyi
2023-05-09 16:58:25 -04:00

188 lines
4.2 KiB
Python

"""
This type stub file was generated by pyright.
"""
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Iterable, Iterator, Text, TypeVar, Union
"""Objects representing colors in different color spaces."""
C = TypeVar("C", bound="Color")
class Color(ABC, Iterable[float]):
"""Abstract base class for color spaces."""
@property
@abstractmethod
def rgb(self) -> RGB:
"""Return the color as an RGB object."""
...
@property
def hex(self) -> Hex:
"""Return the color as an Hex object."""
...
@property
def web_color(self) -> WebColor:
"""Return the color as a WebColor object."""
...
@property
def ansi256(self) -> Ansi256:
"""Return the color as an Ansi256 object."""
...
@property
def hcl(self) -> HCL:
"""Return the color as an HCL object."""
...
def __index__(self) -> int:
"""Return the index of the color as an hexadecimal integer."""
...
def __eq__(self, other: object) -> bool:
"""Return True if the colors are almost equal in RGB space."""
...
def __hash__(self) -> int:
"""Return the hash of the color."""
...
def __iter__(self) -> Iterator[float]:
"""Return an iterator over the color's RGB channels."""
...
def distance(self, other: Color) -> float:
"""Return the distance between colors in the HCL color space."""
...
def closest(self, colors: Iterable[C]) -> C:
"""Find the color in the given list that is closest to this color."""
...
@dataclass(frozen=True, eq=False)
class RGB(Color):
"""An RGB color."""
red: float
green: float
blue: float
N_DIGITS = ...
def __post_init__(self) -> None:
"""Round the RGB channels."""
...
@property
def rgb(self) -> RGB:
"""Return the color as an RGB object."""
...
@property
def hex(self) -> Hex:
"""Return the color as an Hex object."""
...
@property
def web_color(self) -> WebColor:
"""Return the color as a WebColor object."""
...
@property
def ansi256(self) -> Ansi256:
"""Return the color as an Ansi256 object."""
...
@property
def hcl(self) -> HCL:
"""Return the color as an HCL object."""
...
@dataclass(frozen=True, eq=False)
class Hex(Color):
"""A color represented by a hexadecimal integer."""
hex_code: Union[int, Text]
def __repr__(self) -> Text:
"""Return a string representation of the color."""
...
@property
def rgb(self) -> RGB:
"""Return the color as an RGB object."""
...
@property
def hex(self) -> Hex:
"""Return the color as an Hex object."""
...
@dataclass(frozen=True, eq=False)
class WebColor(Color):
"""A color represented by a name."""
name: Text
NORM_PATTERN = ...
def __post_init__(self) -> None:
"""Normalize the name of the color."""
...
@property
def rgb(self) -> RGB:
"""Return the color as an RGB object."""
...
@property
def hex(self) -> Hex:
"""Return the color as an Hex object."""
...
@property
def web_color(self) -> WebColor:
"""Return the color as a WebColor object."""
...
@dataclass(frozen=True, eq=False)
class Ansi256(Color):
"""A color represented by an integer between 0 and 255."""
code: int
@property
def rgb(self) -> RGB:
"""Return the color as an RGB object."""
...
@property
def hex(self) -> Hex:
"""Return the color as an Hex object."""
...
@property
def ansi256(self) -> Ansi256:
"""Return the color as an Ansi256 object."""
...
@dataclass(frozen=True, eq=False)
class HCL(Color):
"""An HCL color."""
hue: float
chroma: float
luminance: float
@property
def rgb(self) -> RGB:
"""Return the color as an RGB object."""
...
@property
def hcl(self) -> HCL:
"""Return the color as an HCL object."""
...