| 1 |
// CIE Lightness difference, as used by Google Material Design |
| 2 |
// Google HCT Tone is the same as CIE Lightness |
| 3 |
// https://material.io/blog/science-of-color-design |
| 4 |
|
| 5 |
import getColor from "../getColor.js"; |
| 6 |
import get from "../get.js"; |
| 7 |
import lab from "../spaces/lab.js"; |
| 8 |
|
| 9 |
/** |
| 10 |
* @param {import("../types.js").ColorTypes} color1 |
| 11 |
* @param {import("../types.js").ColorTypes} color2 |
| 12 |
* @returns {number} |
| 13 |
*/ |
| 14 |
export default function contrastLstar (color1, color2) { |
| 15 |
color1 = getColor(color1); |
| 16 |
color2 = getColor(color2); |
| 17 |
|
| 18 |
let L1 = get(color1, [lab, "l"]); |
| 19 |
let L2 = get(color2, [lab, "l"]); |
| 20 |
|
| 21 |
return Math.abs(L1 - L2); |
| 22 |
} |