package spectrum_palette_ppx

  1. Overview
  2. Docs

Module Spectrum_palette_ppxSource

PPX extension for generating color palettes from JSON.

This library provides:

  • A PPX extension %palette "path/to/palette.json" that generates palette modules
  • Runtime types and utilities for working with generated palettes

The PPX extension reads JSON palette definitions and generates OCaml modules implementing the Palette.M signature with efficient nearest-color lookup using octree-based spatial indexing in LAB color space.

Example Usage

  (* Define a palette from JSON *)
  module MyPalette : Palette.M = [%palette "colors.json"]

  (* Use the generated palette *)
  let red = MyPalette.of_string "red"
  let code = MyPalette.to_code red
  let nearest = MyPalette.nearest (Gg.Color.v 0.5 0.3 0.7 1.0)
Sourcemodule Palette : sig ... end

Palette module type and runtime utilities.

Sourcemodule Private : sig ... end

Internal modules exposed for testing purposes.