@lakuna/color 1.1.2 → 1.2.0

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.
Files changed (368) hide show
  1. package/LICENSE +1 -1
  2. package/dist/{utility → convert}/adobeToXyz.d.ts +1 -1
  3. package/dist/convert/adobeToXyz.d.ts.map +1 -0
  4. package/dist/{utility → convert}/adobeToXyz.js +5 -3
  5. package/dist/convert/adobeToXyz.js.map +1 -0
  6. package/dist/{utility → convert}/cmyToCmyk.d.ts +1 -1
  7. package/dist/convert/cmyToCmyk.d.ts.map +1 -0
  8. package/dist/{utility → convert}/cmyToCmyk.js +0 -3
  9. package/dist/convert/cmyToCmyk.js.map +1 -0
  10. package/dist/{utility → convert}/cmyToRgb.d.ts +1 -1
  11. package/dist/{utility → convert}/cmyToRgb.d.ts.map +1 -1
  12. package/dist/{utility → convert}/cmyToRgb.js.map +1 -1
  13. package/dist/{utility → convert}/cmykToCmy.d.ts +1 -1
  14. package/dist/{utility → convert}/cmykToCmy.d.ts.map +1 -1
  15. package/dist/{utility → convert}/cmykToCmy.js +0 -1
  16. package/dist/convert/cmykToCmy.js.map +1 -0
  17. package/dist/{utility → convert}/hexToRgb.d.ts +1 -1
  18. package/dist/convert/hexToRgb.d.ts.map +1 -0
  19. package/dist/{utility → convert}/hexToRgb.js.map +1 -1
  20. package/dist/{utility → convert}/hslToRgb.d.ts +1 -1
  21. package/dist/convert/hslToRgb.d.ts.map +1 -0
  22. package/dist/{utility → convert}/hslToRgb.js +5 -6
  23. package/dist/convert/hslToRgb.js.map +1 -0
  24. package/dist/{utility → convert}/hsvToRgb.d.ts +1 -1
  25. package/dist/{utility → convert}/hsvToRgb.d.ts.map +1 -1
  26. package/dist/{utility → convert}/hsvToRgb.js +0 -2
  27. package/dist/convert/hsvToRgb.js.map +1 -0
  28. package/dist/{utility → convert}/hunterToXyz.d.ts +1 -1
  29. package/dist/convert/hunterToXyz.d.ts.map +1 -0
  30. package/dist/{utility → convert}/hunterToXyz.js +6 -7
  31. package/dist/convert/hunterToXyz.js.map +1 -0
  32. package/dist/convert/labToLch.d.ts +19 -0
  33. package/dist/convert/labToLch.d.ts.map +1 -0
  34. package/dist/convert/labToLch.js +12 -0
  35. package/dist/convert/labToLch.js.map +1 -0
  36. package/dist/{utility → convert}/labToXyz.d.ts +1 -1
  37. package/dist/convert/labToXyz.d.ts.map +1 -0
  38. package/dist/{utility → convert}/labToXyz.js +8 -5
  39. package/dist/convert/labToXyz.js.map +1 -0
  40. package/dist/convert/lchToLab.d.ts +19 -0
  41. package/dist/convert/lchToLab.d.ts.map +1 -0
  42. package/dist/convert/lchToLab.js +7 -0
  43. package/dist/convert/lchToLab.js.map +1 -0
  44. package/dist/{utility → convert}/luvToXyz.d.ts +1 -1
  45. package/dist/convert/luvToXyz.d.ts.map +1 -0
  46. package/dist/{utility → convert}/luvToXyz.js +4 -6
  47. package/dist/convert/luvToXyz.js.map +1 -0
  48. package/dist/{utility → convert}/rgbToCmy.d.ts +1 -1
  49. package/dist/{utility → convert}/rgbToCmy.d.ts.map +1 -1
  50. package/dist/{utility → convert}/rgbToCmy.js.map +1 -1
  51. package/dist/{utility → convert}/rgbToHex.d.ts.map +1 -1
  52. package/dist/{utility → convert}/rgbToHex.js +3 -1
  53. package/dist/convert/rgbToHex.js.map +1 -0
  54. package/dist/convert/rgbToHsi.d.ts +10 -0
  55. package/dist/convert/rgbToHsi.d.ts.map +1 -0
  56. package/dist/convert/rgbToHsi.js +36 -0
  57. package/dist/convert/rgbToHsi.js.map +1 -0
  58. package/dist/{utility → convert}/rgbToHsl.d.ts +1 -1
  59. package/dist/convert/rgbToHsl.d.ts.map +1 -0
  60. package/dist/convert/rgbToHsl.js +37 -0
  61. package/dist/convert/rgbToHsl.js.map +1 -0
  62. package/dist/{utility → convert}/rgbToHsv.d.ts +1 -1
  63. package/dist/convert/rgbToHsv.d.ts.map +1 -0
  64. package/dist/{utility → convert}/rgbToHsv.js +11 -11
  65. package/dist/convert/rgbToHsv.js.map +1 -0
  66. package/dist/{utility → convert}/rgbToXyz.d.ts +1 -1
  67. package/dist/convert/rgbToXyz.d.ts.map +1 -0
  68. package/dist/{utility → convert}/rgbToXyz.js +9 -3
  69. package/dist/convert/rgbToXyz.js.map +1 -0
  70. package/dist/{utility → convert}/xyzToAdobe.d.ts +1 -1
  71. package/dist/convert/xyzToAdobe.d.ts.map +1 -0
  72. package/dist/{utility → convert}/xyzToAdobe.js +5 -3
  73. package/dist/convert/xyzToAdobe.js.map +1 -0
  74. package/dist/{utility → convert}/xyzToHunter.d.ts +2 -2
  75. package/dist/convert/xyzToHunter.d.ts.map +1 -0
  76. package/dist/{utility → convert}/xyzToHunter.js +7 -8
  77. package/dist/convert/xyzToHunter.js.map +1 -0
  78. package/dist/{utility → convert}/xyzToLab.d.ts +1 -1
  79. package/dist/convert/xyzToLab.d.ts.map +1 -0
  80. package/dist/{utility → convert}/xyzToLab.js +9 -5
  81. package/dist/convert/xyzToLab.js.map +1 -0
  82. package/dist/{utility → convert}/xyzToLuv.d.ts +1 -1
  83. package/dist/convert/xyzToLuv.d.ts.map +1 -0
  84. package/dist/{utility → convert}/xyzToLuv.js +5 -7
  85. package/dist/convert/xyzToLuv.js.map +1 -0
  86. package/dist/{utility → convert}/xyzToRgb.d.ts +1 -1
  87. package/dist/convert/xyzToRgb.d.ts.map +1 -0
  88. package/dist/{utility → convert}/xyzToRgb.js +8 -3
  89. package/dist/convert/xyzToRgb.js.map +1 -0
  90. package/dist/{utility → convert}/xyzToYxy.d.ts +1 -1
  91. package/dist/{utility → convert}/xyzToYxy.d.ts.map +1 -1
  92. package/dist/{utility → convert}/xyzToYxy.js +0 -3
  93. package/dist/convert/xyzToYxy.js.map +1 -0
  94. package/dist/{utility → convert}/yxyToXyz.d.ts +1 -1
  95. package/dist/{utility → convert}/yxyToXyz.d.ts.map +1 -1
  96. package/dist/{utility → convert}/yxyToXyz.js +0 -3
  97. package/dist/convert/yxyToXyz.js.map +1 -0
  98. package/dist/delta/deltaC.d.ts.map +1 -0
  99. package/dist/delta/deltaC.js.map +1 -0
  100. package/dist/{utility → delta}/deltaCmc.d.ts +2 -2
  101. package/dist/delta/deltaCmc.d.ts.map +1 -0
  102. package/dist/{utility → delta}/deltaCmc.js +5 -8
  103. package/dist/delta/deltaCmc.js.map +1 -0
  104. package/dist/{utility → delta}/deltaE00.d.ts +2 -2
  105. package/dist/delta/deltaE00.d.ts.map +1 -0
  106. package/dist/{utility → delta}/deltaE00.js +13 -17
  107. package/dist/delta/deltaE00.js.map +1 -0
  108. package/dist/delta/deltaE76.d.ts.map +1 -0
  109. package/dist/delta/deltaE76.js.map +1 -0
  110. package/dist/{utility → delta}/deltaE94.d.ts +2 -2
  111. package/dist/delta/deltaE94.d.ts.map +1 -0
  112. package/dist/{utility → delta}/deltaE94.js +0 -6
  113. package/dist/delta/deltaE94.js.map +1 -0
  114. package/dist/delta/deltaH.d.ts.map +1 -0
  115. package/dist/{utility → delta}/deltaH.js +0 -4
  116. package/dist/delta/deltaH.js.map +1 -0
  117. package/dist/index.d.ts +41 -31
  118. package/dist/index.d.ts.map +1 -1
  119. package/dist/index.js +41 -30
  120. package/dist/index.js.map +1 -1
  121. package/dist/names/bang.d.ts +2 -2
  122. package/dist/names/bang.d.ts.map +1 -1
  123. package/dist/names/bang.js +471 -471
  124. package/dist/names/bang.js.map +1 -1
  125. package/dist/names/cne.d.ts +1 -1
  126. package/dist/names/cne.d.ts.map +1 -1
  127. package/dist/names/cne.js +843 -843
  128. package/dist/names/cne.js.map +1 -1
  129. package/dist/names/crayola.d.ts +1 -1
  130. package/dist/names/crayola.d.ts.map +1 -1
  131. package/dist/names/crayola.js +110 -110
  132. package/dist/names/crayola.js.map +1 -1
  133. package/dist/names/getName.d.ts.map +1 -1
  134. package/dist/names/getName.js +3 -3
  135. package/dist/names/getName.js.map +1 -1
  136. package/dist/names/hollasch.d.ts +1 -1
  137. package/dist/names/hollasch.d.ts.map +1 -1
  138. package/dist/names/hollasch.js +179 -179
  139. package/dist/names/hollasch.js.map +1 -1
  140. package/dist/names/nbs.d.ts +1 -1
  141. package/dist/names/nbs.d.ts.map +1 -1
  142. package/dist/names/nbs.js +266 -266
  143. package/dist/names/nbs.js.map +1 -1
  144. package/dist/names/ntc.d.ts +1 -1
  145. package/dist/names/ntc.d.ts.map +1 -1
  146. package/dist/names/ntc.js +1519 -1519
  147. package/dist/names/ntc.js.map +1 -1
  148. package/dist/names/resene.d.ts +1 -1
  149. package/dist/names/resene.d.ts.map +1 -1
  150. package/dist/names/resene.js +1331 -1331
  151. package/dist/names/resene.js.map +1 -1
  152. package/dist/names/tcapi.d.ts +1 -1
  153. package/dist/names/tcapi.d.ts.map +1 -1
  154. package/dist/names/tcapi.js +1840 -1840
  155. package/dist/names/tcapi.js.map +1 -1
  156. package/dist/names/x11.d.ts +1 -1
  157. package/dist/names/x11.d.ts.map +1 -1
  158. package/dist/names/x11.js +445 -445
  159. package/dist/names/x11.js.map +1 -1
  160. package/dist/names/xkcd.d.ts +1 -1
  161. package/dist/names/xkcd.d.ts.map +1 -1
  162. package/dist/names/xkcd.js +897 -897
  163. package/dist/names/xkcd.js.map +1 -1
  164. package/dist/palette/analogous.d.ts +28 -0
  165. package/dist/palette/analogous.d.ts.map +1 -0
  166. package/dist/palette/analogous.js +15 -0
  167. package/dist/palette/analogous.js.map +1 -0
  168. package/dist/palette/analogousLch.d.ts +19 -0
  169. package/dist/palette/analogousLch.d.ts.map +1 -0
  170. package/dist/palette/analogousLch.js +15 -0
  171. package/dist/palette/analogousLch.js.map +1 -0
  172. package/dist/palette/complement.d.ts +28 -0
  173. package/dist/palette/complement.d.ts.map +1 -0
  174. package/dist/palette/complement.js +15 -0
  175. package/dist/palette/complement.js.map +1 -0
  176. package/dist/palette/complementLch.d.ts +19 -0
  177. package/dist/palette/complementLch.d.ts.map +1 -0
  178. package/dist/palette/complementLch.js +15 -0
  179. package/dist/palette/complementLch.js.map +1 -0
  180. package/dist/palette/splitComplement.d.ts +28 -0
  181. package/dist/palette/splitComplement.d.ts.map +1 -0
  182. package/dist/palette/splitComplement.js +15 -0
  183. package/dist/palette/splitComplement.js.map +1 -0
  184. package/dist/palette/splitComplementLch.d.ts +19 -0
  185. package/dist/palette/splitComplementLch.d.ts.map +1 -0
  186. package/dist/palette/splitComplementLch.js +15 -0
  187. package/dist/palette/splitComplementLch.js.map +1 -0
  188. package/dist/types/Adobe.d.ts.map +1 -1
  189. package/dist/types/Cmy.d.ts.map +1 -1
  190. package/dist/types/Cmyk.d.ts.map +1 -1
  191. package/dist/types/Hsi.d.ts +15 -0
  192. package/dist/types/Hsi.d.ts.map +1 -0
  193. package/dist/types/Hsi.js +2 -0
  194. package/dist/types/Hsi.js.map +1 -0
  195. package/dist/types/Hsl.d.ts +1 -1
  196. package/dist/types/Hsl.d.ts.map +1 -1
  197. package/dist/types/Hsv.d.ts +1 -1
  198. package/dist/types/Hsv.d.ts.map +1 -1
  199. package/dist/types/Hunter.d.ts.map +1 -1
  200. package/dist/types/Lab.d.ts +2 -2
  201. package/dist/types/Lab.d.ts.map +1 -1
  202. package/dist/types/Lchab.d.ts +15 -0
  203. package/dist/types/Lchab.d.ts.map +1 -0
  204. package/dist/types/Lchab.js +2 -0
  205. package/dist/types/Lchab.js.map +1 -0
  206. package/dist/types/Lchuv.d.ts +15 -0
  207. package/dist/types/Lchuv.d.ts.map +1 -0
  208. package/dist/types/Lchuv.js +2 -0
  209. package/dist/types/Lchuv.js.map +1 -0
  210. package/dist/types/Luv.d.ts +1 -1
  211. package/dist/types/Luv.d.ts.map +1 -1
  212. package/dist/types/Rgb.d.ts.map +1 -1
  213. package/dist/types/Xyz.d.ts.map +1 -1
  214. package/dist/types/Yxy.d.ts.map +1 -1
  215. package/dist/utility/StandardIlluminant.d.ts.map +1 -1
  216. package/dist/utility/StandardIlluminant.js.map +1 -1
  217. package/dist/utility/contrast.d.ts.map +1 -1
  218. package/dist/utility/contrast.js.map +1 -1
  219. package/dist/utility/getReference.d.ts +2 -2
  220. package/dist/utility/getReference.d.ts.map +1 -1
  221. package/dist/utility/getReference.js +39 -39
  222. package/dist/utility/getReference.js.map +1 -1
  223. package/dist/utility/isWebSafe.d.ts +10 -0
  224. package/dist/utility/isWebSafe.d.ts.map +1 -0
  225. package/dist/utility/isWebSafe.js +11 -0
  226. package/dist/utility/isWebSafe.js.map +1 -0
  227. package/dist/utility/relativeLuminance.js.map +1 -1
  228. package/package.json +15 -15
  229. package/src/{utility → convert}/adobeToXyz.ts +10 -4
  230. package/src/{utility → convert}/cmyToCmyk.ts +5 -4
  231. package/src/{utility → convert}/cmyToRgb.ts +1 -1
  232. package/src/{utility → convert}/cmykToCmy.ts +1 -2
  233. package/src/{utility → convert}/hexToRgb.ts +1 -1
  234. package/src/{utility → convert}/hslToRgb.ts +9 -7
  235. package/src/{utility → convert}/hsvToRgb.ts +2 -3
  236. package/src/{utility → convert}/hunterToXyz.ts +11 -8
  237. package/src/convert/labToLch.ts +36 -0
  238. package/src/{utility → convert}/labToXyz.ts +11 -6
  239. package/src/convert/lchToLab.ts +30 -0
  240. package/src/{utility → convert}/luvToXyz.ts +9 -7
  241. package/src/{utility → convert}/rgbToCmy.ts +1 -1
  242. package/src/{utility → convert}/rgbToHex.ts +5 -1
  243. package/src/convert/rgbToHsi.ts +43 -0
  244. package/src/convert/rgbToHsl.ts +44 -0
  245. package/src/{utility → convert}/rgbToHsv.ts +14 -13
  246. package/src/{utility → convert}/rgbToXyz.ts +11 -4
  247. package/src/{utility → convert}/xyzToAdobe.ts +9 -4
  248. package/src/{utility → convert}/xyzToHunter.ts +12 -9
  249. package/src/{utility → convert}/xyzToLab.ts +12 -6
  250. package/src/{utility → convert}/xyzToLuv.ts +11 -9
  251. package/src/{utility → convert}/xyzToRgb.ts +10 -4
  252. package/src/{utility → convert}/xyzToYxy.ts +3 -4
  253. package/src/{utility → convert}/yxyToXyz.ts +3 -4
  254. package/src/{utility → delta}/deltaC.ts +0 -2
  255. package/src/{utility → delta}/deltaCmc.ts +12 -10
  256. package/src/{utility → delta}/deltaE00.ts +21 -18
  257. package/src/{utility → delta}/deltaE76.ts +0 -2
  258. package/src/{utility → delta}/deltaE94.ts +7 -8
  259. package/src/{utility → delta}/deltaH.ts +3 -6
  260. package/src/index.ts +47 -31
  261. package/src/names/bang.ts +476 -472
  262. package/src/names/cne.ts +848 -844
  263. package/src/names/crayola.ts +115 -111
  264. package/src/names/getName.ts +4 -3
  265. package/src/names/hollasch.ts +184 -180
  266. package/src/names/nbs.ts +271 -267
  267. package/src/names/ntc.ts +1524 -1520
  268. package/src/names/resene.ts +1336 -1332
  269. package/src/names/tcapi.ts +1845 -1841
  270. package/src/names/x11.ts +450 -446
  271. package/src/names/xkcd.ts +902 -898
  272. package/src/palette/analogous.ts +61 -0
  273. package/src/palette/analogousLch.ts +49 -0
  274. package/src/palette/complement.ts +65 -0
  275. package/src/palette/complementLch.ts +50 -0
  276. package/src/palette/splitComplement.ts +61 -0
  277. package/src/palette/splitComplementLch.ts +48 -0
  278. package/src/types/Adobe.ts +3 -0
  279. package/src/types/Cmy.ts +3 -0
  280. package/src/types/Cmyk.ts +4 -0
  281. package/src/types/Hsi.ts +20 -0
  282. package/src/types/Hsl.ts +4 -1
  283. package/src/types/Hsv.ts +4 -1
  284. package/src/types/Hunter.ts +3 -0
  285. package/src/types/Lab.ts +5 -2
  286. package/src/types/Lchab.ts +20 -0
  287. package/src/types/Lchuv.ts +20 -0
  288. package/src/types/Luv.ts +4 -1
  289. package/src/types/Rgb.ts +3 -0
  290. package/src/types/Xyz.ts +3 -0
  291. package/src/types/Yxy.ts +3 -0
  292. package/src/utility/StandardIlluminant.ts +40 -40
  293. package/src/utility/contrast.ts +1 -0
  294. package/src/utility/getReference.ts +42 -41
  295. package/src/utility/isWebSafe.ts +14 -0
  296. package/src/utility/relativeLuminance.ts +1 -1
  297. package/dist/types/Lch.d.ts +0 -16
  298. package/dist/types/Lch.d.ts.map +0 -1
  299. package/dist/types/Lch.js +0 -2
  300. package/dist/types/Lch.js.map +0 -1
  301. package/dist/utility/adobeToXyz.d.ts.map +0 -1
  302. package/dist/utility/adobeToXyz.js.map +0 -1
  303. package/dist/utility/cmyToCmyk.d.ts.map +0 -1
  304. package/dist/utility/cmyToCmyk.js.map +0 -1
  305. package/dist/utility/cmykToCmy.js.map +0 -1
  306. package/dist/utility/deltaC.d.ts.map +0 -1
  307. package/dist/utility/deltaC.js.map +0 -1
  308. package/dist/utility/deltaCmc.d.ts.map +0 -1
  309. package/dist/utility/deltaCmc.js.map +0 -1
  310. package/dist/utility/deltaE00.d.ts.map +0 -1
  311. package/dist/utility/deltaE00.js.map +0 -1
  312. package/dist/utility/deltaE76.d.ts.map +0 -1
  313. package/dist/utility/deltaE76.js.map +0 -1
  314. package/dist/utility/deltaE94.d.ts.map +0 -1
  315. package/dist/utility/deltaE94.js.map +0 -1
  316. package/dist/utility/deltaH.d.ts.map +0 -1
  317. package/dist/utility/deltaH.js.map +0 -1
  318. package/dist/utility/hexToRgb.d.ts.map +0 -1
  319. package/dist/utility/hslToRgb.d.ts.map +0 -1
  320. package/dist/utility/hslToRgb.js.map +0 -1
  321. package/dist/utility/hsvToRgb.js.map +0 -1
  322. package/dist/utility/hunterToXyz.d.ts.map +0 -1
  323. package/dist/utility/hunterToXyz.js.map +0 -1
  324. package/dist/utility/labToLch.d.ts +0 -11
  325. package/dist/utility/labToLch.d.ts.map +0 -1
  326. package/dist/utility/labToLch.js +0 -19
  327. package/dist/utility/labToLch.js.map +0 -1
  328. package/dist/utility/labToXyz.d.ts.map +0 -1
  329. package/dist/utility/labToXyz.js.map +0 -1
  330. package/dist/utility/lchToLab.d.ts +0 -11
  331. package/dist/utility/lchToLab.d.ts.map +0 -1
  332. package/dist/utility/lchToLab.js +0 -14
  333. package/dist/utility/lchToLab.js.map +0 -1
  334. package/dist/utility/luvToXyz.d.ts.map +0 -1
  335. package/dist/utility/luvToXyz.js.map +0 -1
  336. package/dist/utility/rgbToHex.js.map +0 -1
  337. package/dist/utility/rgbToHsl.d.ts.map +0 -1
  338. package/dist/utility/rgbToHsl.js +0 -31
  339. package/dist/utility/rgbToHsl.js.map +0 -1
  340. package/dist/utility/rgbToHsv.d.ts.map +0 -1
  341. package/dist/utility/rgbToHsv.js.map +0 -1
  342. package/dist/utility/rgbToXyz.d.ts.map +0 -1
  343. package/dist/utility/rgbToXyz.js.map +0 -1
  344. package/dist/utility/xyzToAdobe.d.ts.map +0 -1
  345. package/dist/utility/xyzToAdobe.js.map +0 -1
  346. package/dist/utility/xyzToHunter.d.ts.map +0 -1
  347. package/dist/utility/xyzToHunter.js.map +0 -1
  348. package/dist/utility/xyzToLab.d.ts.map +0 -1
  349. package/dist/utility/xyzToLab.js.map +0 -1
  350. package/dist/utility/xyzToLuv.d.ts.map +0 -1
  351. package/dist/utility/xyzToLuv.js.map +0 -1
  352. package/dist/utility/xyzToRgb.d.ts.map +0 -1
  353. package/dist/utility/xyzToRgb.js.map +0 -1
  354. package/dist/utility/xyzToYxy.js.map +0 -1
  355. package/dist/utility/yxyToXyz.js.map +0 -1
  356. package/src/types/Lch.ts +0 -18
  357. package/src/utility/labToLch.ts +0 -24
  358. package/src/utility/lchToLab.ts +0 -18
  359. package/src/utility/rgbToHsl.ts +0 -38
  360. /package/dist/{utility → convert}/cmyToRgb.js +0 -0
  361. /package/dist/{utility → convert}/hexToRgb.js +0 -0
  362. /package/dist/{utility → convert}/rgbToCmy.js +0 -0
  363. /package/dist/{utility → convert}/rgbToHex.d.ts +0 -0
  364. /package/dist/{utility → delta}/deltaC.d.ts +0 -0
  365. /package/dist/{utility → delta}/deltaC.js +0 -0
  366. /package/dist/{utility → delta}/deltaE76.d.ts +0 -0
  367. /package/dist/{utility → delta}/deltaE76.js +0 -0
  368. /package/dist/{utility → delta}/deltaH.d.ts +0 -0
