Skip the Math.sqrt for clamped values in convertToRgb
No need to compute the square root of clamped values. Only the values in the range ]0,1[ need to be processed.
This commit is contained in:
parent
7657011985
commit
e786649d2a
@ -885,9 +885,9 @@ var LabCS = (function LabCSClosure() {
|
||||
b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
|
||||
}
|
||||
// clamp color values to [0,1] range then convert to [0,255] range.
|
||||
dest[destOffset] = Math.sqrt(r < 0 ? 0 : r > 1 ? 1 : r) * 255;
|
||||
dest[destOffset + 1] = Math.sqrt(g < 0 ? 0 : g > 1 ? 1 : g) * 255;
|
||||
dest[destOffset + 2] = Math.sqrt(b < 0 ? 0 : b > 1 ? 1 : b) * 255;
|
||||
dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
|
||||
dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
|
||||
dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
|
||||
}
|
||||
|
||||
LabCS.prototype = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user