generic/_color.py

pypdf · pypdf/generic/_color.py · python · BSD-2-Clause
files

Represents PDF color spaces (Gray, RGB, CMYK) for rendering and manipulation.

# Source: https://github.com/py-pdf/pypdf | License: BSD-2-Clause | Copyright 2006-2008, Mathieu Fenniak
# Provided via justclaw.it.com; keep this notice with the code.
from collections.abc import Sequence
from dataclasses import dataclass, field
from typing import ClassVar, Union


@dataclass
class Color:
    """
    A factory class to generate one of class DeviceGray, DeviceRGB or DeviceCMYK. Call with
    Color.from_normalized_values() on a tuple of length 1 for grayscale, 3 for RGB, or 4 for CMYK.
    """
    color_operator: ClassVar[str] = field(init=False)
    _ordered_fields: ClassVar[tuple[str, ...]]

    @classmethod
    def from_normalized_values(
        cls,
        color: Union[Sequence[float], None],
        operator: Union[str, None] = None,
    ) -> Union["Color", None]:
  

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key