Skip to content

Commit

Permalink
Avoid calling Math.pow if possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuratak committed Jun 2, 2020
1 parent 96ad60f commit 5a267a1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/colorspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,9 @@ const CalRGBCS = (function CalRGBCSClosure() {
if (color <= 0.0031308) {
return adjustToRange(0, 1, 12.92 * color);
}
if (color >= 0.99554525) {
return 1;
}
return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
}

Expand Down Expand Up @@ -1156,9 +1159,9 @@ const CalRGBCS = (function CalRGBCSClosure() {
// A <---> AGR in the spec
// B <---> BGG in the spec
// C <---> CGB in the spec
const AGR = A ** cs.GR;
const BGG = B ** cs.GG;
const CGB = C ** cs.GB;
const AGR = A === 1 ? 1 : A ** cs.GR;
const BGG = B === 1 ? 1 : B ** cs.GG;
const CGB = C === 1 ? 1 : C ** cs.GB;

// Computes intermediate variables L, M, N as per spec.
// To decode X, Y, Z values map L, M, N directly to them.
Expand Down

0 comments on commit 5a267a1

Please sign in to comment.