@@ -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
- import getReference from "./getReference.js";
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.
@@ -13,7 +18,7 @@ import getReference from "./getReference.js";
13
18
  export default function labToXyz(
14
19
  color: Lab,
15
20
  ref: Xyz = getReference(StandardIlluminant.D65_2)
16
- ): Xyz {
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 > 0.008856 ? i3 : (i2 - 0.13793103) / 7.787) * ref[0], // `16 / 116`
26
- (i1 > 0.008856 ? i1 : (i0 - 0.13793103) / 7.787) * ref[1], // `16 / 116`
27
- (i5 > 0.008856 ? i5 : (i4 - 0.13793103) / 7.787) * ref[2] // `16 / 116`
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,30 @@
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(color: Lchab): [number, number, number] & Lab;
15
+ /**
16
+ * Convert the given CIELCh(uv) color to a CIELUV color. Based on the EasyRGB pseudo-code.
17
+ * @param color - The CIELCh color.
18
+ * @returns A CIELUV color.
19
+ * @public
20
+ */
21
+ export default function lchToLab(color: Lchuv): [number, number, number] & Luv;
22
+ export default function lchToLab(
23
+ color: Lchab
24
+ ): [number, number, number] & (Lab | Luv) {
25
+ const c = color[1];
26
+
27
+ const h = color[2];
28
+
29
+ return [color[0], Math.cos(h * c0) * c, Math.sin(h * c0) * c];
30
+ }
@@ -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
- import getReference from "./getReference.js";
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.
@@ -13,12 +16,11 @@ import getReference from "./getReference.js";
13
16
  export default function luvToXyz(
14
17
  color: Luv,
15
18
  ref: Xyz = getReference(StandardIlluminant.D65_2)
16
- ): Xyz {
17
- // eslint-disable-next-line prefer-destructuring
19
+ ): [number, number, number] & Xyz {
18
20
  const l = color[0];
19
- // eslint-disable-next-line prefer-destructuring
21
+
20
22
  const rx = ref[0];
21
- // eslint-disable-next-line prefer-destructuring
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 - 0.13793103) / 7.787) * 100; // `16 / 166`
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,6 @@ import type Rgb from "../types/Rgb.js";
7
7
  * @returns A CMY color.
