palettes
August 23, 2026 ยท View on GitHub
๐ 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
=== "MicroPython (MIP)"
```python
import mip
mip.install("palettes", index="https://PyDevices.github.io/mip")
```
=== "CPython (TestPyPI)"
```bash
pip install -i https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple/ pydevices-palettes
```
=== "CircuitPython"
Copy the `palettes/` folder from the repository into your board's `CIRCUITPY/lib/` folder.
=== "PyScript / Pyodide"
In PyScript headers or Pyodide configurations, declare:
```python
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:
display = AutoDisplay(width=320, height=240, canvas_id=CANVAS_ID) display.fill(0x1082)
Generate a 256-color wheel palette
palette = get_palette("wheel", color_depth=16, length=256, saturation=1.0)
Draw vertical color bars
bar_width = display.width // 32 for i in range(32): color = palette[i * 8] display.fill_rect(i * bar_width, 20, bar_width, 100, color)
Material Design amber ramp
md = get_palette("material_design", color_depth=16) shades = [ md.AMBER_S50, md.AMBER_S100, md.AMBER_S200, md.AMBER_S300, md.AMBER_S400, md.AMBER_S500, md.AMBER_S600, md.AMBER_S700, md.AMBER_S800, md.AMBER_S900 ] for i, color in enumerate(shades): display.fill_rect(i * 30 + 10, 140, 26, 60, color)
display.show() print("Drawn 32 color wheel bands and 10 Material Design amber shades!")
๐ 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)
๐ฎ Featured Browser Demos
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.
๐ชถ Rainbow Feathers
Geometric generative art rendering smooth multi-chromatic feather curves.
๐ Palette Rotations
Real-time palette cycling and rotational sweeps demonstrating zero-cost animations.
๐ Gradient Scrolling
Hardware vertical scrolling demonstration paired with high-precision palette shading.
๐ 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.