Color.Gamut.SVG
(Color v0.11.0)
Copy Markdown
Renders a chromaticity diagram — the horseshoe, gamut triangles, Planckian locus, and optional palette / seed overlays — as a self-contained SVG string.
The heavy lifting (spectral-locus points, working-space
triangle vertices, Planckian coordinates) is done by
Color.Gamut.Diagram; this module wraps that data in a
complete, styleable SVG.
Useful when you want to embed a chromaticity diagram in a
design-system docs page, a README, an exported PDF, or any
tool that speaks SVG. The same renderer is used by the
/gamut tab of Color.Palette.Visualizer.
Example
iex> svg = Color.Gamut.SVG.render(projection: :uv, gamuts: [:SRGB, :P3_D65])
iex> String.starts_with?(svg, "<svg viewBox=")
true
Summary
Functions
Renders the diagram as an SVG binary.
Functions
Renders the diagram as an SVG binary.
Options
:projectionis:uv(default) or:xy.:gamutsis a list of working-space atoms to overlay as triangles. Default[:SRGB, :P3_D65]. Pass[]to render no triangles.:planckian— whentrue(defaultfalse), draws the Planckian locus from 1500 K to 20 000 K with annotation points at 2000, 2700, 4000, 6500, and 10 000 K.:seed— anyColor.input(). When provided, a labelled dot is plotted at the colour's chromaticity.:palette— aColor.Palette.TonalorColor.Palette.ContrastScalestruct. When provided, every stop is plotted as a coloured circle with a<title>giving its label and hex. The seed stop is drawn slightly larger.:width,:height— SVG viewport dimensions. Defaults 800 × 700. The inline CSS of the embedding page can scale this withwidth: 100%.:gamut_colours— a map ofworking_space_atom => hexoverriding the default outline colour for specific spaces.
Returns
- A binary containing a self-contained
<svg>…</svg>element.
Examples
iex> svg = Color.Gamut.SVG.render(projection: :xy)
iex> String.contains?(svg, "Chromaticity not shown directly") or String.contains?(svg, "polygon")
true
iex> palette = Color.Palette.Tonal.new("#3b82f6")
iex> svg = Color.Gamut.SVG.render(palette: palette, seed: "#3b82f6")
iex> String.contains?(svg, "<title>500:")
true