MCPcopy Create free account
hub / github.com/csskit/csskit / linear

Function linear

crates/chromashift/src/hsl.rs:54–57  ·  view source on GitHub ↗

sRGB linearize: gamma to linear (handles negative/OOG values via signum)

(c: f64)

Source from the content-addressed store, hash-verified

52
53/// sRGB linearize: gamma to linear (handles negative/OOG values via signum)
54fn 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.

Callers 1

fromMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected