Skip to content

palettes

๐ŸŽจ palettes

A lightweight, pure-Python color palette and UI theme engine for microcontrollers, embedded displays, desktop Python, and the browser.

๐Ÿ“ฆ MIP: palettes ๐Ÿ PyPI: pydevices-palettes โšก Zero C Dependencies ๐ŸŒ MicroPython ยท CircuitPython ยท CPython ยท Direct WebAssembly ยท Pyodide

๐ŸŒˆ Color Wheels

Generate continuous color ramps and rainbow gradients with configurable saturation and hue lengths.

๐ŸŽฏ Material Design

Access standardized semantic UI palettes with shades from 50 to 900 for modern themes and widgets.

๐ŸงŠ Color Cubes

Evenly distributed 8, 27, 64, and 125 color spaces optimized for dithering and quantized graphics.

๐Ÿ”„ Byte-Swapping

First-class 16-bit RGB565 byte swapping (swapped=True) for direct SPI panel compatibility.


๐Ÿš€ Quick Install

import mip
mip.install("palettes", index="https://PyDevices.github.io/mip")
pip install -i https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ pydevices-palettes

Copy the palettes/ folder from the repository into your board's CIRCUITPY/lib/ folder.

In PyScript headers or Pyodide configurations, declare:

import micropip
await micropip.install(
    "pydevices-palettes", index_urls="https://test.pypi.org/simple/"
)

from palettes import get_palette

The wheel is named pydevices-palettes; the module you import is palettes. On MicroPython the MIP package name is palettes (mip.install("palettes", index="https://PyDevices.github.io/mip")).


๐Ÿ’ป Live Interactive Demo

Try tweaking the palette parameters below. Click โ–ถ Run to execute the code with direct MicroPython WebAssembly:

Initializing Pythonโ€ฆ

  

๐Ÿ“– Practical Usage Pattern

Construct a palette once and index it inside your application draw loop:

from palettes import get_palette

# Match the display's native color depth (16-bit RGB565)
palette = get_palette(name="wheel", color_depth=16, length=256, saturation=1.0)

# Index directly into the palette
for i in range(16):
    display_drv.fill_rect(0, i * 8, 80, 8, palette[i * 16])

If the physical display expects byte-swapped 16-bit values (common on SPI TFTs like the ST7789 or ILI9341), pass swapped=True:

palette = get_palette(name="wheel", color_depth=16, swapped=True)

Explore full-color gradient and animation applications built with palettes:

๐ŸŽจ Palettes Gallery Showcase

Interactive color visualizer exploring Material Design tokens, HSV wheels, and RGB cubes.

โ–ถ Launch Live Demo

๐Ÿชถ Rainbow Feathers

Geometric generative art rendering smooth multi-chromatic feather curves.

โ–ถ Launch Live Demo

๐Ÿ”„ Palette Rotations

Real-time palette cycling and rotational sweeps demonstrating zero-cost animations.

โ–ถ Launch Live Demo

๐Ÿ“œ Gradient Scrolling

Hardware vertical scrolling demonstration paired with high-precision palette shading.

โ–ถ Launch Live Demo


๐Ÿ“š Documentation Map

  • ๐ŸŽจ Palette Gallery โ€” Visual previews and tables for Wheel, Material Design, Cube, and Win16 palettes.
  • ๐Ÿ”ข Color Math & Formats โ€” RGB565 bit-packing, endianness swapping, and HSL/HSV math.
  • ๐Ÿงฉ Integrations โ€” Recipes for pygraphics, pdwidgets, and hardware display drivers.
  • ๐Ÿ“š API Reference โ€” Complete docstrings and class references.