pypindou.color.resources

Built-in palette resource loading.

The packaged palettes.json file is generated from domestic and international submodules by make resource. Runtime code should load palettes through this module instead of reading the resource file directly.

Example:

>>> from pypindou.color.resources import list_palettes
>>> isinstance(list_palettes(), list)
True

list_palettes

pypindou.color.resources.list_palettes()[源代码]

List built-in palettes.

返回:

Summary dictionaries for packaged palettes.

返回类型:

List[Dict[str, Any]]

load_palette

pypindou.color.resources.load_palette(palette_id, *, allow_unidentified=False)[源代码]

Load a built-in palette by id.

参数:
  • palette_id (str) -- Built-in palette id.

  • allow_unidentified (bool, optional) -- Whether to include colors marked unidentified, defaults to False.

返回:

Loaded palette.

返回类型:

pypindou.color.Palette

抛出:

KeyError -- If palette_id is unknown.

get_palette

pypindou.color.resources.get_palette(palette, *, include_codes=None, exclude_codes=None, allow_unidentified=False, max_colors=None)[源代码]

Resolve and optionally filter a palette.

参数:
  • palette (Union[str, pypindou.color.Palette]) -- Built-in palette id or explicit palette object.

  • include_codes (Optional[Iterable[str]], optional) -- Optional allow-list of color codes.

  • exclude_codes (Optional[Iterable[str]], optional) -- Optional deny-list of color codes.

  • allow_unidentified (bool, optional) -- Whether to include colors marked unidentified, defaults to False.

  • max_colors (Optional[int], optional) -- Optional leading color count after filtering.

返回:

Resolved palette.

返回类型:

pypindou.color.Palette