@lakuna/color 1.1.2 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/{utility → convert}/adobeToXyz.d.ts +1 -1
- package/dist/convert/adobeToXyz.d.ts.map +1 -0
- package/dist/{utility → convert}/adobeToXyz.js +5 -3
- package/dist/convert/adobeToXyz.js.map +1 -0
- package/dist/{utility → convert}/cmyToCmyk.d.ts +1 -1
- package/dist/convert/cmyToCmyk.d.ts.map +1 -0
- package/dist/{utility → convert}/cmyToCmyk.js +0 -3
- package/dist/convert/cmyToCmyk.js.map +1 -0
- package/dist/{utility → convert}/cmyToRgb.d.ts +1 -1
- package/dist/convert/cmyToRgb.d.ts.map +1 -0
- package/dist/convert/cmyToRgb.js.map +1 -0
- package/dist/{utility → convert}/cmykToCmy.d.ts +1 -1
- package/dist/convert/cmykToCmy.d.ts.map +1 -0
- package/dist/{utility → convert}/cmykToCmy.js +0 -1
- package/dist/convert/cmykToCmy.js.map +1 -0
- package/dist/{utility → convert}/hexToRgb.d.ts +1 -1
- package/dist/convert/hexToRgb.d.ts.map +1 -0
- package/dist/{utility → convert}/hexToRgb.js.map +1 -1
- package/dist/{utility → convert}/hslToRgb.d.ts +1 -1
- package/dist/convert/hslToRgb.d.ts.map +1 -0
- package/dist/{utility → convert}/hslToRgb.js +5 -6
- package/dist/convert/hslToRgb.js.map +1 -0
- package/dist/{utility → convert}/hsvToRgb.d.ts +1 -1
- package/dist/convert/hsvToRgb.d.ts.map +1 -0
- package/dist/{utility → convert}/hsvToRgb.js +0 -2
- package/dist/convert/hsvToRgb.js.map +1 -0
- package/dist/{utility → convert}/hunterToXyz.d.ts +1 -1
- package/dist/convert/hunterToXyz.d.ts.map +1 -0
- package/dist/{utility → convert}/hunterToXyz.js +6 -7
- package/dist/convert/hunterToXyz.js.map +1 -0
- package/dist/convert/labToLch.d.ts +19 -0
- package/dist/convert/labToLch.d.ts.map +1 -0
- package/dist/convert/labToLch.js +12 -0
- package/dist/convert/labToLch.js.map +1 -0
- package/dist/{utility → convert}/labToXyz.d.ts +1 -1
- package/dist/convert/labToXyz.d.ts.map +1 -0
- package/dist/{utility → convert}/labToXyz.js +8 -5
- package/dist/convert/labToXyz.js.map +1 -0
- package/dist/convert/lchToLab.d.ts +19 -0
- package/dist/convert/lchToLab.d.ts.map +1 -0
- package/dist/convert/lchToLab.js +7 -0
- package/dist/convert/lchToLab.js.map +1 -0
- package/dist/{utility → convert}/luvToXyz.d.ts +1 -1
- package/dist/convert/luvToXyz.d.ts.map +1 -0
- package/dist/{utility → convert}/luvToXyz.js +4 -6
- package/dist/convert/luvToXyz.js.map +1 -0
- package/dist/{utility → convert}/rgbToCmy.d.ts +1 -1
- package/dist/convert/rgbToCmy.d.ts.map +1 -0
- package/dist/convert/rgbToCmy.js.map +1 -0
- package/dist/{utility → convert}/rgbToHex.d.ts +1 -1
- package/dist/{utility → convert}/rgbToHex.d.ts.map +1 -1
- package/dist/{utility → convert}/rgbToHex.js +3 -1
- package/dist/convert/rgbToHex.js.map +1 -0
- package/dist/convert/rgbToHsi.d.ts +10 -0
- package/dist/convert/rgbToHsi.d.ts.map +1 -0
- package/dist/convert/rgbToHsi.js +36 -0
- package/dist/convert/rgbToHsi.js.map +1 -0
- package/dist/{utility → convert}/rgbToHsl.d.ts +1 -1
- package/dist/convert/rgbToHsl.d.ts.map +1 -0
- package/dist/convert/rgbToHsl.js +37 -0
- package/dist/convert/rgbToHsl.js.map +1 -0
- package/dist/{utility → convert}/rgbToHsv.d.ts +1 -1
- package/dist/convert/rgbToHsv.d.ts.map +1 -0
- package/dist/{utility → convert}/rgbToHsv.js +11 -11
- package/dist/convert/rgbToHsv.js.map +1 -0
- package/dist/{utility → convert}/rgbToXyz.d.ts +1 -1
- package/dist/convert/rgbToXyz.d.ts.map +1 -0
- package/dist/{utility → convert}/rgbToXyz.js +9 -3
- package/dist/convert/rgbToXyz.js.map +1 -0
- package/dist/{utility → convert}/xyzToAdobe.d.ts +1 -1
- package/dist/convert/xyzToAdobe.d.ts.map +1 -0
- package/dist/{utility → convert}/xyzToAdobe.js +5 -3
- package/dist/convert/xyzToAdobe.js.map +1 -0
- package/dist/{utility → convert}/xyzToHunter.d.ts +2 -2
- package/dist/convert/xyzToHunter.d.ts.map +1 -0
- package/dist/{utility → convert}/xyzToHunter.js +7 -8
- package/dist/convert/xyzToHunter.js.map +1 -0
- package/dist/{utility → convert}/xyzToLab.d.ts +1 -1
- package/dist/convert/xyzToLab.d.ts.map +1 -0
- package/dist/{utility → convert}/xyzToLab.js +9 -5
- package/dist/convert/xyzToLab.js.map +1 -0
- package/dist/{utility → convert}/xyzToLuv.d.ts +1 -1
- package/dist/convert/xyzToLuv.d.ts.map +1 -0
- package/dist/{utility → convert}/xyzToLuv.js +5 -7
- package/dist/convert/xyzToLuv.js.map +1 -0
- package/dist/{utility → convert}/xyzToRgb.d.ts +1 -1
- package/dist/convert/xyzToRgb.d.ts.map +1 -0
- package/dist/{utility → convert}/xyzToRgb.js +8 -3
- package/dist/convert/xyzToRgb.js.map +1 -0
- package/dist/{utility → convert}/xyzToYxy.d.ts +1 -1
- package/dist/convert/xyzToYxy.d.ts.map +1 -0
- package/dist/{utility → convert}/xyzToYxy.js +0 -3
- package/dist/convert/xyzToYxy.js.map +1 -0
- package/dist/{utility → convert}/yxyToXyz.d.ts +1 -1
- package/dist/convert/yxyToXyz.d.ts.map +1 -0
- package/dist/{utility → convert}/yxyToXyz.js +0 -3
- package/dist/convert/yxyToXyz.js.map +1 -0
- package/dist/{utility → delta}/deltaC.d.ts +2 -2
- package/dist/delta/deltaC.d.ts.map +1 -0
- package/dist/{utility → delta}/deltaC.js.map +1 -1
- package/dist/{utility → delta}/deltaCmc.d.ts +2 -2
- package/dist/delta/deltaCmc.d.ts.map +1 -0
- package/dist/{utility → delta}/deltaCmc.js +5 -8
- package/dist/delta/deltaCmc.js.map +1 -0
- package/dist/{utility → delta}/deltaE00.d.ts +2 -2
- package/dist/delta/deltaE00.d.ts.map +1 -0
- package/dist/{utility → delta}/deltaE00.js +13 -17
- package/dist/delta/deltaE00.js.map +1 -0
- package/dist/{utility → delta}/deltaE76.d.ts +2 -2
- package/dist/delta/deltaE76.d.ts.map +1 -0
- package/dist/{utility → delta}/deltaE76.js.map +1 -1
- package/dist/{utility → delta}/deltaE94.d.ts +2 -2
- package/dist/delta/deltaE94.d.ts.map +1 -0
- package/dist/{utility → delta}/deltaE94.js +0 -6
- package/dist/delta/deltaE94.js.map +1 -0
- package/dist/{utility → delta}/deltaH.d.ts +2 -2
- package/dist/delta/deltaH.d.ts.map +1 -0
- package/dist/{utility → delta}/deltaH.js +0 -4
- package/dist/delta/deltaH.js.map +1 -0
- package/dist/index.d.ts +41 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -30
- package/dist/index.js.map +1 -1
- package/dist/names/bang.d.ts +2 -2
- package/dist/names/bang.d.ts.map +1 -1
- package/dist/names/bang.js +471 -471
- package/dist/names/bang.js.map +1 -1
- package/dist/names/cne.d.ts +1 -1
- package/dist/names/cne.d.ts.map +1 -1
- package/dist/names/cne.js +843 -843
- package/dist/names/cne.js.map +1 -1
- package/dist/names/crayola.d.ts +1 -1
- package/dist/names/crayola.d.ts.map +1 -1
- package/dist/names/crayola.js +110 -110
- package/dist/names/crayola.js.map +1 -1
- package/dist/names/getName.d.ts +2 -2
- package/dist/names/getName.d.ts.map +1 -1
- package/dist/names/getName.js +3 -3
- package/dist/names/getName.js.map +1 -1
- package/dist/names/hollasch.d.ts +1 -1
- package/dist/names/hollasch.d.ts.map +1 -1
- package/dist/names/hollasch.js +179 -179
- package/dist/names/hollasch.js.map +1 -1
- package/dist/names/nbs.d.ts +1 -1
- package/dist/names/nbs.d.ts.map +1 -1
- package/dist/names/nbs.js +266 -266
- package/dist/names/nbs.js.map +1 -1
- package/dist/names/ntc.d.ts +1 -1
- package/dist/names/ntc.d.ts.map +1 -1
- package/dist/names/ntc.js +1519 -1519
- package/dist/names/ntc.js.map +1 -1
- package/dist/names/resene.d.ts +1 -1
- package/dist/names/resene.d.ts.map +1 -1
- package/dist/names/resene.js +1331 -1331
- package/dist/names/resene.js.map +1 -1
- package/dist/names/tcapi.d.ts +1 -1
- package/dist/names/tcapi.d.ts.map +1 -1
- package/dist/names/tcapi.js +1840 -1840
- package/dist/names/tcapi.js.map +1 -1
- package/dist/names/x11.d.ts +1 -1
- package/dist/names/x11.d.ts.map +1 -1
- package/dist/names/x11.js +445 -445
- package/dist/names/x11.js.map +1 -1
- package/dist/names/xkcd.d.ts +1 -1
- package/dist/names/xkcd.d.ts.map +1 -1
- package/dist/names/xkcd.js +897 -897
- package/dist/names/xkcd.js.map +1 -1
- package/dist/palette/analogous.d.ts +28 -0
- package/dist/palette/analogous.d.ts.map +1 -0
- package/dist/palette/analogous.js +15 -0
- package/dist/palette/analogous.js.map +1 -0
- package/dist/palette/analogousLch.d.ts +19 -0
- package/dist/palette/analogousLch.d.ts.map +1 -0
- package/dist/palette/analogousLch.js +15 -0
- package/dist/palette/analogousLch.js.map +1 -0
- package/dist/palette/complement.d.ts +28 -0
- package/dist/palette/complement.d.ts.map +1 -0
- package/dist/palette/complement.js +15 -0
- package/dist/palette/complement.js.map +1 -0
- package/dist/palette/complementLch.d.ts +19 -0
- package/dist/palette/complementLch.d.ts.map +1 -0
- package/dist/palette/complementLch.js +15 -0
- package/dist/palette/complementLch.js.map +1 -0
- package/dist/palette/splitComplement.d.ts +28 -0
- package/dist/palette/splitComplement.d.ts.map +1 -0
- package/dist/palette/splitComplement.js +15 -0
- package/dist/palette/splitComplement.js.map +1 -0
- package/dist/palette/splitComplementLch.d.ts +19 -0
- package/dist/palette/splitComplementLch.d.ts.map +1 -0
- package/dist/palette/splitComplementLch.js +15 -0
- package/dist/palette/splitComplementLch.js.map +1 -0
- package/dist/types/Adobe.d.ts.map +1 -1
- package/dist/types/Cmy.d.ts.map +1 -1
- package/dist/types/Cmyk.d.ts.map +1 -1
- package/dist/types/Hsi.d.ts +15 -0
- package/dist/types/Hsi.d.ts.map +1 -0
- package/dist/types/Hsi.js +2 -0
- package/dist/types/Hsi.js.map +1 -0
- package/dist/types/Hsl.d.ts +1 -1
- package/dist/types/Hsl.d.ts.map +1 -1
- package/dist/types/Hsv.d.ts +1 -1
- package/dist/types/Hsv.d.ts.map +1 -1
- package/dist/types/Hunter.d.ts.map +1 -1
- package/dist/types/Lab.d.ts +2 -2
- package/dist/types/Lab.d.ts.map +1 -1
- package/dist/types/Lchab.d.ts +15 -0
- package/dist/types/Lchab.d.ts.map +1 -0
- package/dist/types/Lchab.js +2 -0
- package/dist/types/Lchab.js.map +1 -0
- package/dist/types/Lchuv.d.ts +15 -0
- package/dist/types/Lchuv.d.ts.map +1 -0
- package/dist/types/Lchuv.js +2 -0
- package/dist/types/Lchuv.js.map +1 -0
- package/dist/types/Luv.d.ts +1 -1
- package/dist/types/Luv.d.ts.map +1 -1
- package/dist/types/Rgb.d.ts.map +1 -1
- package/dist/types/Xyz.d.ts.map +1 -1
- package/dist/types/Yxy.d.ts.map +1 -1
- package/dist/utility/StandardIlluminant.d.ts.map +1 -1
- package/dist/utility/StandardIlluminant.js.map +1 -1
- package/dist/utility/contrast.d.ts +1 -1
- package/dist/utility/contrast.d.ts.map +1 -1
- package/dist/utility/contrast.js.map +1 -1
- package/dist/utility/getReference.d.ts +2 -2
- package/dist/utility/getReference.d.ts.map +1 -1
- package/dist/utility/getReference.js +39 -39
- package/dist/utility/getReference.js.map +1 -1
- package/dist/utility/isWebSafe.d.ts +10 -0
- package/dist/utility/isWebSafe.d.ts.map +1 -0
- package/dist/utility/isWebSafe.js +11 -0
- package/dist/utility/isWebSafe.js.map +1 -0
- package/dist/utility/relativeLuminance.d.ts +1 -1
- package/dist/utility/relativeLuminance.d.ts.map +1 -1
- package/dist/utility/relativeLuminance.js.map +1 -1
- package/package.json +34 -36
- package/src/{utility → convert}/adobeToXyz.ts +10 -4
- package/src/{utility → convert}/cmyToCmyk.ts +5 -4
- package/src/{utility → convert}/cmyToRgb.ts +3 -1
- package/src/{utility → convert}/cmykToCmy.ts +3 -2
- package/src/{utility → convert}/hexToRgb.ts +1 -1
- package/src/{utility → convert}/hslToRgb.ts +11 -7
- package/src/{utility → convert}/hsvToRgb.ts +4 -3
- package/src/{utility → convert}/hunterToXyz.ts +13 -10
- package/src/convert/labToLch.ts +40 -0
- package/src/{utility → convert}/labToXyz.ts +13 -8
- package/src/convert/lchToLab.ts +34 -0
- package/src/{utility → convert}/luvToXyz.ts +11 -9
- package/src/{utility → convert}/rgbToCmy.ts +3 -1
- package/src/{utility → convert}/rgbToHex.ts +6 -2
- package/src/convert/rgbToHsi.ts +45 -0
- package/src/convert/rgbToHsl.ts +46 -0
- package/src/{utility → convert}/rgbToHsv.ts +16 -13
- package/src/{utility → convert}/rgbToXyz.ts +13 -4
- package/src/convert/xyzToAdobe.ts +25 -0
- package/src/{utility → convert}/xyzToHunter.ts +14 -11
- package/src/{utility → convert}/xyzToLab.ts +14 -8
- package/src/{utility → convert}/xyzToLuv.ts +13 -11
- package/src/{utility → convert}/xyzToRgb.ts +12 -4
- package/src/{utility → convert}/xyzToYxy.ts +5 -4
- package/src/{utility → convert}/yxyToXyz.ts +5 -4
- package/src/{utility → delta}/deltaC.ts +12 -5
- package/src/{utility → delta}/deltaCmc.ts +14 -12
- package/src/{utility → delta}/deltaE00.ts +23 -20
- package/src/{utility → delta}/deltaE76.ts +12 -5
- package/src/{utility → delta}/deltaE94.ts +9 -10
- package/src/{utility → delta}/deltaH.ts +15 -9
- package/src/index.ts +47 -31
- package/src/names/bang.ts +476 -472
- package/src/names/cne.ts +848 -844
- package/src/names/crayola.ts +115 -111
- package/src/names/getName.ts +7 -6
- package/src/names/hollasch.ts +184 -180
- package/src/names/nbs.ts +271 -267
- package/src/names/ntc.ts +1524 -1520
- package/src/names/resene.ts +1336 -1332
- package/src/names/tcapi.ts +1845 -1841
- package/src/names/x11.ts +450 -446
- package/src/names/xkcd.ts +902 -898
- package/src/palette/analogous.ts +61 -0
- package/src/palette/analogousLch.ts +49 -0
- package/src/palette/complement.ts +65 -0
- package/src/palette/complementLch.ts +50 -0
- package/src/palette/splitComplement.ts +61 -0
- package/src/palette/splitComplementLch.ts +48 -0
- package/src/types/Adobe.ts +3 -0
- package/src/types/Cmy.ts +3 -0
- package/src/types/Cmyk.ts +4 -0
- package/src/types/Hsi.ts +20 -0
- package/src/types/Hsl.ts +4 -1
- package/src/types/Hsv.ts +4 -1
- package/src/types/Hunter.ts +3 -0
- package/src/types/Lab.ts +5 -2
- package/src/types/Lchab.ts +20 -0
- package/src/types/Lchuv.ts +20 -0
- package/src/types/Luv.ts +4 -1
- package/src/types/Rgb.ts +3 -0
- package/src/types/Xyz.ts +3 -0
- package/src/types/Yxy.ts +3 -0
- package/src/utility/StandardIlluminant.ts +40 -40
- package/src/utility/contrast.ts +5 -1
- package/src/utility/getReference.ts +42 -41
- package/src/utility/isWebSafe.ts +14 -0
- package/src/utility/relativeLuminance.ts +2 -2
- package/dist/types/Lch.d.ts +0 -16
- package/dist/types/Lch.d.ts.map +0 -1
- package/dist/types/Lch.js +0 -2
- package/dist/types/Lch.js.map +0 -1
- package/dist/utility/adobeToXyz.d.ts.map +0 -1
- package/dist/utility/adobeToXyz.js.map +0 -1
- package/dist/utility/cmyToCmyk.d.ts.map +0 -1
- package/dist/utility/cmyToCmyk.js.map +0 -1
- package/dist/utility/cmyToRgb.d.ts.map +0 -1
- package/dist/utility/cmyToRgb.js.map +0 -1
- package/dist/utility/cmykToCmy.d.ts.map +0 -1
- package/dist/utility/cmykToCmy.js.map +0 -1
- package/dist/utility/deltaC.d.ts.map +0 -1
- package/dist/utility/deltaCmc.d.ts.map +0 -1
- package/dist/utility/deltaCmc.js.map +0 -1
- package/dist/utility/deltaE00.d.ts.map +0 -1
- package/dist/utility/deltaE00.js.map +0 -1
- package/dist/utility/deltaE76.d.ts.map +0 -1
- package/dist/utility/deltaE94.d.ts.map +0 -1
- package/dist/utility/deltaE94.js.map +0 -1
- package/dist/utility/deltaH.d.ts.map +0 -1
- package/dist/utility/deltaH.js.map +0 -1
- package/dist/utility/hexToRgb.d.ts.map +0 -1
- package/dist/utility/hslToRgb.d.ts.map +0 -1
- package/dist/utility/hslToRgb.js.map +0 -1
- package/dist/utility/hsvToRgb.d.ts.map +0 -1
- package/dist/utility/hsvToRgb.js.map +0 -1
- package/dist/utility/hunterToXyz.d.ts.map +0 -1
- package/dist/utility/hunterToXyz.js.map +0 -1
- package/dist/utility/labToLch.d.ts +0 -11
- package/dist/utility/labToLch.d.ts.map +0 -1
- package/dist/utility/labToLch.js +0 -19
- package/dist/utility/labToLch.js.map +0 -1
- package/dist/utility/labToXyz.d.ts.map +0 -1
- package/dist/utility/labToXyz.js.map +0 -1
- package/dist/utility/lchToLab.d.ts +0 -11
- package/dist/utility/lchToLab.d.ts.map +0 -1
- package/dist/utility/lchToLab.js +0 -14
- package/dist/utility/lchToLab.js.map +0 -1
- package/dist/utility/luvToXyz.d.ts.map +0 -1
- package/dist/utility/luvToXyz.js.map +0 -1
- package/dist/utility/rgbToCmy.d.ts.map +0 -1
- package/dist/utility/rgbToCmy.js.map +0 -1
- package/dist/utility/rgbToHex.js.map +0 -1
- package/dist/utility/rgbToHsl.d.ts.map +0 -1
- package/dist/utility/rgbToHsl.js +0 -31
- package/dist/utility/rgbToHsl.js.map +0 -1
- package/dist/utility/rgbToHsv.d.ts.map +0 -1
- package/dist/utility/rgbToHsv.js.map +0 -1
- package/dist/utility/rgbToXyz.d.ts.map +0 -1
- package/dist/utility/rgbToXyz.js.map +0 -1
- package/dist/utility/xyzToAdobe.d.ts.map +0 -1
- package/dist/utility/xyzToAdobe.js.map +0 -1
- package/dist/utility/xyzToHunter.d.ts.map +0 -1
- package/dist/utility/xyzToHunter.js.map +0 -1
- package/dist/utility/xyzToLab.d.ts.map +0 -1
- package/dist/utility/xyzToLab.js.map +0 -1
- package/dist/utility/xyzToLuv.d.ts.map +0 -1
- package/dist/utility/xyzToLuv.js.map +0 -1
- package/dist/utility/xyzToRgb.d.ts.map +0 -1
- package/dist/utility/xyzToRgb.js.map +0 -1
- package/dist/utility/xyzToYxy.d.ts.map +0 -1
- package/dist/utility/xyzToYxy.js.map +0 -1
- package/dist/utility/yxyToXyz.d.ts.map +0 -1
- package/dist/utility/yxyToXyz.js.map +0 -1
- package/src/types/Lch.ts +0 -18
- package/src/utility/labToLch.ts +0 -24
- package/src/utility/lchToLab.ts +0 -18
- package/src/utility/rgbToHsl.ts +0 -38
- package/src/utility/xyzToAdobe.ts +0 -20
- /package/dist/{utility → convert}/cmyToRgb.js +0 -0
- /package/dist/{utility → convert}/hexToRgb.js +0 -0
- /package/dist/{utility → convert}/rgbToCmy.js +0 -0
- /package/dist/{utility → delta}/deltaC.js +0 -0
- /package/dist/{utility → delta}/deltaE76.js +0 -0
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type Hunter from "../types/Hunter.js";
|
|
2
|
-
import StandardIlluminant from "./StandardIlluminant.js";
|
|
3
2
|
import type Xyz from "../types/Xyz.js";
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import getReference from "../utility/getReference.js";
|
|
5
|
+
import StandardIlluminant from "../utility/StandardIlluminant.js";
|
|
6
|
+
|
|
7
|
+
const c0 = 175 / 198.04;
|
|
8
|
+
const c1 = 70 / 218.11;
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Convert the given Hunter Lab color to a CIEXYZ color. Based on the EasyRGB pseudo-code.
|
|
@@ -11,14 +15,13 @@ import getReference from "./getReference.js";
|
|
|
11
15
|
* @public
|
|
12
16
|
*/
|
|
13
17
|
export default function hunterToXyz(
|
|
14
|
-
color: Hunter
|
|
15
|
-
ref: Xyz = getReference(StandardIlluminant.D65_2)
|
|
16
|
-
): Xyz {
|
|
17
|
-
// eslint-disable-next-line prefer-destructuring
|
|
18
|
+
color: Readonly<Hunter>,
|
|
19
|
+
ref: Readonly<Xyz> = getReference(StandardIlluminant.D65_2)
|
|
20
|
+
): [number, number, number] & Xyz {
|
|
18
21
|
const rx = ref[0];
|
|
19
|
-
|
|
22
|
+
|
|
20
23
|
const ry = ref[1];
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
const rz = ref[2];
|
|
23
26
|
|
|
24
27
|
const y = (color[0] / ry) ** 2 * 100;
|
|
@@ -26,8 +29,8 @@ export default function hunterToXyz(
|
|
|
26
29
|
const i1 = Math.sqrt(i0);
|
|
27
30
|
|
|
28
31
|
return [
|
|
29
|
-
((color[1] / (
|
|
32
|
+
((color[1] / (c0 * (ry + rx))) * i1 + i0) * rx,
|
|
30
33
|
y,
|
|
31
|
-
-((color[2] / (
|
|
34
|
+
-((color[2] / (c1 * (ry + rz))) * i1 - i0) * rz
|
|
32
35
|
];
|
|
33
36
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type Lab from "../types/Lab.js";
|
|
2
|
+
import type Lchab from "../types/Lchab.js";
|
|
3
|
+
import type Lchuv from "../types/Lchuv.js";
|
|
4
|
+
import type Luv from "../types/Luv.js";
|
|
5
|
+
|
|
6
|
+
const c0 = 180 / Math.PI;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Convert the given CIELAB color to a CIELCh(ab) color. Based on the EasyRGB pseudo-code.
|
|
10
|
+
* @param color - The CIELAB color.
|
|
11
|
+
* @returns A CIELCh color.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export default function labToLch(
|
|
15
|
+
color: Readonly<Lab>
|
|
16
|
+
): [number, number, number] & Lchab;
|
|
17
|
+
/**
|
|
18
|
+
* Convert the given CIELUV color to a CIELCh(uv) color. Based on the EasyRGB pseudo-code.
|
|
19
|
+
* @param color - The CIELUV color.
|
|
20
|
+
* @returns A CIELCh color.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export default function labToLch(
|
|
24
|
+
color: Readonly<Luv>
|
|
25
|
+
): [number, number, number] & Lchuv;
|
|
26
|
+
export default function labToLch(
|
|
27
|
+
color: Readonly<Lab | Luv>
|
|
28
|
+
): [number, number, number] & (Lchab | Lchuv) {
|
|
29
|
+
const a = color[1];
|
|
30
|
+
|
|
31
|
+
const b = color[2];
|
|
32
|
+
|
|
33
|
+
const i0 = Math.atan2(b, a);
|
|
34
|
+
|
|
35
|
+
return [
|
|
36
|
+
color[0],
|
|
37
|
+
Math.hypot(a, b),
|
|
38
|
+
i0 > 0 ? i0 * c0 : 360 - Math.abs(i0) * c0
|
|
39
|
+
];
|
|
40
|
+
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type Lab from "../types/Lab.js";
|
|
2
|
-
import StandardIlluminant from "./StandardIlluminant.js";
|
|
3
2
|
import type Xyz from "../types/Xyz.js";
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import getReference from "../utility/getReference.js";
|
|
5
|
+
import StandardIlluminant from "../utility/StandardIlluminant.js";
|
|
6
|
+
|
|
7
|
+
const c0 = 0.008856;
|
|
8
|
+
const c1 = 16 / 116;
|
|
9
|
+
const c2 = 7.787;
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Convert the given CIELAB color to a CIEXYZ color. Based on the EasyRGB pseudo-code.
|
|
@@ -11,9 +16,9 @@ import getReference from "./getReference.js";
|
|
|
11
16
|
* @public
|
|
12
17
|
*/
|
|
13
18
|
export default function labToXyz(
|
|
14
|
-
color: Lab
|
|
15
|
-
ref: Xyz = getReference(StandardIlluminant.D65_2)
|
|
16
|
-
): Xyz {
|
|
19
|
+
color: Readonly<Lab>,
|
|
20
|
+
ref: Readonly<Xyz> = getReference(StandardIlluminant.D65_2)
|
|
21
|
+
): [number, number, number] & Xyz {
|
|
17
22
|
const i0 = (color[0] + 16) / 116;
|
|
18
23
|
const i1 = i0 ** 3;
|
|
19
24
|
const i2 = color[1] / 500 + i0;
|
|
@@ -22,8 +27,8 @@ export default function labToXyz(
|
|
|
22
27
|
const i5 = i4 ** 3;
|
|
23
28
|
|
|
24
29
|
return [
|
|
25
|
-
(i3 >
|
|
26
|
-
(i1 >
|
|
27
|
-
(i5 >
|
|
30
|
+
(i3 > c0 ? i3 : (i2 - c1) / c2) * ref[0],
|
|
31
|
+
(i1 > c0 ? i1 : (i0 - c1) / c2) * ref[1],
|
|
32
|
+
(i5 > c0 ? i5 : (i4 - c1) / c2) * ref[2]
|
|
28
33
|
];
|
|
29
34
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type Lab from "../types/Lab.js";
|
|
2
|
+
import type Lchab from "../types/Lchab.js";
|
|
3
|
+
import type Lchuv from "../types/Lchuv.js";
|
|
4
|
+
import type Luv from "../types/Luv.js";
|
|
5
|
+
|
|
6
|
+
const c0 = Math.PI / 180;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Convert the given CIELCh(ab) color to a CIELAB color. Based on the EasyRGB pseudo-code.
|
|
10
|
+
* @param color - The CIELCh color.
|
|
11
|
+
* @returns A CIELAB color.
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export default function lchToLab(
|
|
15
|
+
color: Readonly<Lchab>
|
|
16
|
+
): [number, number, number] & Lab;
|
|
17
|
+
/**
|
|
18
|
+
* Convert the given CIELCh(uv) color to a CIELUV color. Based on the EasyRGB pseudo-code.
|
|
19
|
+
* @param color - The CIELCh color.
|
|
20
|
+
* @returns A CIELUV color.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export default function lchToLab(
|
|
24
|
+
color: Readonly<Lchuv>
|
|
25
|
+
): [number, number, number] & Luv;
|
|
26
|
+
export default function lchToLab(
|
|
27
|
+
color: Readonly<Lchab | Lchuv>
|
|
28
|
+
): [number, number, number] & (Lab | Luv) {
|
|
29
|
+
const c = color[1];
|
|
30
|
+
|
|
31
|
+
const h = color[2];
|
|
32
|
+
|
|
33
|
+
return [color[0], Math.cos(h * c0) * c, Math.sin(h * c0) * c];
|
|
34
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type Luv from "../types/Luv.js";
|
|
2
|
-
import StandardIlluminant from "./StandardIlluminant.js";
|
|
3
2
|
import type Xyz from "../types/Xyz.js";
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import getReference from "../utility/getReference.js";
|
|
5
|
+
import StandardIlluminant from "../utility/StandardIlluminant.js";
|
|
6
|
+
|
|
7
|
+
const c0 = 16 / 116;
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Convert the given CIELUV color to a CIEXYZ color. Based on the EasyRGB pseudo-code.
|
|
@@ -11,14 +14,13 @@ import getReference from "./getReference.js";
|
|
|
11
14
|
* @public
|
|
12
15
|
*/
|
|
13
16
|
export default function luvToXyz(
|
|
14
|
-
color: Luv
|
|
15
|
-
ref: Xyz = getReference(StandardIlluminant.D65_2)
|
|
16
|
-
): Xyz {
|
|
17
|
-
// eslint-disable-next-line prefer-destructuring
|
|
17
|
+
color: Readonly<Luv>,
|
|
18
|
+
ref: Readonly<Xyz> = getReference(StandardIlluminant.D65_2)
|
|
19
|
+
): [number, number, number] & Xyz {
|
|
18
20
|
const l = color[0];
|
|
19
|
-
|
|
21
|
+
|
|
20
22
|
const rx = ref[0];
|
|
21
|
-
|
|
23
|
+
|
|
22
24
|
const ry = ref[1];
|
|
23
25
|
|
|
24
26
|
const i0 = (l + 16) / 116;
|
|
@@ -27,7 +29,7 @@ export default function luvToXyz(
|
|
|
27
29
|
const i3 = rx + 15 * ry + 3 * ref[2];
|
|
28
30
|
const i4 = color[1] / i2 + (4 * rx) / i3;
|
|
29
31
|
const i5 = color[2] / i2 + (9 * ry) / i3;
|
|
30
|
-
const y = (i1 > 0.008856 ? i1 : (i0 -
|
|
32
|
+
const y = (i1 > 0.008856 ? i1 : (i0 - c0) / 7.787) * 100; // `16 / 166`
|
|
31
33
|
const i6 = 9 * y;
|
|
32
34
|
const x = -(i6 * i4) / ((i4 - 4) * i5 - i4 * i5);
|
|
33
35
|
|
|
@@ -7,6 +7,8 @@ import type Rgb from "../types/Rgb.js";
|
|
|
7
7
|
* @returns A CMY color.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export default function rgbToCmy(
|
|
10
|
+
export default function rgbToCmy(
|
|
11
|
+
color: Readonly<Rgb>
|
|
12
|
+
): [number, number, number] & Cmy {
|
|
11
13
|
return [1 - color[0] / 0xff, 1 - color[1] / 0xff, 1 - color[2] / 0xff];
|
|
12
14
|
}
|
|
@@ -6,6 +6,10 @@ import type Rgb from "../types/Rgb.js";
|
|
|
6
6
|
* @returns The numerical hexadecimal representation of the color.
|
|
7
7
|
* @public
|
|
8
8
|
*/
|
|
9
|
-
export default function rgbToHex(rgb: Rgb): number {
|
|
10
|
-
return
|
|
9
|
+
export default function rgbToHex(rgb: Readonly<Rgb>): number {
|
|
10
|
+
return (
|
|
11
|
+
Math.round(rgb[0] * 0x10000) +
|
|
12
|
+
Math.round(rgb[1] * 0x100) +
|
|
13
|
+
Math.round(rgb[2])
|
|
14
|
+
);
|
|
11
15
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type Hsi from "../types/Hsi.js";
|
|
2
|
+
import type Rgb from "../types/Rgb.js";
|
|
3
|
+
|
|
4
|
+
const c0 = 1 / 3;
|
|
5
|
+
const c1 = 2 / 3;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert the given sRGB color to an HSI color.
|
|
9
|
+
* @param color - The sRGB color.
|
|
10
|
+
* @returns An HSI color.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export default function rgbToHsi(
|
|
14
|
+
color: Readonly<Rgb>
|
|
15
|
+
): [number, number, number] & Hsi {
|
|
16
|
+
const i0 = color[0] / 0xff;
|
|
17
|
+
const i1 = color[1] / 0xff;
|
|
18
|
+
const i2 = color[2] / 0xff;
|
|
19
|
+
const i = (i0 + i1 + i2) / 3;
|
|
20
|
+
const v = Math.max(i0, i1, i2);
|
|
21
|
+
const m = Math.min(i0, i1, i2);
|
|
22
|
+
const c = v - m;
|
|
23
|
+
|
|
24
|
+
if (c === 0) {
|
|
25
|
+
return [0, 0, i];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const i4 = c / 2;
|
|
29
|
+
const i5 = ((v - i0) / 6 + i4) / c;
|
|
30
|
+
const i6 = ((v - i1) / 6 + i4) / c;
|
|
31
|
+
const i7 = ((v - i2) / 6 + i4) / c;
|
|
32
|
+
const i8 =
|
|
33
|
+
i0 === v ? i7 - i6
|
|
34
|
+
: i1 === v ? c0 + i5 - i7
|
|
35
|
+
: i2 === v ? c1 + i6 - i5
|
|
36
|
+
: 0;
|
|
37
|
+
|
|
38
|
+
return [
|
|
39
|
+
i8 < 0 ? i8 + 1
|
|
40
|
+
: i8 > 1 ? i8 - 1
|
|
41
|
+
: i8,
|
|
42
|
+
i === 0 ? 0 : 1 - m / i,
|
|
43
|
+
i
|
|
44
|
+
];
|
|
45
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type Hsl from "../types/Hsl.js";
|
|
2
|
+
import type Rgb from "../types/Rgb.js";
|
|
3
|
+
|
|
4
|
+
const c0 = 1 / 3;
|
|
5
|
+
const c1 = 2 / 3;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert the given sRGB color to an HSL color. Based on the EasyRGB pseudo-code.
|
|
9
|
+
* @param color - The sRGB color.
|
|
10
|
+
* @returns An HSL color.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export default function rgbToHsl(
|
|
14
|
+
color: Readonly<Rgb>
|
|
15
|
+
): [number, number, number] & Hsl {
|
|
16
|
+
const i0 = color[0] / 0xff;
|
|
17
|
+
const i1 = color[1] / 0xff;
|
|
18
|
+
const i2 = color[2] / 0xff;
|
|
19
|
+
const i3 = Math.min(i0, i1, i2);
|
|
20
|
+
const i4 = Math.max(i0, i1, i2);
|
|
21
|
+
const i5 = i4 + i3;
|
|
22
|
+
const l = i5 / 2;
|
|
23
|
+
const i6 = i4 - i3;
|
|
24
|
+
|
|
25
|
+
if (i6 === 0) {
|
|
26
|
+
return [0, 0, l];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const i7 = i6 / 2;
|
|
30
|
+
const i8 = ((i4 - i0) / 6 + i7) / i6;
|
|
31
|
+
const i9 = ((i4 - i1) / 6 + i7) / i6;
|
|
32
|
+
const i10 = ((i4 - i2) / 6 + i7) / i6;
|
|
33
|
+
const i11 =
|
|
34
|
+
i0 === i4 ? i10 - i9
|
|
35
|
+
: i1 === i4 ? c0 + i8 - i10
|
|
36
|
+
: i2 === i4 ? c1 + i9 - i8
|
|
37
|
+
: 0;
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
i11 < 0 ? i11 + 1
|
|
41
|
+
: i11 > 1 ? i11 - 1
|
|
42
|
+
: i11,
|
|
43
|
+
l < 0.5 ? i6 / i5 : i6 / (2 - i4 - i3),
|
|
44
|
+
l
|
|
45
|
+
];
|
|
46
|
+
}
|
|
@@ -1,40 +1,43 @@
|
|
|
1
1
|
import type Hsv from "../types/Hsv.js";
|
|
2
2
|
import type Rgb from "../types/Rgb.js";
|
|
3
3
|
|
|
4
|
+
const c0 = 1 / 3;
|
|
5
|
+
const c1 = 2 / 3;
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Convert the given sRGB color to an HSV color. Based on the EasyRGB pseudo-code.
|
|
6
9
|
* @param color - The sRGB color.
|
|
7
10
|
* @returns An HSV color.
|
|
8
11
|
* @public
|
|
9
12
|
*/
|
|
10
|
-
export default function rgbToHsv(
|
|
13
|
+
export default function rgbToHsv(
|
|
14
|
+
color: Readonly<Rgb>
|
|
15
|
+
): [number, number, number] & Hsv {
|
|
11
16
|
const i0 = color[0] / 0xff;
|
|
12
17
|
const i1 = color[1] / 0xff;
|
|
13
18
|
const i2 = color[2] / 0xff;
|
|
14
19
|
const v = Math.max(i0, i1, i2);
|
|
15
|
-
const
|
|
20
|
+
const c = v - Math.min(i0, i1, i2);
|
|
16
21
|
|
|
17
|
-
if (
|
|
22
|
+
if (c === 0) {
|
|
18
23
|
return [0, 0, v];
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
const i4 =
|
|
22
|
-
const i5 = ((v - i0) / 6 + i4) /
|
|
23
|
-
const i6 = ((v - i1) / 6 + i4) /
|
|
24
|
-
const i7 = ((v - i2) / 6 + i4) /
|
|
26
|
+
const i4 = c / 2;
|
|
27
|
+
const i5 = ((v - i0) / 6 + i4) / c;
|
|
28
|
+
const i6 = ((v - i1) / 6 + i4) / c;
|
|
29
|
+
const i7 = ((v - i2) / 6 + i4) / c;
|
|
25
30
|
const i8 =
|
|
26
31
|
i0 === v ? i7 - i6
|
|
27
|
-
: i1 === v ?
|
|
28
|
-
|
|
29
|
-
:
|
|
30
|
-
0.66666666 + i6 - i5 // `2 / 3`
|
|
31
|
-
: 0;
|
|
32
|
+
: i1 === v ? c0 + i5 - i7
|
|
33
|
+
: i2 === v ? c1 + i6 - i5
|
|
34
|
+
: 0;
|
|
32
35
|
|
|
33
36
|
return [
|
|
34
37
|
i8 < 0 ? i8 + 1
|
|
35
38
|
: i8 > 1 ? i8 - 1
|
|
36
39
|
: i8,
|
|
37
|
-
|
|
40
|
+
v === 0 ? 0 : c / v,
|
|
38
41
|
v
|
|
39
42
|
];
|
|
40
43
|
}
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import type Rgb from "../types/Rgb.js";
|
|
2
2
|
import type Xyz from "../types/Xyz.js";
|
|
3
3
|
|
|
4
|
+
const c0 = 0.04045;
|
|
5
|
+
const c1 = 0.055;
|
|
6
|
+
const c2 = 1.055;
|
|
7
|
+
const c3 = 2.4;
|
|
8
|
+
const c4 = 12.92;
|
|
9
|
+
const c5 = 100;
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Convert the given sRGB color to a CIEXYZ color. Based on the EasyRGB pseudo-code.
|
|
6
13
|
* @param color - The sRGB color.
|
|
7
14
|
* @returns A CIEXYZ color.
|
|
8
15
|
* @public
|
|
9
16
|
*/
|
|
10
|
-
export default function rgbToXyz(
|
|
17
|
+
export default function rgbToXyz(
|
|
18
|
+
color: Readonly<Rgb>
|
|
19
|
+
): [number, number, number] & Xyz {
|
|
11
20
|
const i0 = color[0] / 0xff;
|
|
12
21
|
const i1 = color[1] / 0xff;
|
|
13
22
|
const i2 = color[2] / 0xff;
|
|
14
|
-
const i3 = (i0 >
|
|
15
|
-
const i4 = (i1 >
|
|
16
|
-
const i5 = (i2 >
|
|
23
|
+
const i3 = (i0 > c0 ? ((i0 + c1) / c2) ** c3 : i0 / c4) * c5;
|
|
24
|
+
const i4 = (i1 > c0 ? ((i1 + c1) / c2) ** c3 : i1 / c4) * c5;
|
|
25
|
+
const i5 = (i2 > c0 ? ((i2 + c1) / c2) ** c3 : i2 / c4) * c5;
|
|
17
26
|
|
|
18
27
|
return [
|
|
19
28
|
i3 * 0.4124 + i4 * 0.3576 + i5 * 0.1805,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type Adobe from "../types/Adobe.js";
|
|
2
|
+
import type Xyz from "../types/Xyz.js";
|
|
3
|
+
|
|
4
|
+
const gamma = 0x233 / 0x100; // https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf
|
|
5
|
+
const c0 = 1 / gamma;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Convert the given CIEXYZ D65/2° standard illuminant color to an Adobe RGB color. Based on the EasyRGB pseudo-code.
|
|
9
|
+
* @param color - The CIEXYZ color.
|
|
10
|
+
* @returns An Adobe RGB color.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export default function xyzToAdobe(
|
|
14
|
+
color: Readonly<Xyz>
|
|
15
|
+
): [number, number, number] & Adobe {
|
|
16
|
+
const i0 = color[0] / 100;
|
|
17
|
+
const i1 = color[1] / 100;
|
|
18
|
+
const i2 = color[2] / 100;
|
|
19
|
+
|
|
20
|
+
return [
|
|
21
|
+
(i0 * 2.04137 + i1 * -0.56495 + i2 * -0.34469) ** c0 * 0xff,
|
|
22
|
+
(i0 * -0.96927 + i1 * 1.87601 + i2 * 0.04156) ** c0 * 0xff,
|
|
23
|
+
(i0 * 0.01345 + i1 * -0.11839 + i2 * 1.01541) ** c0 * 0xff
|
|
24
|
+
];
|
|
25
|
+
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
import type Hunter from "../types/Hunter.js";
|
|
2
|
-
import StandardIlluminant from "./StandardIlluminant.js";
|
|
3
2
|
import type Xyz from "../types/Xyz.js";
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import getReference from "../utility/getReference.js";
|
|
5
|
+
import StandardIlluminant from "../utility/StandardIlluminant.js";
|
|
6
|
+
|
|
7
|
+
const c0 = 175 / 198.04;
|
|
8
|
+
const c1 = 70 / 218.11;
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Convert the given CIEXYZ color to a Hunter Lab color. Based on the EasyRGB pseudo-code.
|
|
8
12
|
* @param color - The CIEXYZ color.
|
|
9
|
-
* @param ref - A standard illuminant that represents the white point.
|
|
13
|
+
* @param ref - A standard illuminant that represents the white point. This color space was originally used with standard illuminant C.
|
|
10
14
|
* @returns A Hunter Lab color.
|
|
11
15
|
* @public
|
|
12
16
|
*/
|
|
13
17
|
export default function xyzToHunter(
|
|
14
|
-
color: Xyz
|
|
15
|
-
ref: Xyz = getReference(StandardIlluminant.D65_2)
|
|
16
|
-
): Hunter {
|
|
17
|
-
// eslint-disable-next-line prefer-destructuring
|
|
18
|
+
color: Readonly<Xyz>,
|
|
19
|
+
ref: Readonly<Xyz> = getReference(StandardIlluminant.D65_2)
|
|
20
|
+
): [number, number, number] & Hunter {
|
|
18
21
|
const rx = ref[0];
|
|
19
|
-
|
|
22
|
+
|
|
20
23
|
const ry = ref[1];
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
const rz = ref[2];
|
|
23
26
|
|
|
24
27
|
const i2 = color[1] / ry;
|
|
@@ -26,7 +29,7 @@ export default function xyzToHunter(
|
|
|
26
29
|
|
|
27
30
|
return [
|
|
28
31
|
100 * i3,
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
c0 * (ry + rx) * ((color[0] / rx - i2) / i3),
|
|
33
|
+
c1 * (ry + rz) * ((i2 - color[2] / rz) / i3)
|
|
31
34
|
];
|
|
32
35
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type Lab from "../types/Lab.js";
|
|
2
|
-
import StandardIlluminant from "./StandardIlluminant.js";
|
|
3
2
|
import type Xyz from "../types/Xyz.js";
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import getReference from "../utility/getReference.js";
|
|
5
|
+
import StandardIlluminant from "../utility/StandardIlluminant.js";
|
|
6
|
+
|
|
7
|
+
const c0 = 1 / 3;
|
|
8
|
+
const c1 = 16 / 116;
|
|
9
|
+
const c2 = 0.008856;
|
|
10
|
+
const c3 = 7.787;
|
|
5
11
|
|
|
6
12
|
/**
|
|
7
13
|
* Convert the given CIEXYZ color to a CIELAB color. Based on the EasyRGB pseudo-code.
|
|
@@ -11,17 +17,17 @@ import getReference from "./getReference.js";
|
|
|
11
17
|
* @public
|
|
12
18
|
*/
|
|
13
19
|
export default function xyzToLab(
|
|
14
|
-
color: Xyz
|
|
15
|
-
ref: Xyz = getReference(StandardIlluminant.D65_2)
|
|
16
|
-
): Lab {
|
|
20
|
+
color: Readonly<Xyz>,
|
|
21
|
+
ref: Readonly<Xyz> = getReference(StandardIlluminant.D65_2)
|
|
22
|
+
): [number, number, number] & Lab {
|
|
17
23
|
const i0 = color[0] / ref[0];
|
|
18
24
|
const i1 = color[1] / ref[1];
|
|
19
25
|
const i2 = color[2] / ref[2];
|
|
20
|
-
const i3 = i1 >
|
|
26
|
+
const i3 = i1 > c2 ? i1 ** c0 : c3 * i1 + c1;
|
|
21
27
|
|
|
22
28
|
return [
|
|
23
29
|
116 * i3 - 16,
|
|
24
|
-
500 * ((i0 >
|
|
25
|
-
200 * (i3 - (i2 >
|
|
30
|
+
500 * ((i0 > c2 ? i0 ** c0 : c3 * i0 + c1) - i3),
|
|
31
|
+
200 * (i3 - (i2 > c2 ? i2 ** c0 : c3 * i2 + c1))
|
|
26
32
|
];
|
|
27
33
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type Luv from "../types/Luv.js";
|
|
2
|
-
import StandardIlluminant from "./StandardIlluminant.js";
|
|
3
2
|
import type Xyz from "../types/Xyz.js";
|
|
4
|
-
|
|
3
|
+
|
|
4
|
+
import getReference from "../utility/getReference.js";
|
|
5
|
+
import StandardIlluminant from "../utility/StandardIlluminant.js";
|
|
6
|
+
|
|
7
|
+
const c0 = 1 / 3;
|
|
8
|
+
const c1 = 16 / 116;
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Convert the given CIEXYZ color to a CIELUV color. Based on the EasyRGB pseudo-code.
|
|
@@ -11,23 +15,21 @@ import getReference from "./getReference.js";
|
|
|
11
15
|
* @public
|
|
12
16
|
*/
|
|
13
17
|
export default function xyzToLuv(
|
|
14
|
-
color: Xyz
|
|
15
|
-
ref: Xyz = getReference(StandardIlluminant.D65_2)
|
|
16
|
-
): Luv {
|
|
17
|
-
// eslint-disable-next-line prefer-destructuring
|
|
18
|
+
color: Readonly<Xyz>,
|
|
19
|
+
ref: Readonly<Xyz> = getReference(StandardIlluminant.D65_2)
|
|
20
|
+
): [number, number, number] & Luv {
|
|
18
21
|
const x = color[0];
|
|
19
|
-
|
|
22
|
+
|
|
20
23
|
const y = color[1];
|
|
21
|
-
|
|
24
|
+
|
|
22
25
|
const rx = ref[0];
|
|
23
|
-
|
|
26
|
+
|
|
24
27
|
const ry = ref[1];
|
|
25
28
|
|
|
26
29
|
const i0 = x + 15 * y + 3 * color[2];
|
|
27
30
|
const i1 = rx + 15 * ry + 3 * ref[2];
|
|
28
31
|
const i2 = y / 100;
|
|
29
|
-
const l =
|
|
30
|
-
116 * (i2 > 0.008856 ? i2 ** 0.33333333 : 7.787 * i2 + 0.13793103) - 16; // `1 / 3`; `16 / 116`
|
|
32
|
+
const l = 116 * (i2 > 0.008856 ? i2 ** c0 : 7.787 * i2 + c1) - 16;
|
|
31
33
|
const i3 = 13 * l;
|
|
32
34
|
|
|
33
35
|
return [
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import type Rgb from "../types/Rgb.js";
|
|
2
2
|
import type Xyz from "../types/Xyz.js";
|
|
3
3
|
|
|
4
|
+
const c0 = 0.0031308;
|
|
5
|
+
const c1 = 1.055;
|
|
6
|
+
const c2 = 1 / 2.4;
|
|
7
|
+
const c3 = 0.055;
|
|
8
|
+
const c4 = 12.92;
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
11
|
* Convert the given CIEXYZ D65/2° standard illuminant color to an sRGB color. Based on the EasyRGB pseudo-code.
|
|
6
12
|
* @param color - The CIEXYZ color.
|
|
7
13
|
* @returns An sRGB color.
|
|
8
14
|
* @public
|
|
9
15
|
*/
|
|
10
|
-
export default function xyzToRgb(
|
|
16
|
+
export default function xyzToRgb(
|
|
17
|
+
color: Readonly<Xyz>
|
|
18
|
+
): [number, number, number] & Rgb {
|
|
11
19
|
const i0 = color[0] / 100;
|
|
12
20
|
const i1 = color[1] / 100;
|
|
13
21
|
const i2 = color[2] / 100;
|
|
@@ -16,8 +24,8 @@ export default function xyzToRgb(color: Xyz): Rgb {
|
|
|
16
24
|
const i5 = i0 * 0.0557 + i1 * -0.204 + i2 * 1.057;
|
|
17
25
|
|
|
18
26
|
return [
|
|
19
|
-
(i3 >
|
|
20
|
-
(i4 >
|
|
21
|
-
(i5 >
|
|
27
|
+
(i3 > c0 ? c1 * i3 ** c2 - c3 : i3 * c4) * 0xff,
|
|
28
|
+
(i4 > c0 ? c1 * i4 ** c2 - c3 : i4 * c4) * 0xff,
|
|
29
|
+
(i5 > c0 ? c1 * i5 ** c2 - c3 : i5 * c4) * 0xff
|
|
22
30
|
];
|
|
23
31
|
}
|
|
@@ -7,12 +7,13 @@ import type Yxy from "../types/Yxy.js";
|
|
|
7
7
|
* @returns The CIEXYZ color in yxy format.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export default function xyzToYxy(
|
|
11
|
-
|
|
10
|
+
export default function xyzToYxy(
|
|
11
|
+
color: Readonly<Xyz>
|
|
12
|
+
): [number, number, number] & Yxy {
|
|
12
13
|
const X = color[0];
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
const Y = color[1];
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
const Z = color[2];
|
|
17
18
|
|
|
18
19
|
return [Y, X / (X + Y + Z), Y / (X + Y + Z)];
|
|
@@ -7,12 +7,13 @@ import type Yxy from "../types/Yxy.js";
|
|
|
7
7
|
* @returns A CIEXYZ color.
|
|
8
8
|
* @public
|
|
9
9
|
*/
|
|
10
|
-
export default function yxyToXyz(
|
|
11
|
-
|
|
10
|
+
export default function yxyToXyz(
|
|
11
|
+
color: Readonly<Yxy>
|
|
12
|
+
): [number, number, number] & Xyz {
|
|
12
13
|
const Y = color[0];
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
const x = color[1];
|
|
15
|
-
|
|
16
|
+
|
|
16
17
|
const y = color[2];
|
|
17
18
|
|
|
18
19
|
return [x * (Y / y), Y, (1 - x - y) * (Y / y)];
|
|
@@ -9,8 +9,10 @@ import type Luv from "../types/Luv.js";
|
|
|
9
9
|
* @see {@link https://en.wikipedia.org/wiki/Color_difference | Color difference}
|
|
10
10
|
* @public
|
|
11
11
|
*/
|
|
12
|
-
export default function deltaC(
|
|
13
|
-
|
|
12
|
+
export default function deltaC(
|
|
13
|
+
color0: Readonly<Lab>,
|
|
14
|
+
color1: Readonly<Lab>
|
|
15
|
+
): number;
|
|
14
16
|
/**
|
|
15
17
|
* Calculates the ΔC* between two CIELUV values. Based on the EasyRGB pseudocode.
|
|
16
18
|
* @param color0 - The first color.
|
|
@@ -19,8 +21,13 @@ export default function deltaC(color0: Lab, color1: Lab): number;
|
|
|
19
21
|
* @see {@link https://en.wikipedia.org/wiki/Color_difference | Color difference}
|
|
20
22
|
* @public
|
|
21
23
|
*/
|
|
22
|
-
export default function deltaC(
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
export default function deltaC(
|
|
25
|
+
color0: Readonly<Luv>,
|
|
26
|
+
color1: Readonly<Luv>
|
|
27
|
+
): number;
|
|
28
|
+
export default function deltaC(
|
|
29
|
+
color0: Readonly<Lab | Luv>,
|
|
30
|
+
color1: Readonly<Lab | Luv>
|
|
31
|
+
): number {
|
|
25
32
|
return Math.hypot(color1[1], color1[2]) - Math.hypot(color0[1], color0[2]);
|
|
26
33
|
}
|