DitherIteratorExt

Trait DitherIteratorExt 

Source
pub trait DitherIteratorExt<T>: Iterator<Item = T> + Sized
where T: DitherFloat,
{ // Provided methods fn dither(self, min: T, one: T, dither_amplitude: T, seed: u32) -> Vec<T> where T: Send + Sync, Self: Send, Self::Item: Send { ... } fn dither_with<M: LinearRng>( self, min: T, one: T, dither_amplitude: T, method: &M, ) -> Vec<T> where T: Send + Sync, Self: Send, Self::Item: Send { ... } fn simple_dither(self, one: T, seed: u32) -> Vec<T> where T: Number + CastableFrom<f32> + Send + Sync, Self: Send, Self::Item: Send { ... } fn simple_dither_with<M: LinearRng>(self, one: T, method: &M) -> Vec<T> where T: Number + CastableFrom<f32> + Send + Sync, Self: Send, Self::Item: Send { ... } }
Expand description

Iterator adapter trait for dithering operations.

This trait provides methods to apply dithering directly to iterators, allowing for chaining operations. The trait automatically handles index tracking for deterministic dithering.

§Examples

let values = vec![0.2f32, 0.5, 0.8];

let result: Vec<f32> = values
    .iter()
    .copied()
    .map(|x| x * 0.5)
    .simple_dither(255.0, 42);

Provided Methods§

Source

fn dither(self, min: T, one: T, dither_amplitude: T, seed: u32) -> Vec<T>
where T: Send + Sync, Self: Send, Self::Item: Send,

Source

fn dither_with<M: LinearRng>( self, min: T, one: T, dither_amplitude: T, method: &M, ) -> Vec<T>
where T: Send + Sync, Self: Send, Self::Item: Send,

Source

fn simple_dither(self, one: T, seed: u32) -> Vec<T>
where T: Number + CastableFrom<f32> + Send + Sync, Self: Send, Self::Item: Send,

Source

fn simple_dither_with<M: LinearRng>(self, one: T, method: &M) -> Vec<T>
where T: Number + CastableFrom<f32> + Send + Sync, Self: Send, Self::Item: Send,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<I, T> DitherIteratorExt<T> for I
where I: Iterator<Item = T>, T: DitherFloat,

Automatic implementation of DitherIteratorExt for all iterators yielding DitherFloat types.