Skip to content

Commit dbf4cf3

Browse files
committed
feat: updated color palettes
1 parent 24d0695 commit dbf4cf3

4 files changed

Lines changed: 237 additions & 92 deletions

File tree

CHANGELOG.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [Unreleased]
2+
3+
- Updated color palettes
4+
15
## 0.51.0 _2026-02-14_
26

37
### Colors
@@ -14,29 +18,29 @@
1418
using OKLCh color space with shorter-arc hue interpolation. Includes 8
1519
sequential palettes (viridis, inferno, magma, plasma, cividis, turbo, rocket,
1620
mako), 6 categorical palettes (graph6, spectrum6, spectrum12, tableau10,
17-
tycho11, kelly22), and 12 diverging palettes (roma, vik, broc, rdbu,
18-
coolwarm, ocean-balance, plus reversed variants).
21+
tycho11, kelly22), and 12 diverging palettes (roma, vik, broc, rdbu, coolwarm,
22+
ocean-balance, plus reversed variants).
1923
- **`ColorToColorspace`**: Convert an sRGB color (string or `Tuple`) to
2024
components in `"rgb"`, `"hsl"`, `"oklch"`, or `"oklab"` (alias `"lab"`).
2125
Preserves alpha when present.
2226
- **`ColorFromColorspace`**: Convert color space components back to a canonical
2327
sRGB `Tuple`. Accepts the same color space names as `ColorToColorspace`.
2428
- **`ColorToString`**: Convert a color (string or sRGB `Tuple`) to a formatted
2529
string. Supports optional format argument: `"hex"` (default), `"rgb"`,
26-
`"hsl"`, or `"oklch"` for CSS-style output. Alpha is included when not
27-
equal to 1.
30+
`"hsl"`, or `"oklch"` for CSS-style output. Alpha is included when not equal
31+
to 1.
2832
- **`ColorMix`**: Blend two colors in OKLCh space with an optional ratio
2933
(default 0.5). Accepts color strings or sRGB `Tuple` values. Interpolates
3034
lightness and chroma linearly, hue with shorter-arc interpolation.
31-
- **`ColorContrast`**: Compute the APCA contrast ratio between a background
32-
and foreground color. Returns a positive value for dark-on-light and
33-
negative for light-on-dark.
35+
- **`ColorContrast`**: Compute the APCA contrast ratio between a background and
36+
foreground color. Returns a positive value for dark-on-light and negative for
37+
light-on-dark.
3438
- **`ContrastingColor`**: Choose the foreground color with better APCA contrast
3539
against a background. With one argument, picks between white and black. With
3640
three arguments, picks the better of two foreground candidates.
3741
- **LaTeX color support**: `\textcolor{color}{body}`, `\colorbox{color}{body}`,
38-
and `\boxed{body}` now roundtrip through `Annotated` expressions. Parsing
39-
and serialization are handled in the core `Annotated` infrastructure.
42+
and `\boxed{body}` now roundtrip through `Annotated` expressions. Parsing and
43+
serialization are handled in the core `Annotated` infrastructure.
4044
- **LaTeX font annotations**: `\textbf`, `\textit`, `\texttt`, `\textsf`,
4145
`\textup` now serialize correctly from `Annotated` expressions via
4246
`fontWeight`, `fontStyle`, and `fontFamily` dict keys.
@@ -47,8 +51,8 @@
4751
`oklab(L a b / alpha)` syntax, matching the existing `oklch()` support.
4852
- **GPU compilation**: `ColorMix`, `ColorContrast`, `ContrastingColor`,
4953
`ColorToColorspace`, and `ColorFromColorspace` now compile to GLSL and WGSL.
50-
Preamble functions provide sRGB ↔ OKLab ↔ OKLCh conversion, color mixing
51-
with shorter-arc hue interpolation, and APCA contrast on the GPU.
54+
Preamble functions provide sRGB ↔ OKLab ↔ OKLCh conversion, color mixing with
55+
shorter-arc hue interpolation, and APCA contrast on the GPU.
5256
- Added `rgbToHsl()` conversion function. Exported `hslToRgb()` (previously
5357
private).
5458

requirements/COLORS.md

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ reference color values, and palettes.
3131
Four color spaces are used. **sRGB** is the canonical storage format; all others
3232
are conversion targets/sources.
3333

