Spectrum_palette_ppxPPX extension for generating color palettes from JSON.
This library provides:
%palette "path/to/palette.json" that generates palette modulesThe 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.
(* 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)module Palette : sig ... endPalette module type and runtime utilities.
module Private : sig ... endInternal modules exposed for testing purposes.