Sha256: df5f580315461edd6ef6de4df73503b7f5734c334c6a53222025ab9aec4ec278
Contents?: true
Size: 817 Bytes
Versions: 26
Compression:
Stored size: 817 Bytes
Contents
/* Convert between Lab and XYZ /* ========================================================================== */ export function lab2lch(labL, labA, labB) { const [ lchC, lchH ] = [ Math.sqrt(Math.pow(labA, 2) + Math.pow(labB, 2)), // convert to chroma Math.atan2(labB, labA) * 180 / Math.PI // convert to hue, in degrees ]; return [ labL, lchC, lchH ]; } export function lch2lab(lchL, lchC, lchH) { // convert to Lab a and b from the polar form const [ labA, labB ] = [ lchC * Math.cos(lchH * Math.PI / 180), lchC * Math.sin(lchH * Math.PI / 180) ]; return [ lchL, labA, labB ]; } /* References ---------- - https://www.w3.org/TR/css-color-4/#lch-to-lab - https://www.w3.org/TR/css-color-4/#color-conversion-code /* ========================================================================== */
Version data entries
26 entries across 25 versions & 8 rubygems