8
8
  * @public
9
9
  */
10
- export default function rgbToCmy(color: Rgb): Cmy {
10
+ export default function rgbToCmy(color: Rgb): [number, number, number] & Cmy {
11
11
  return [1 - color[0] / 0xff, 1 - color[1] / 0xff, 1 - color[2] / 0xff];
12
12
  }
@@ -7,5 +7,9 @@ import type Rgb from "../types/Rgb.js";
7
7
  * @public
8
8
  */
9
9
  export default function rgbToHex(rgb: Rgb): number {
10
- return rgb[0] * 0x10000 + rgb[1] * 0x100 + rgb[2];
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,43 @@
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(color: Rgb): [number, number, number] & Hsi {
14
+ const i0 = color[0] / 0xff;
15
+ const i1 = color[1] / 0xff;
16
+ const i2 = color[2] / 0xff;
17
+ const i = (i0 + i1 + i2) / 3;
18
+ const v = Math.max(i0, i1, i2);
19
+ const m = Math.min(i0, i1, i2);
20
+ const c = v - m;
21
+
22
+ if (c === 0) {
23
+ return [0, 0, i];
24
+ }
25
+
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;
30
+ const i8 =
31
+ i0 === v ? i7 - i6
32
+ : i1 === v ? c0 + i5 - i7
33
+ : i2 === v ? c1 + i6 - i5
34
+ : 0;
35
+
36
+ return [
37
+ i8 < 0 ? i8 + 1
38
+ : i8 > 1 ? i8 - 1
39
+ : i8,
40
+ i === 0 ? 0 : 1 - m / i,
41
+ i
42
+ ];
43
+ }
@@ -0,0 +1,44 @@
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(color: Rgb): [number, number, number] & Hsl {
14
+ const i0 = color[0] / 0xff;
15
+ const i1 = color[1] / 0xff;
16
+ const i2 = color[2] / 0xff;
17
+ const i3 = Math.min(i0, i1, i2);
18
+ const i4 = Math.max(i0, i1, i2);
19
+ const i5 = i4 + i3;
20
+ const l = i5 / 2;
21
+ const i6 = i4 - i3;
22
+
23
+ if (i6 === 0) {
24
+ return [0, 0, l];
25
+ }
26
+
27
+ const i7 = i6 / 2;
28
+ const i8 = ((i4 - i0) / 6 + i7) / i6;
29
+ const i9 = ((i4 - i1) / 6 + i7) / i6;
30
+ const i10 = ((i4 - i2) / 6 + i7) / i6;
31
+ const i11 =
32
+ i0 === i4 ? i10 - i9
33
+ : i1 === i4 ? c0 + i8 - i10
34
+ : i2 === i4 ? c1 + i9 - i8
35
+ : 0;
36
+
37
+ return [
38
+ i11 < 0 ? i11 + 1
39
+ : i11 > 1 ? i11 - 1
40
+ : i11,
41
+ l < 0.5 ? i6 / i5 : i6 / (2 - i4 - i3),
42
+ l
43
+ ];
44
+ }
@@ -1,40 +1,41 @@
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(color: Rgb): Hsv {
13
+ export default function rgbToHsv(color: Rgb): [number, number, number] & Hsv {
11
14
  const i0 = color[0] / 0xff;
12
15
  const i1 = color[1] / 0xff;
13
16
  const i2 = color[2] / 0xff;
14
17
  const v = Math.max(i0, i1, i2);
15
- const i3 = v - Math.min(i0, i1, i2);
18
+ const c = v - Math.min(i0, i1, i2);
16
19
 
17
- if (i3 === 0) {
20
+ if (c === 0) {
18
21
  return [0, 0, v];
19
22
  }
20
23
 
21
- const i4 = i3 / 2;
22
- const i5 = ((v - i0) / 6 + i4) / i3;
23
- const i6 = ((v - i1) / 6 + i4) / i3;
24
- const i7 = ((v - i2) / 6 + i4) / i3;
24
+ const i4 = c / 2;
25
+ const i5 = ((v - i0) / 6 + i4) / c;
26
+ const i6 = ((v - i1) / 6 + i4) / c;
27
+ const i7 = ((v - i2) / 6 + i4) / c;
25
28
  const i8 =
26
29
  i0 === v ? i7 - i6
27
- : i1 === v ?
28
- 0.33333333 + i5 - i7 // `1 / 3`
29
- : i2 === v ?
30
- 0.66666666 + i6 - i5 // `2 / 3`
31
- : 0;
30
+ : i1 === v ? c0 + i5 - i7
31
+ : i2 === v ? c1 + i6 - i5
32
+ : 0;
32
33
 
33
34
  return [
34
35
  i8 < 0 ? i8 + 1
35
36
  : i8 > 1 ? i8 - 1
36
37
  : i8,
37
- i3 / v,
38
+ v === 0 ? 0 : c / v,
38
39
  v
39
40
  ];
40
41
  }
@@ -1,19 +1,26 @@
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(color: Rgb): Xyz {
17
+ export default function rgbToXyz(color: Rgb): [number, number, number] & Xyz {
11
18
  const i0 = color[0] / 0xff;
12
19
  const i1 = color[1] / 0xff;
13
20
  const i2 = color[2] / 0xff;
14
- const i3 = (i0 > 0.04045 ? ((i0 + 0.055) / 1.055) ** 2.4 : i0 / 12.92) * 100;
15
- const i4 = (i1 > 0.04045 ? ((i1 + 0.055) / 1.055) ** 2.4 : i1 / 12.92) * 100;
16
- const i5 = (i2 > 0.04045 ? ((i2 + 0.055) / 1.055) ** 2.4 : i2 / 12.92) * 100;
21
+ const i3 = (i0 > c0 ? ((i0 + c1) / c2) ** c3 : i0 / c4) * c5;
22
+ const i4 = (i1 > c0 ? ((i1 + c1) / c2) ** c3 : i1 / c4) * c5;
23
+ const i5 = (i2 > c0 ? ((i2 + c1) / c2) ** c3 : i2 / c4) * c5;
17
24
 
18
25
  return [
19
26
  i3 * 0.4124 + i4 * 0.3576 + i5 * 0.1805,
@@ -1,20 +1,25 @@
1
1
  import type Adobe from "../types/Adobe.js";
2
2
  import type Xyz from "../types/Xyz.js";
3
3
 
4
+ const gamma = 0x233 / 0x100; // https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf
5
+ const c0 = 1 / gamma;
6
+
4
7
  /**
5
8
  * Convert the given CIEXYZ D65/2° standard illuminant color to an Adobe RGB color. Based on the EasyRGB pseudo-code.
6
9
  * @param color - The CIEXYZ color.
7
10
  * @returns An Adobe RGB color.
8
11
  * @public
9
12
  */
10
- export default function xyzToAdobe(color: Xyz): Adobe {
13
+ export default function xyzToAdobe(
14
+ color: Xyz
15
+ ): [number, number, number] & Adobe {
11
16
  const i0 = color[0] / 100;
12
17
  const i1 = color[1] / 100;
13
18
  const i2 = color[2] / 100;
14
19
 
15
20
  return [
16
- (i0 * 2.04137 + i1 * -0.56495 + i2 * -0.34469) ** 0.45470693 * 0xff, // `1 / 2.19921875`
17
- (i0 * -0.96927 + i1 * 1.87601 + i2 * 0.04156) ** 0.45470693 * 0xff, // `1 / 2.19921875`
18
- (i0 * 0.01345 + i1 * -0.11839 + i2 * 1.01541) ** 0.45470693 * 0xff // `1 / 2.19921875`
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
19
24
  ];
20
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
- import getReference from "./getReference.js";
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
18
  color: Xyz,
15
19
  ref: Xyz = getReference(StandardIlluminant.D65_2)
16
- ): Hunter {
17
- // eslint-disable-next-line prefer-destructuring
20
+ ): [number, number, number] & Hunter {
18
21
  const rx = ref[0];
19
- // eslint-disable-next-line prefer-destructuring
22
+
20
23
  const ry = ref[1];
21
- // eslint-disable-next-line prefer-destructuring
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
- 0.88365987 * (ry + rx) * ((color[0] / rx - i2) / i3), // `175 / 198.04`
30
- 0.32093898 * (ry + rz) * ((i2 - color[2] / rz) / i3) // `70 / 218.11`
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
- import getReference from "./getReference.js";
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.
@@ -13,15 +19,15 @@ import getReference from "./getReference.js";
13
19
  export default function xyzToLab(
14
20
  color: Xyz,
15
21
  ref: Xyz = getReference(StandardIlluminant.D65_2)
16
- ): Lab {
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 > 0.008856 ? i1 ** 0.33333333 : 7.787 * i1 + 0.13793103; // `1 / 3`; `16 / 116`
26
+ const i3 = i1 > c2 ? i1 ** c0 : c3 * i1 + c1;
21
27
 
22
28
  return [
23
29
  116 * i3 - 16,
24
- 500 * ((i0 > 0.008856 ? i0 ** 0.33333333 : 7.787 * i0 + 0.13793103) - i3), // `1 / 3`; `16 / 116`
25
- 200 * (i3 - (i2 > 0.008856 ? i2 ** 0.33333333 : 7.787 * i2 + 0.13793103)) // `1 / 3`; `16 / 116`
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
- import getReference from "./getReference.js";
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.
@@ -13,21 +17,19 @@ import getReference from "./getReference.js";
13
17
  export default function xyzToLuv(
14
18
  color: Xyz,
15
19
  ref: Xyz = getReference(StandardIlluminant.D65_2)
16
- ): Luv {
17
- // eslint-disable-next-line prefer-destructuring
20
+ ): [number, number, number] & Luv {
18
21
  const x = color[0];
19
- // eslint-disable-next-line prefer-destructuring
22
+
20
23
  const y = color[1];
21
- // eslint-disable-next-line prefer-destructuring
24
+
22
25
  const rx = ref[0];
23
- // eslint-disable-next-line prefer-destructuring
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,19 @@
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(color: Xyz): Rgb {
16
+ export default function xyzToRgb(color: Xyz): [number, number, number] & Rgb {
11
17
  const i0 = color[0] / 100;
12
18
  const i1 = color[1] / 100;
13
19
  const i2 = color[2] / 100;
@@ -16,8 +22,8 @@ export default function xyzToRgb(color: Xyz): Rgb {
16
22
  const i5 = i0 * 0.0557 + i1 * -0.204 + i2 * 1.057;
17
23
 
18
24
  return [
19
- (i3 > 0.0031308 ? 1.055 * i3 ** 0.41666666 - 0.055 : i3 * 12.92) * 0xff, // `1 / 2.4`
20
- (i4 > 0.0031308 ? 1.055 * i4 ** 0.41666666 - 0.055 : i4 * 12.92) * 0xff, // `1 / 2.4`
21
- (i5 > 0.0031308 ? 1.055 * i5 ** 0.41666666 - 0.055 : i5 * 12.92) * 0xff // `1 / 2.4`
25
+ (i3 > c0 ? c1 * i3 ** c2 - c3 : i3 * c4) * 0xff,
26
+ (i4 > c0 ? c1 * i4 ** c2 - c3 : i4 * c4) * 0xff,
27
+ (i5 > c0 ? c1 * i5 ** c2 - c3 : i5 * c4) * 0xff
22
28
  ];
23
29
  }
@@ -7,12 +7,11 @@ 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(color: Xyz): Yxy {
11
- // eslint-disable-next-line prefer-destructuring
10
+ export default function xyzToYxy(color: Xyz): [number, number, number] & Yxy {
12
11
  const X = color[0];
13
- // eslint-disable-next-line prefer-destructuring
12
+
14
13
  const Y = color[1];
15
- // eslint-disable-next-line prefer-destructuring
14
+
16
15
  const Z = color[2];
17
16
 
18
17
  return [Y, X / (X + Y + Z), Y / (X + Y + Z)];
@@ -7,12 +7,11 @@ import type Yxy from "../types/Yxy.js";
7
7
  * @returns A CIEXYZ color.
8
8
  * @public
9
9
  */
10
- export default function yxyToXyz(color: Yxy): Xyz {
11
- // eslint-disable-next-line prefer-destructuring
10
+ export default function yxyToXyz(color: Yxy): [number, number, number] & Xyz {
12
11
  const Y = color[0];
13
- // eslint-disable-next-line prefer-destructuring
12
+
14
13
  const x = color[1];
15
- // eslint-disable-next-line prefer-destructuring
14
+
16
15
  const y = color[2];
17
16
 
18
17
  return [x * (Y / y), Y, (1 - x - y) * (Y / y)];
@@ -10,7 +10,6 @@ import type Luv from "../types/Luv.js";
10
10
  * @public
11
11
  */
12
12
  export default function deltaC(color0: Lab, color1: Lab): number;
13
-
14
13
  /**
15
14
  * Calculates the ΔC* between two CIELUV values. Based on the EasyRGB pseudocode.
16
15
  * @param color0 - The first color.
@@ -20,7 +19,6 @@ export default function deltaC(color0: Lab, color1: Lab): number;
20
19
  * @public
21
20
  */
22
21
  export default function deltaC(color0: Luv, color1: Luv): number;
23
-
24
22
  export default function deltaC(color0: Lab | Luv, color1: Lab | Luv): number {
25
23
  return Math.hypot(color1[1], color1[2]) - Math.hypot(color0[1], color0[2]);
26
24
  }
@@ -1,5 +1,8 @@
1
1
  import type Lab from "../types/Lab.js";
2
- import type Lch from "../types/Lch.js";
2
+ import type Lchab from "../types/Lchab.js";
3
+
4
+ const c0 = 180 / Math.PI;
5
+ const c1 = Math.PI / 180;
3
6
 
4
7
  /**
5
8
  * Calculates the ΔCMC between two CIELAB values. Based on the EasyRGB pseudocode.
@@ -13,17 +16,16 @@ import type Lch from "../types/Lch.js";
13
16
  export default function deltaCmc(
14
17
  color0: Lab,
15
18
  color1: Lab,
16
- weight: Lch = [1, 1, 1]
19
+ weight: Lchab = [1, 1, 1]
17
20
  ): number {
18
- // eslint-disable-next-line prefer-destructuring
19
21
  const l0 = color0[0];
20
- // eslint-disable-next-line prefer-destructuring
22
+
21
23
  const a0 = color0[1];
22
- // eslint-disable-next-line prefer-destructuring
24
+
23
25
  const b0 = color0[2];
24
- // eslint-disable-next-line prefer-destructuring
26
+
25
27
  const a1 = color1[1];
26
- // eslint-disable-next-line prefer-destructuring
28
+
27
29
  const b1 = color1[2];
28
30
 
29
31
  const i0 = Math.hypot(a0, b0);
@@ -38,7 +40,7 @@ export default function deltaCmc(
38
40
  b0 < 0 ?
39
41
  270
40
42
  : 90
41
- : Math.atan(b0 / a0) * 57.29577951 + // `180 / Math.PI`
43
+ : Math.atan(b0 / a0) * c0 +
42
44
  (a0 > 0 ?
43
45
  b0 > 0 ?
44
46
  0
@@ -54,8 +56,8 @@ export default function deltaCmc(
54
56
  Math.sqrt((a1 - a0) ** 2 + (b1 - b0) ** 2 - i5 ** 2) /
55
57
  ((i2 *
56
58
  (i3 < 164 || i3 > 345 ?
57
- 0.36 + Math.abs(0.4 * Math.cos((35 + i3) * 0.01745329)) // `Math.PI / 180`
58
- : 0.56 + Math.abs(0.2 * Math.cos((168 + i3) * 0.01745329))) + // `Math.PI / 180`
59
+ 0.36 + Math.abs(0.4 * Math.cos((35 + i3) * c1))
60
+ : 0.56 + Math.abs(0.2 * Math.cos((168 + i3) * c1))) +
59
61
  1 -
60
62
  i2) *
61
63
  i4)