You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,13 @@
1
1
## Culori Changelog
2
2
3
+
### Unreleased
4
+
5
+
Stop treating the _alpha_ channel specifically in the Euclidean distance formula. Instead, assume it's always the fourth channel and assign it a default weight of 0. This means that it's now possible to factor in the alpha into the distance, if needed.
6
+
7
+
There's also a change of handing `NaN` differences on a channel. In this case, the distance on that particular channel is considered to be zero. (Which kind of makes sense?)
8
+
9
+
Distances on the hue (`h` channel) are now computed with the _shortest hue distance_, taking into account the cyclical nature of this channel. ([#68](https://github.com/Evercoder/culori/issues/68)).
10
+
3
11
### 0.5.4
4
12
5
13
Fixed typo in CMC (l:c) color difference formula. ([#66](https://github.com/Evercoder/culori/issues/66))
These methods are concerned to finding the [distance between two colors](https://en.wikipedia.org/wiki/Color_difference) based on various formulas. Each of these formulas will return a _function (colorA, colorB)_ that lets you measure the distance between two colors. Also available as a separate [d3 plugin](https://github.com/evercoder/d3-color-difference).
Returns a [Euclidean distance](https://en.wikipedia.org/wiki/Color_difference#Euclidean) function in a certain color space.
235
239
236
240
You can optionally assign different weights to the channels in the color space. See, for example, the [Kotsarenko/Ramos distance](#culoriDifferenceKotsarenkoRamos).
237
241
242
+
The default weights `[1, 1, 1, 0]` mean that the _alpha_, which is the fourth channel in all the color spaces Culori defines, is not taken into account. Send `[1, 1, 1, 1]` as the weights to include it in the computation.
243
+
244
+
For the `h` channel in the color (in any color space that has this channel), we're using a _shortest hue distance_ to compute the hue's contribution to the distance. In spaces such as HSL or HSV, where the range of this difference is `[0, 180]` — as opposed to `[0, 1]` for the other channels — consider adjusting the weights so that the hue contributes "equally" to the distance:
245
+
246
+
```js
247
+
let hsl_distance =culori.differenceEuclidean('hsl', [
Computes the [CIE76][cie76] ΔE\*<sub>ab</sub> color difference between the colors _a_ and _b_. The computation is done in the Lab color space and it is analogous to [culori.differenceEuclidean('lab')](#culoriDifferenceEuclidean).
@@ -275,6 +292,8 @@ Pass _n = Infinity_ to get all colors in the array with a maximum distance of _
275
292
276
293
### RGB / LRGB (Linear RGB)
277
294
295
+
> 🕳 expand this section
296
+
278
297
### HSL / HSV / HSI
279
298
280
299
[HSL, HSV, and HSI](https://en.wikipedia.org/wiki/HSL_and_HSV) are a family of representations of the RGB color space, created in 1970 to provide color spaces more closely aligned to how humans perceive colors.
@@ -436,7 +455,14 @@ function contrast(colorA, colorB) {
436
455
437
456
## Extending culori
438
457
439
-
TODO
458
+
### Defining a color space
459
+
460
+
**Note:** The order of the items in the `channels` array matters. To keep things simple, we're making the following conventions:
461
+
462
+
- the fourth item in the array should be `alpha`
463
+
- any cyclical values (e.g. hue) should be identified by `h`, in the range `[0, 360)`
464
+
465
+
These constrains make sure `differenceEuclidean()` works as expected.
0 commit comments