fast image operations
Diffstat (limited to 'src/pixels/utility.rs')
-rw-r--r--src/pixels/utility.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/pixels/utility.rs b/src/pixels/utility.rs
index e9cca62..78795ac 100644
--- a/src/pixels/utility.rs
+++ b/src/pixels/utility.rs
@@ -1,4 +1,4 @@
-use umath::FF32;
+#[lower::apply(algebraic)]
pub trait Unfloatify<const N: usize> {
/// computes 255 * n, for all elements
fn unfloat(self) -> [u8; N];
@@ -6,12 +6,12 @@ pub trait Unfloatify<const N: usize> {
#[inline(always)]
/// computes 255 * n
-pub fn unfloat(n: FF32) -> u8 {
+pub fn unfloat(n: f32) -> u8 {
// SAFETY: n is 0..=1
- unsafe { *(FF32::new(255.0) * n) as u8 }
+ (255.0 * n) as u8
}
-impl<const N: usize> Unfloatify<N> for [FF32; N] {
+impl<const N: usize> Unfloatify<N> for [f32; N] {
fn unfloat(self) -> [u8; N] {
self.map(unfloat)
}
@@ -22,20 +22,21 @@ impl<const N:usize>Unfloatify<N>for[u8; N]{fn unfloat(self)->[u8;N]{self}}
pub trait Floatify<const N: usize> {
/// computes n / 255, for all elements
- fn float(self) -> [FF32; N];
+ fn float(self) -> [f32; N];
}
/// computes n / 255
-pub fn float(n: u8) -> FF32 {
+#[lower::apply(algebraic)]
+pub fn float(n: u8) -> f32 {
// SAFETY: 0..=255 / 0..=255 mayn't ever be NAN / INF
- unsafe { FF32::new(n as f32) / FF32::new(255.0) }
+ n as f32 / 255.0
}
impl<const N: usize> Floatify<N> for [u8; N] {
- fn float(self) -> [FF32; N] {
+ fn float(self) -> [f32; N] {
self.map(float)
}
}
#[rustfmt::skip]
-impl<const N:usize>Floatify<N>for[FF32;N]{fn float(self)->[FF32;N]{self}}
+impl<const N:usize>Floatify<N>for[f32;N]{fn float(self)->[f32;N]{self}}