Skip to content

Commit bedf32e

Browse files
committed
[css-color-hdr] Handle negative component values in HLG function
1 parent 8745dbb commit bedf32e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

css-color-hdr/Overview.bs

+5-2
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,11 @@ Predefined color spaces for HDR: {#predefined-HDR}
555555
const a = 0.17883277;
556556
const b = 0.28466892; // 1 - (4 * a)
557557
const c = 0.55991073; // 0.5 - a * Math.log(4 *a)
558-
if (E <= 1/12) {
559-
Edash = Math.sqrt( 3 * E);
558+
// handle negative values
559+
var sign = E < 0? -1 : 1;
560+
var abs = Math.abs(E);
561+
if (abs <= 1/12) {
562+
Edash = sign * Math.sqrt( 3 * abs);
560563
}
561564
else {
562565
Edash = a * Math.log(12 * E - b) + c;

0 commit comments

Comments
 (0)