Skip to content

Commit

Permalink
Add docs on setting default DeltaE method
Browse files Browse the repository at this point in the history
  • Loading branch information
LeaVerou committed Aug 1, 2020
1 parent 5f226c6 commit 11ab574
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/color-difference.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,19 @@ color1.deltaE(color2, "76");
color1.deltaE(color2, "CMC");
color1.deltaE(color2, "2000");
```

## Setting the default DeltaE algorithm

Notice that even if you include better DeltaE algorithms such as ΔΕ2000,
the default DeltaE algorithm used in every function that accepts a deltaE argument (e.g `Color#steps()`) or `color.deltaE()` with no method parameter) will remain DeltaE 1976.
This is because Color.js doesn't necessarily know which DeltaE method is better for your use case.
E.g. for high performance code, you may prefer the speed over accuracy tradeoff of DeltaE 1976.
You can however change this default:

```js
let color1 = new Color("blue");
let color2 = new Color("lch", [20, 50, 230]);
color1.deltaE(color2);
Color.defaults.deltaE = "2000";
color1.deltaE(color2);
```

0 comments on commit 11ab574

Please sign in to comment.