34-
| Color space | Components | Ranges | Role |
35-
| ----------- | ---------------------------------- | ------------------------------------------------- | ---- |
36-
| **sRGB** | `r`, `g`, `b` | 0–1 each (may exceed 1 for wide-gamut) | Canonical. Every color-returning function produces sRGB tuples. |
37-
| **OKLCh** | `L` (lightness), `C` (chroma), `h` (hue) | L: 0–1, C: 0–0.4, h: 0–360° | Perceptually uniform cylindrical space. Used for all interpolation, gamut mapping, and lightness/chroma manipulation. |
38-
| **OKLab** | `L` (lightness), `a` (green–red), `b` (blue–yellow) | L: 0–1, a: −0.4–0.4, b: −0.4–0.4 | Perceptually uniform rectangular space. OKLCh is its cylindrical form. Useful for computing color differences (ΔE). Accepted as `"oklab"` or `"lab"`. |
39-
| **HSL** | `h` (hue), `s` (saturation), `l` (lightness) | h: 0–360°, s: 0–1, l: 0–1 | Legacy CSS color space. Familiar to web developers. Not perceptually uniform. |
34+
| Color space | Components | Ranges | Role |
35+
| ----------- | --------------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
36+
| **sRGB** | `r`, `g`, `b` | 0–1 each (may exceed 1 for wide-gamut) | Canonical. Every color-returning function produces sRGB tuples. |
37+
| **OKLCh** | `L` (lightness), `C` (chroma), `h` (hue) | L: 0–1, C: 0–0.4, h: 0–360° | Perceptually uniform cylindrical space. Used for all interpolation, gamut mapping, and lightness/chroma manipulation. |
38+
| **OKLab** | `L` (lightness), `a` (green–red), `b` (blue–yellow) | L: 0–1, a: −0.4–0.4, b: −0.4–0.4 | Perceptually uniform rectangular space. OKLCh is its cylindrical form. Useful for computing color differences (ΔE). Accepted as `"oklab"` or `"lab"`. |
39+
| **HSL** | `h` (hue), `s` (saturation), `l` (lightness) | h: 0–360°, s: 0–1, l: 0–1 | Legacy CSS color space. Familiar to web developers. Not perceptually uniform. |
4040

4141
### Why OKLCh for interpolation?
4242

@@ -61,8 +61,8 @@ HSL ⟷ sRGB ⟷ OKLab ⟷ OKLCh
6161
```
6262

6363
Full bidirectional conversion exists between all four spaces, with sRGB as the
64-
hub. Conversions between non-adjacent spaces go through sRGB (e.g.
65-
HSL → sRGB → OKLab).
64+
hub. Conversions between non-adjacent spaces go through sRGB (e.g. HSL → sRGB →
65+
OKLab).
6666

6767
**Implementation note**: `hslToRgb` exists in `src/color/manipulation.ts`.
6868
`rgbToHsl` needs to be added for the reverse direction.
@@ -81,18 +81,18 @@ Color(input: string) -> Tuple<real, real, real> | Tuple<real, real, real, real>
8181

8282
#### Accepted input formats
8383

84-
| Format | Example | Notes |
85-
| ------------------- | ------------------------------ | -------------------------------------------------- |
86-
| Hex (3 digits) | `"#f2c"` | Expanded to `#ff22cc` |
87-
| Hex (6 digits) | `"#fedaca"` | |
88-
| Hex (8 digits) | `"#fedacaff"` | Last two digits are alpha |
89-
| `rgb()` / `rgba()` | `"rgb(255, 100, 20)"` | Values 0–255; values ≤ 1.0 treated as fractions |
90-
| `rgb()` modern | `"rgb(255 100 20 / 0.5)"` | Space-separated, slash-alpha |
91-
| `rgb()` percent | `"rgb(50%, 25%, 10%)"` | Percentages |
92-
| `hsl()` / `hsla()` | `"hsl(210, 80%, 50%)"` | H: 0–360°, S/L: 0–100% |
93-
| `oklch()` | `"oklch(0.7 0.15 210)"` | L: 0–1, C: 0–0.4, H: 0–360° |
94-
| Named color | `"red"`, `"teal"`, `"white"` | See named colors table |
95-
| `"transparent"` | `"transparent"` | Returns `(0, 0, 0, 0)` |
84+
| Format | Example | Notes |
85+
| ------------------ | ---------------------------- | ----------------------------------------------- |
86+
| Hex (3 digits) | `"#f2c"` | Expanded to `#ff22cc` |
87+
| Hex (6 digits) | `"#fedaca"` | |
88+
| Hex (8 digits) | `"#fedacaff"` | Last two digits are alpha |
89+
| `rgb()` / `rgba()` | `"rgb(255, 100, 20)"` | Values 0–255; values ≤ 1.0 treated as fractions |
90+
| `rgb()` modern | `"rgb(255 100 20 / 0.5)"` | Space-separated, slash-alpha |
91+
| `rgb()` percent | `"rgb(50%, 25%, 10%)"` | Percentages |
92+
| `hsl()` / `hsla()` | `"hsl(210, 80%, 50%)"` | H: 0–360°, S/L: 0–100% |
93+
| `oklch()` | `"oklch(0.7 0.15 210)"` | L: 0–1, C: 0–0.4, H: 0–360° |
94+
| Named color | `"red"`, `"teal"`, `"white"` | See named colors table |
95+
| `"transparent"` | `"transparent"` | Returns `(0, 0, 0, 0)` |
9696

