Skip to content

Commit 8ea42d7

Browse files
committed
Tolerate negative values
1 parent 9c88493 commit 8ea42d7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pal.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ impl f_pixel {
126126

127127
// 256, because numbers are in range 1..255.9999… rounded down
128128
RGBA {
129-
r: (r.powf(gamma) * 256.) as u8,
130-
g: (g.powf(gamma) * 256.) as u8,
131-
b: (b.powf(gamma) * 256.) as u8,
129+
r: (r.max(0.).powf(gamma) * 256.) as u8,
130+
g: (g.max(0.).powf(gamma) * 256.) as u8,
131+
b: (b.max(0.).powf(gamma) * 256.) as u8,
132132
a: (self.a * (256. / f64::from(LIQ_WEIGHT_A)) as f32) as u8,
133133
}
134134
}

0 commit comments

Comments
 (0)