Skip to content

Commit

Permalink
Pass arrays of colors to getColor()
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydk committed Feb 26, 2024
1 parent e3f867b commit b96472a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/deltaE/deltaE2000.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ function pow7 (x) {
}

export default function (color, sample, {kL = 1, kC = 1, kH = 1} = {}) {
color = getColor(color);
sample = getColor(sample);
[color, sample] = getColor([color, sample]);

// Given this color as the reference
// and the function parameter as the sample,
Expand Down
3 changes: 2 additions & 1 deletion src/deltaE/deltaE76.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import distance from "../distance.js";
import getColor from "../getColor.js";

export default function deltaE76 (color, sample) {
return distance(getColor(color), getColor(sample), "lab");
// Assume getColor() is called in the distance function
return distance(color, sample, "lab");
}
3 changes: 1 addition & 2 deletions src/deltaE/deltaECMC.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const π = Math.PI;
const d2r = π / 180;

export default function (color, sample, {l = 2, c = 1} = {}) {
color = getColor(color);
sample = getColor(sample);
[color, sample] = getColor([color, sample]);

// Given this color as the reference
// and a sample,
Expand Down
3 changes: 1 addition & 2 deletions src/deltaE/deltaEHCT.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ function convertUcsAb (coords) {
* @return {number[]}
*/
export default function (color, sample) {
color = getColor(color);
sample = getColor(sample);
[color, sample] = getColor([color, sample]);

let [ t1, a1, b1 ] = convertUcsAb(hct.from(color));
let [ t2, a2, b2 ] = convertUcsAb(hct.from(sample));
Expand Down
3 changes: 1 addition & 2 deletions src/deltaE/deltaEITP.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import getColor from "../getColor.js";
// formulae from ITU Rec. ITU-R BT.2124-0

export default function (color, sample) {
color = getColor(color);
sample = getColor(sample);
[color, sample] = getColor([color, sample]);

// Given this color as the reference
// and a sample,
Expand Down
3 changes: 1 addition & 2 deletions src/deltaE/deltaEJz.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import getColor from "../getColor.js";
// gives good results.

export default function (color, sample) {
color = getColor(color);
sample = getColor(sample);
[color, sample] = getColor([color, sample]);

// Given this color as the reference
// and a sample,
Expand Down
3 changes: 1 addition & 2 deletions src/deltaE/deltaEOK.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import oklab from "../spaces/oklab.js";
import getColor from "../getColor.js";

export default function (color, sample) {
color = getColor(color);
sample = getColor(sample);
[color, sample] = getColor([color, sample]);

// Given this color as the reference
// and a sample,
Expand Down

0 comments on commit b96472a

Please sign in to comment.