sRGB gamma-encode: linear to gamma (handles negative/OOG values via signum)
(u: f64)
| 46 | |
| 47 | /// sRGB gamma-encode: linear to gamma (handles negative/OOG values via signum) |
| 48 | fn gamma(u: f64) -> f64 { |
| 49 | let abs = u.abs(); |
| 50 | if abs <= 0.0031308 { u * 12.92 } else { u.signum() * (1.055 * abs.powf(1.0 / 2.4) - 0.055) } |
| 51 | } |
| 52 | |
| 53 | /// sRGB linearize: gamma to linear (handles negative/OOG values via signum) |
| 54 | fn linear(c: f64) -> f64 { |