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

Function gamma

crates/chromashift/src/hsl.rs:48–51  ·  view source on GitHub ↗

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

(u: f64)

Source from the content-addressed store, hash-verified

46
47/// sRGB gamma-encode: linear to gamma (handles negative/OOG values via signum)
48fn 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)
54fn linear(c: f64) -> f64 {

Callers 1

fromMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected