Skip to content

Commit 85bb759

Browse files
committed
update color fns
1 parent a899c2b commit 85bb759

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

src/color/fns.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
// devela::color::fns
22
//
33

4-
#[cfg(all(feature = "no_std", feature = "dep"))]
5-
use crate::_dep::libm::Libm;
4+
#[cfg(feature = "libm")]
5+
use crate::ops::FloatExt;
66

77
/// Applies the `gamma` to an `f32` channel.
88
#[inline]
9-
#[cfg(any(feature = "std", all(feature = "no_std", feature = "dep")))]
10-
#[cfg_attr(
11-
feature = "nightly",
12-
doc(cfg(any(feature = "std", all(feature = "no_std", feature = "dep"))))
13-
)]
9+
#[cfg(any(feature = "std", feature = "libm"))]
10+
#[cfg_attr(feature = "nightly", doc(cfg(any(feature = "std", feature = "libm"))))]
1411
pub fn linearize32(nonlinear: f32, gamma: f32) -> f32 {
1512
if nonlinear >= 0.04045 {
16-
#[cfg(feature = "std")]
1713
return ((nonlinear + 0.055) / (1. + 0.055)).powf(gamma);
18-
19-
#[cfg(not(feature = "std"))]
20-
return Libm::<f32>::pow((nonlinear + 0.055) / (1. + 0.055), gamma);
2114
} else {
2215
nonlinear / 12.92
2316
}
2417
}
2518

2619
/// Removes the `gamma` from an `f32` channel.
2720
#[inline]
28-
#[cfg(any(feature = "std", all(feature = "no_std", feature = "dep")))]
29-
#[cfg_attr(
30-
feature = "nightly",
31-
doc(cfg(any(feature = "std", all(feature = "no_std", feature = "dep"))))
32-
)]
21+
#[cfg(any(feature = "std", feature = "libm"))]
22+
#[cfg_attr(feature = "nightly", doc(cfg(any(feature = "std", feature = "libm"))))]
3323
pub fn nonlinearize32(linear: f32, gamma: f32) -> f32 {
3424
if linear >= 0.0031308 {
35-
#[cfg(feature = "std")]
3625
return (1.055) * linear.powf(1.0 / gamma) - 0.055;
37-
38-
#[cfg(not(feature = "std"))]
39-
return (1.055) * Libm::<f32>::pow(linear, 1.0 / gamma) - 0.055;
4026
} else {
4127
12.92 * linear
4228
}

0 commit comments

Comments
 (0)