Trait rgb::ComponentMap
source · [−]pub trait ComponentMap<DestPixel, SrcComponent, DestComponent> {
fn map<Callback>(&self, f: Callback) -> DestPixel
where
Callback: FnMut(SrcComponent) -> DestComponent;
}
Expand description
Applying operation to every component
use rgb::ComponentMap;
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;