9797
#### Named colors
9898

@@ -170,21 +170,19 @@ ensure perceptual uniformity. Hue interpolation uses the shorter arc.
170170

171171
#### Available palettes
172172

173-
**Sequential** (256-stop, perceptually uniform):
174-
`turbo`, `inferno`, `magma`, `plasma`, `viridis`, `cividis`, `rocket`, `mako`
173+
**Sequential** (256-stop, perceptually uniform): `turbo`, `inferno`, `magma`,
174+
`plasma`, `viridis`, `cividis`, `rocket`, `mako`
175175

176-
Each sequential palette also has a `-reversed` variant (e.g. `viridis-reversed`).
176+
Each sequential palette also has a `-reversed` variant (e.g.
177+
`viridis-reversed`).
177178

178-
**Sequential (short)**:
179-
`grey` (18 stops)
179+
**Sequential (short)**: `grey` (18 stops)
180180

181-
**Categorical** (discrete, not meaningful to interpolate between):
182-
`tycho11` (11), `tableau10` (10), `kelly22` (22), `graph6` (6),
183-
`spectrum6` (6), `spectrum12` (12)
181+
**Categorical** (discrete, not meaningful to interpolate between): `tycho11`
182+
(11), `tableau10` (10), `kelly22` (22), `graph6` (6), `spectrum12` (12)
184183

185-
**Diverging** (symmetric around a neutral midpoint):
186-
`roma` (261), `vik` (9), `broc` (9), `rdbu` (21), `coolwarm` (21),
187-
`ocean-balance` (22)
184+
**Diverging** (symmetric around a neutral midpoint): `roma` (261), `vik` (9),
185+
`broc` (9), `rdbu` (21), `coolwarm` (21), `ocean-balance` (22)
188186

189187
Each diverging palette also has a `-reversed` variant.
190188

@@ -207,16 +205,17 @@ Convert a color to component values in a target color space.
207205
ColorToColorspace(color, colorspace: string) -> Tuple
208206
```
209207

210-
The first argument may be a canonical RGB tuple or any value accepted by `Color`.
208+
The first argument may be a canonical RGB tuple or any value accepted by
209+
`Color`.
211210

212211
#### Supported color spaces
213212

214-
| Name | Components | Ranges |
215-
| --------------------- | ---------------------- | ------------------------------------------- |
216-
| `"rgb"` | `(r, g, b)` | 0–1 each (sRGB) |
217-
| `"hsl"` | `(h, s, l)` | h: 0–360, s: 0–1, l: 0–1 |
218-
| `"oklch"` | `(L, C, h)` | L: 0–1, C: 0–0.4, h: 0–360 |
219-
| `"oklab"` or `"lab"` | `(L, a, b)` | L: 0–1, a: −0.4–0.4, b: −0.4–0.4 |
213+
| Name | Components | Ranges |
214+
| -------------------- | ----------- | -------------------------------- |
215+
| `"rgb"` | `(r, g, b)` | 0–1 each (sRGB) |
216+
| `"hsl"` | `(h, s, l)` | h: 0–360, s: 0–1, l: 0–1 |
217+
| `"oklch"` | `(L, C, h)` | L: 0–1, C: 0–0.4, h: 0–360 |
218+
| `"oklab"` or `"lab"` | `(L, a, b)` | L: 0–1, a: −0.4–0.4, b: −0.4–0.4 |
220219

221220
Alpha, if present and ≠ 1, is appended as a fourth component in every case.
222221

@@ -240,9 +239,9 @@ ColorFromColorspace(components: Tuple, colorspace: string) -> Tuple
240239
```
241240

242241
The same color space names as `ColorToColorspace` are accepted (`"rgb"`,
243-
`"hsl"`, `"oklch"`, `"oklab"` / `"lab"`). If the input color is outside the
244-
sRGB gamut, chroma is reduced (in OKLCh) while preserving hue until the color
245-
fits, using a binary-search gamut-mapping algorithm (see Color Spaces section).
242+
`"hsl"`, `"oklch"`, `"oklab"` / `"lab"`). If the input color is outside the sRGB
243+
gamut, chroma is reduced (in OKLCh) while preserving hue until the color fits,
244+
using a binary-search gamut-mapping algorithm (see Color Spaces section).
246245

247246
#### Examples
248247

0 commit comments

Comments
 (0)