Trait ComponentMap

trait ComponentMap<DestPixel, SrcComponent, DestComponent>

Applying operation to every component

use rgb::prelude::*;
# let pixel = rgb::RGB::new(0u8,0,0);
let inverted = pixel.map(|c| 255 - c);

// For simple math there are Add/Sub/Mul implementations:
let halved = pixel.map(|c| c / 2);
let doubled = pixel * 2;

Required Methods

fn map<Callback>(self: &Self, f: Callback) -> DestPixel
where
    Callback: FnMut(SrcComponent) -> DestComponent

Convenience function (equivalent of self.iter().map().collect()) for applying the same formula to every component.

Note that it returns the pixel directly, not an Interator.

Implementors