sRGB linearize: gamma to linear (handles negative/OOG values via signum)
(c: f64)
| 52 | |
| 53 | /// sRGB linearize: gamma to linear (handles negative/OOG values via signum) |
| 54 | fn linear(c: f64) -> f64 { |
| 55 | let abs = c.abs(); |
| 56 | if abs > 0.04045 { c.signum() * ((abs + 0.055) / 1.055).powf(2.4) } else { c / 12.92 } |
| 57 | } |
| 58 | |
| 59 | /// Convert float sRGB (r,g,b in 0..1 range, but may be OOG) to HSL. |
| 60 | /// This is the core algorithm that preserves out-of-gamut values. |