palettes.cube

RGB color-cube palettes.

Samples the RGB cube at evenly spaced points. Supported cube sizes are 2, 3, 4, and 5 (8, 27, 64, or 125 colors). Each size uses a built-in name table for color_name.

Example

>>> from palettes import get_palette
>>> palette = get_palette(name="cube", size=5, color_depth=16)
>>> len(palette)
125
class palettes.cube.CubePalette(name='', color_depth=16, swapped=False, cached=True, size=5)[source]

Bases: Palette

Evenly spaced RGB cube palette.

This palette is useful when you want a finite, evenly distributed set of colors rather than a continuous ramp. It is common for simple color pickers, indicator sets, or status themes where a small number of distinct colors is better than a smooth gradient.

Indices traverse the cube in x, then y, then z order. Channel values are spaced from 0 to 255 inclusive.

Parameters:
  • name (str) – Prefix for name (length suffix is added).

  • color_depth (int) – Output format; see Palette.

  • swapped (bool) – Byte-swap 16-bit colors when True.

  • cached (bool) – Memoize index lookups when True (default).

  • size (int) – Cube edge length. Must be 2, 3, 4, or 5.