pub enum LinearDither {
Hash(Hash),
R2(R2),
GoldenRatio(GoldenRatio),
}Expand description
Enum for dynamic dispatch of 1D dithering methods.
This enum allows runtime selection of dithering methods. All variants
implement LinearRng through enum_dispatch, providing zero-cost
abstraction for dynamic method selection.
§Example
use dithereens::{LinearDither, LinearRng};
let method = LinearDither::Hash(dithereens::Hash::new(42));
let noise = method.compute(100);
assert!(noise >= -1.0 && noise <= 1.0);Variants§
Trait Implementations§
Source§impl Clone for LinearDither
impl Clone for LinearDither
Source§fn clone(&self) -> LinearDither
fn clone(&self) -> LinearDither
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LinearDither
impl Debug for LinearDither
Source§impl From<GoldenRatio> for LinearDither
impl From<GoldenRatio> for LinearDither
Source§fn from(v: GoldenRatio) -> LinearDither
fn from(v: GoldenRatio) -> LinearDither
Source§impl From<Hash> for LinearDither
impl From<Hash> for LinearDither
Source§fn from(v: Hash) -> LinearDither
fn from(v: Hash) -> LinearDither
Source§impl From<R2> for LinearDither
impl From<R2> for LinearDither
Source§fn from(v: R2) -> LinearDither
fn from(v: R2) -> LinearDither
Source§impl LinearRng for LinearDither
impl LinearRng for LinearDither
Source§fn compute(&self, __enum_dispatch_arg_0: u32) -> f32
fn compute(&self, __enum_dispatch_arg_0: u32) -> f32
Compute dither offset for a given index. Returns a value in range [-1, 1] to be scaled by amplitude.
Source§fn dither<T>(
&self,
__enum_dispatch_arg_0: T,
__enum_dispatch_arg_1: T,
__enum_dispatch_arg_2: T,
__enum_dispatch_arg_3: T,
__enum_dispatch_arg_4: u32,
) -> Twhere
T: DitherFloat,
Self: Sized,
fn dither<T>(
&self,
__enum_dispatch_arg_0: T,
__enum_dispatch_arg_1: T,
__enum_dispatch_arg_2: T,
__enum_dispatch_arg_3: T,
__enum_dispatch_arg_4: u32,
) -> Twhere
T: DitherFloat,
Self: Sized,
Dither a single value.
Source§fn simple_dither<T>(
&self,
__enum_dispatch_arg_0: T,
__enum_dispatch_arg_1: T,
__enum_dispatch_arg_2: u32,
) -> T
fn simple_dither<T>( &self, __enum_dispatch_arg_0: T, __enum_dispatch_arg_1: T, __enum_dispatch_arg_2: u32, ) -> T
Simple dither for a single value.
Source§fn dither_slice<T>(
&self,
__enum_dispatch_arg_0: &mut [T],
__enum_dispatch_arg_1: T,
__enum_dispatch_arg_2: T,
__enum_dispatch_arg_3: T,
)
fn dither_slice<T>( &self, __enum_dispatch_arg_0: &mut [T], __enum_dispatch_arg_1: T, __enum_dispatch_arg_2: T, __enum_dispatch_arg_3: T, )
Dither values in a slice (parallel version).
Source§fn simple_dither_slice<T>(
&self,
__enum_dispatch_arg_0: &mut [T],
__enum_dispatch_arg_1: T,
)
fn simple_dither_slice<T>( &self, __enum_dispatch_arg_0: &mut [T], __enum_dispatch_arg_1: T, )
Simple dither for values in a slice (parallel version).
Source§fn dither_iter<T, I>(
&self,
__enum_dispatch_arg_0: I,
__enum_dispatch_arg_1: T,
__enum_dispatch_arg_2: T,
__enum_dispatch_arg_3: T,
) -> Vec<T>
fn dither_iter<T, I>( &self, __enum_dispatch_arg_0: I, __enum_dispatch_arg_1: T, __enum_dispatch_arg_2: T, __enum_dispatch_arg_3: T, ) -> Vec<T>
Dither values from an iterator (parallel version).
Source§fn simple_dither_iter<T, I>(
&self,
__enum_dispatch_arg_0: I,
__enum_dispatch_arg_1: T,
) -> Vec<T>where
T: DitherFloat + Number + CastableFrom<f32> + Send + Sync,
I: IntoIterator<Item = T>,
I::IntoIter: Send,
Self: Sized,
fn simple_dither_iter<T, I>(
&self,
__enum_dispatch_arg_0: I,
__enum_dispatch_arg_1: T,
) -> Vec<T>where
T: DitherFloat + Number + CastableFrom<f32> + Send + Sync,
I: IntoIterator<Item = T>,
I::IntoIter: Send,
Self: Sized,
Simple dither for values from an iterator (parallel version).
Source§fn dither_float<Src, Dest>(
&self,
__enum_dispatch_arg_0: Src,
__enum_dispatch_arg_1: u32,
) -> Dest
fn dither_float<Src, Dest>( &self, __enum_dispatch_arg_0: Src, __enum_dispatch_arg_1: u32, ) -> Dest
Dither a float value when converting to lower precision.
Source§fn dither_float_slice<Src, Dest>(
&self,
__enum_dispatch_arg_0: &[Src],
) -> Vec<Dest>where
Src: DitherFloatConversion<Dest> + DitherFloat + CastableFrom<f64> + Copy + Send + Sync,
Dest: Send,
Self: Sized,
fn dither_float_slice<Src, Dest>(
&self,
__enum_dispatch_arg_0: &[Src],
) -> Vec<Dest>where
Src: DitherFloatConversion<Dest> + DitherFloat + CastableFrom<f64> + Copy + Send + Sync,
Dest: Send,
Self: Sized,
Dither float values in a slice when converting to lower precision (parallel version).
Source§fn dither_float_iter<Src, Dest, I>(&self, __enum_dispatch_arg_0: I) -> Vec<Dest>where
Src: DitherFloatConversion<Dest> + DitherFloat + CastableFrom<f64> + Send + Sync,
Dest: Send,
I: IntoIterator<Item = Src>,
I::IntoIter: Send,
Self: Sized,
fn dither_float_iter<Src, Dest, I>(&self, __enum_dispatch_arg_0: I) -> Vec<Dest>where
Src: DitherFloatConversion<Dest> + DitherFloat + CastableFrom<f64> + Send + Sync,
Dest: Send,
I: IntoIterator<Item = Src>,
I::IntoIter: Send,
Self: Sized,
Dither float values from an iterator when converting to lower precision (parallel version).
Source§impl PartialEq for LinearDither
impl PartialEq for LinearDither
Source§impl TryInto<GoldenRatio> for LinearDither
impl TryInto<GoldenRatio> for LinearDither
Source§impl TryInto<Hash> for LinearDither
impl TryInto<Hash> for LinearDither
Source§impl TryInto<R2> for LinearDither
impl TryInto<R2> for LinearDither
impl Copy for LinearDither
impl StructuralPartialEq for LinearDither
Auto Trait Implementations§
impl Freeze for LinearDither
impl RefUnwindSafe for LinearDither
impl Send for LinearDither
impl Sync for LinearDither
impl Unpin for LinearDither
impl UnwindSafe for LinearDither
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
impl<T, U> CastableInto<U> for Twhere
U: CastableFrom<T>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DowncastableFrom<T> for T
impl<T> DowncastableFrom<T> for T
Source§fn downcast_from(value: T) -> T
fn downcast_from(value: T) -> T
Source§impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
impl<T, U> DowncastableInto<U> for Twhere
U: DowncastableFrom<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more