Skip to content

Commit db7a58b

Browse files
committed
Update docs
1 parent 6ccb866 commit db7a58b

File tree

3 files changed

+87
-33
lines changed

3 files changed

+87
-33
lines changed

docs/color-spaces.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,38 @@ The [RGB color model](https://en.wikipedia.org/wiki/RGB_color_model) describes c
3737

3838
The [sRGB color space](https://en.wikipedia.org/wiki/SRGB), which most people refer to when talking about RGB colors.
3939

40-
Serialized as `color(srgb r g b / alpha)`.
40+
Serialized as `color(srgb r g b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
4141

4242
#### `lrgb`
4343

4444
The linear-light form of the sRGB color space.
4545

46-
Serialized as `color(--srgb-linear r g b / alpha)`.
46+
Serialized as `color(--srgb-linear r g b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
4747

4848
#### `a98`
4949

5050
The A98 RGB color space, compatible with the [Adobe RGB (1998) color space](https://en.wikipedia.org/wiki/Adobe_RGB_color_space).
5151

52-
Serialized as `color(a98-rgb r g b / alpha)`.
52+
Serialized as `color(a98-rgb r g b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
5353

5454
#### `p3`
5555

5656
The [Display P3 color space](https://en.wikipedia.org/wiki/DCI-P3#Display_P3).
5757

58-
Serialized as `color(display-p3 r g b / alpha)`.
58+
Serialized as `color(display-p3 r g b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
59+
5960

6061
#### `prophoto`
6162

6263
The [ProPhoto RGB color space](https://en.wikipedia.org/wiki/ProPhoto_RGB_color_space).
6364

64-
Serialized as `color(prophoto-rgb r g b / alpha)`.
65+
Serialized as `color(prophoto-rgb r g b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
6566

6667
#### `rec2020`
6768

6869
The [Rec. 2020 color space](https://en.wikipedia.org/wiki/Rec._2020).
6970

70-
Serialized as `color(rec2020 r g b / alpha)`.
71+
Serialized as `color(rec2020 r g b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
7172

7273
### The HSL/HSV/HSI family
7374

@@ -87,7 +88,7 @@ The HSL color space.
8788
| `s` | `[0, 1]` | Saturation in HSL |
8889
| `l` | `[0, 1]` | Lightness |
8990

90-
Serialized as `hsl(h s% l% / alpha)`.
91+
Serialized as `hsl(h s% l%)`. A missing hue is serialized as `0`, with the `none` keyword for any other missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
9192

9293
#### `hsv`
9394

@@ -99,7 +100,7 @@ The HSV color space.
99100
| `s` | `[0, 1]` | Saturation in HSV |
100101
| `v` | `[0, 1]` | Value |
101102

102-
Serialized as `color(--hsv h s v / alpha)`.
103+
Serialized as `color(--hsv h s v)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
103104

104105
#### `hsi`
105106

@@ -111,7 +112,7 @@ The HSI color space.
111112
| `s` | `[0, 1]` | Saturation in HSI |
112113
| `i` | `[0, 1]` | Intensity |
113114

114-
Serialized as `color(--hsi h s i / alpha)`.
115+
Serialized as `color(--hsi h s i)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
115116

116117
### HWB
117118

@@ -123,7 +124,9 @@ Serialized as `color(--hsi h s i / alpha)`.
123124
| `w` | `[0, 1]` | Whiteness |
124125
| `b` | `[0, 1]` | Blackness |
125126

126-
Serialized as `hwb(h w% b% / alpha)`.
127+
Serialized as `hwb(h w% b%)`.
128+
129+
Serialized as `hwb(h w% b%)`. A missing hue is serialized as `0`, with the `none` keyword for any other missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
127130

128131
> Smith, Alvy Ray (1996) — ["HWB — A More Intuitive Hue-Based Color Model"](http://alvyray.com/Papers/CG/HWB_JGTv208.pdf), Journal of Graphics, GPU and Game tools.
129132
@@ -141,7 +144,7 @@ The CIELAB color space using the [D50 standard illuminant](https://en.wikipedia.
141144
| `a` | `[-79.287, 93.55]`| Green–red component |
142145
| `b` | `[-112.029, 93.388]`| Blue–yellow component |
143146

144-
Serialized as `lab(l% a b / alpha)`.
147+
Serialized as `lab(l% a b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
145148

146149
#### `lch`
147150

@@ -153,7 +156,7 @@ The CIELCh color space using the D50 standard illuminant.
153156
| `c` | `[0, 131.207]`| Chroma |
154157
| `h` | `[0, 360)` | Hue |
155158

156-
Serialized as `lch(l% c h / alpha)`.
159+
Serialized as `lch(l% c h)`. A missing hue is serialized as `0`, with the `none` keyword for any other missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
157160

158161
#### `lab65`
159162

@@ -165,7 +168,7 @@ CIELAB relative to the D65 standard illuminant.
165168
| `a` | `[-86.183, 98.234]`| Green–red component |
166169
| `b` | `[-107.86, 94.478]`| Blue–yellow component |
167170

168-
Serialized as `color(--lab-d65 l a b / alpha)`.
171+
Serialized as `color(--lab-d65 l a b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
169172

170173
#### `lch65`
171174

@@ -177,7 +180,7 @@ CIELCh relative to the D65 standard illuminant.
177180
| `c` | `[0, 133.807]`| Chroma |
178181
| `h` | `[0, 360)` | Hue |
179182

180-
Serialized as `color(--lch-d65 l c h / alpha)`.
183+
Serialized as `color(--lch-d65 l c h)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
181184

182185
### CIELUV
183186

@@ -197,7 +200,7 @@ let deltaE_uv = culori.colorDifferenceEuclidean('luv');
197200
| `u` | `[-84.936, 175.042]`| Green–red component |
198201
| `v` | `[-125.882, 87.243]`| Blue–yellow component |
199202

200-
Serialized as `color(--luv l u v / alpha)`.
203+
Serialized as `color(--luv l u v)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
201204

202205
#### `lchuv`
203206

@@ -207,11 +210,11 @@ Serialized as `color(--luv l u v / alpha)`.
207210
| `c` | `[0, 176.956]`| Chroma |
208211
| `h` | `[0, 360)` | Hue |
209212

210-
Serialized as `color(--lchuv l c h / alpha)`.
213+
Serialized as `color(--lchuv l c h)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
211214

212215
### DIN99 Lab / LCh
213216

214-
The [DIN99][din99o] color space "squishes" the CIELAB D65 color space to obtain an [effective color difference](#culoriDifferenceDin99o) metric that can be expressed as a simple Euclidean distance. The latest iteration of the the standard, DIN99o, is available in Cartesian (`dlab`) and plar (`dlch`) form.
217+
The [DIN99](https://de.wikipedia.org/wiki/DIN99-Farbraum) color space "squishes" the CIELAB D65 color space to obtain an [effective color difference](#culoriDifferenceDin99o) metric that can be expressed as a simple Euclidean distance. The latest iteration of the the standard, DIN99o, is available in Cartesian (`dlab`) and plar (`dlch`) form.
215218

216219
> ["Industrial Color Physics"](https://www.springer.com/us/book/9781441911964), Georg A. Klein, Springer (2010)
217220
@@ -225,7 +228,7 @@ The DIN99o color space in Cartesian form.
225228
| `a` | `[-40.09, 45.501]`|
226229
| `b` | `[-40.469, 44.344]`|
227230

228-
Serialized as `color(--din99o-lab l a b / alpha)`.
231+
Serialized as `color(--din99o-lab l a b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
229232

230233
#### `dlch`
231234

@@ -237,7 +240,7 @@ The DIN99o color space in cylindrical form.
237240
| `c` | `[0, 51.484]`| Chroma |
238241
| `h` | `[0, 360)` | Hue |
239242

240-
Serialized as `color(--din99o-lch l c h / alpha)`.
243+
Serialized as `color(--din99o-lch l c h)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
241244

242245
### Oklab, Oklch, Okhsl, Okhsv
243246

@@ -255,7 +258,7 @@ The Oklab color space in Cartesian form.
255258
| `a` | `[-0.233, 0.276]`| Green–red component |
256259
| `b` | `[-0.311, 0.198]`| Blue–yellow component |
257260

258-
Serialized as `color(--oklab l a b / alpha)`.
261+
Serialized as `color(--oklab l a b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
259262

260263
#### `oklch`
261264

@@ -267,7 +270,7 @@ The Oklab color space in cylindrical form.
267270
| `c` | `[0, 0.322]`| Chroma |
268271
| `h` | `[0, 360)` | Hue |
269272

270-
Serialized as `color(--oklch l c h / alpha)`.
273+
Serialized as `color(--oklch l c h)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
271274

272275
### `okhsl`
273276

@@ -277,7 +280,7 @@ Serialized as `color(--oklch l c h / alpha)`.
277280
| `s` | `[0, 1]` | Saturation (Okhsl) |
278281
| `l` | `[0, 1]` | Lightness |
279282

280-
Serialized as `color(--okhsl h s l / alpha)`.
283+
Serialized as `color(--okhsl h s l)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
281284

282285
### `okhsv`
283286

@@ -287,7 +290,7 @@ Serialized as `color(--okhsl h s l / alpha)`.
287290
| `s` | `[0, 1]` | Saturation (Okhsv) |
288291
| `v` | `[0, 1]` | Value |
289292

290-
Serialized as `color(--okhsv h s v / alpha)`.
293+
Serialized as `color(--okhsv h s v)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
291294

292295
#### Further reading
293296

@@ -311,7 +314,7 @@ The J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> color space in Cartesian form.
311314
| `a` | `[-0.109, 0.129]`| Green–red component |
312315
| `b` | `[-0.185, 0.134]`| Blue–yellow component |
313316

314-
Serialized as `color(--jzazbz j a b / alpha)`.
317+
Serialized as `color(--jzazbz j a b)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
315318

316319
#### `jch`
317320

@@ -323,19 +326,19 @@ The J<sub>z</sub>a<sub>z</sub>b<sub>z</sub> color space in cylindrical form.
323326
| `c` | `[0, 0.190]`| Chroma |
324327
| `h` | `[0, 360)` | Hue |
325328

326-
Serialized as `color(--jzczhz j c h / alpha)`.
329+
Serialized as `color(--jzczhz j c h)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
327330

328331
### YIQ
329332

330-
[YIQ][yiq] is the color space used by the NTSC color TV system. It contains the following channels:
333+
[YIQ](https://en.wikipedia.org/wiki/YIQ) is the color space used by the NTSC color TV system. It contains the following channels:
331334

332335
| Channel | Range | Description |
333336
| ------- | ------------------ | ------------------------------ |
334337
| Y | `[0, 1]` | Luma |
335338
| I | `[-0.595, 0.595]`| In-phase (orange-blue axis) |
336339
| Q | `[-0.522, 0.522]`| Quadrature (green-purple axis) |
337340

338-
Serialized as `color(--yiq y i q / alpha)`.
341+
Serialized as `color(--yiq y i q)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
339342

340343
### CIE XYZ
341344

@@ -351,7 +354,7 @@ The CIE XYZ color space in respect to the D50 standard illuminant.
351354
| Y | `[0, 0.999]`| ? |
352355
| Z | `[0, 0.825]`| ? |
353356

354-
Serialized as `color(xyz-d50 x y z / alpha)`.
357+
Serialized as `color(xyz-d50 x y z)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
355358

356359
#### `xyz65`
357360

@@ -363,7 +366,7 @@ The CIE XYZ color space in respect to the D65 standard illuminant.
363366
| Y | `[0, 1]`| ? |
364367
| Z | `[0, 1.088]`| ? |
365368

366-
Serialized as `color(xyz-d65 x y z / alpha)`.
369+
Serialized as `color(xyz-d65 x y z)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
367370

368371
### Cubehelix
369372

@@ -383,7 +386,5 @@ The channels in the `cubehelix` color space maintain the conventions from D3, na
383386
| `s` | `[0, 4.614]` | Saturation (Called _hue_ in op. cit.) |
384387
| `l` | `[0, 1]` | Lightness |
385388

386-
Serialized as `color(--cubehelix h s l / alpha)`.
389+
Serialized as `color(--cubehelix h s l)`, with the `none` keyword for any missing color channel. An explicit `alpha < 1` is included as ` / alpha`.
387390

388-
[din99o]: https://de.wikipedia.org/wiki/DIN99-Farbraum
389-
[yiq]: https://en.wikipedia.org/wiki/YIQ

docs/guides/migration.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,59 @@
22
title: 'Migration guide'
33
---
44

5+
## Migrating from version 1.x to 2.0
6+
7+
* all color components in all CSS color syntaxes now accept the `none` keyword. ([w3c/csswg-drafts#6107](https://github.com/w3c/csswg-drafts/issues/6107))
8+
9+
### XYZ D50 vs. D65
10+
11+
The CSS Color Module Level 4 specification has been updated so that the `xyz` predefined color profile refers to the D65-relative XYZ color space, rather than the D50-relative XYZ color space. ([w3c/csswg-drafts#6722](https://github.com/w3c/csswg-drafts/issues/6722)).
12+
13+
In Culori, this has resulted in the D50-relative XYZ color space being changed to use `mode: 'xyz50'` instead of `mode: 'xyz'`. The latter is no longer supported. In addition:
14+
15+
* colors in the `xyz50` mode will be serialized as `color(xyz-d50 x y z / alpha)` when using the [`formatCss()`](/api#formatCss) method, instead of `color(--xyz-d50 x y z)`, to reflect the addition of `xyz-d50` to the list of predefined CSS color profiles.
16+
* colors in the `xyz65` mode will be serialized as `color(xyz-d65 x y z / alpha)` instead of `color(--xyz-d65 x y z / alpha)`, to reflect the addition of `xyz-d65` to the list of predefined CSS color profiles.
17+
* CSS colors in the `color(xyz x y z / alpha)` format will be parsed as `mode: 'xyz65'` instead of `mode: 'xyz50'`.
18+
19+
As a result of this rename, the following exports have been renamed in [all applicable entry points](/guides/tree-shaking):
20+
21+
* <code>modeXyz</code> → <code>modeXyz<strong>50</strong></code>
22+
* <code>xyz</code> → <code>xyz<strong>50</strong></code>
23+
* <code>convertLabToXyz</code> → <code>convertLabToXyz<strong>50</strong></code>
24+
* <code>convertLuvToXyz</code> → <code>convertLuvToXyz<strong>50</strong></code>
25+
* <code>convertProphotoToXyz</code> → <code>convertProphotoToXyz<strong>50</strong></code>
26+
* <code>convertRgbToXyz</code> → <code>convertRgbToXyz<strong>50</strong></code>
27+
* <code>convertXyz65ToXyz</code> → <code>convertXyz65ToXyz<strong>50</strong></code>
28+
* <code>convertXyzToLab</code> → <code>convertXyz<strong>50</strong>ToLab</code>
29+
* <code>convertXyzToLuv</code> → <code>convertXyz<strong>50</strong>ToLuv</code>
30+
* <code>convertXyzToProphoto</code> → <code>convertXyz<strong>50</strong>ToProphoto</code>
31+
* <code>convertXyzToRgb</code> → <code>convertXyz<strong>50</strong>ToRgb</code>
32+
* <code>convertXyzToXyz65</code> → <code>convertXyz<strong>50</strong>ToXyz65</code>
33+
34+
### `<number>` for L no longer valid in `lab()` and `lch()`
35+
36+
CSS defines the `lab` syntax as `lab(<percentage> <number> <number>)`, for example:
37+
38+
```css
39+
lab(75% 40 30)
40+
```
41+
42+
...and the `lch` syntax as `lch(<percentage> <number> <hue>)`:
43+
44+
```css
45+
lch(75% 50 15deg)
46+
```
47+
48+
Culori used to support `<number>` as the L channel, so these colors used to be also valid:
49+
50+
```css
51+
lab(75 40 30)
52+
lch(75 50 15deg)
53+
```
54+
55+
In version 2.0, we drop this quirk and bring Culori in line with the specification.
56+
57+
558
## Migrating from version 0.x to 1.0
659

760
### Using the library

test/xyz65.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { xyz65, formatCss } from '../src/index.js';
44
tape('xyz65', t => {
55
/*
66
These should theoretically be equal to the Xn, Yn, and Zn values
7-
from xyz/constants.js, but there's a small rounding error for `y`.
7+
from xyz65/constants.js, but there's a small rounding error for `y`.
88
*/
99
t.deepEqual(xyz65('white'), {
1010
mode: 'xyz65',

0 commit comments

Comments
 (0)