pub trait ColorMap<T: Color + Sized> {
    // Required method
    fn transform_single(&self, color: f64) -> T;

    // Provided method
    fn transform<U: IntoIterator<Item = f64>>(&self, inputs: U) -> Vec<T> { ... }
}
Expand description

A trait that models a colormap, a continuous mapping of the numbers between 0 and 1 to colors. Any color output format is supported, but it must be consistent.

Required Methods§

source

fn transform_single(&self, color: f64) -> T

Maps a given number between 0 and 1 to a given output Color. This should never fail or panic except for NaN and similar: there should be some Color that marks out-of-range data.

Provided Methods§

source

fn transform<U: IntoIterator<Item = f64>>(&self, inputs: U) -> Vec<T>

Maps a given collection of numbers between 0 and 1 to an iterator of Colors. Does not evaluate lazily, because the colormap could have some sort of state that changes between iterations otherwise.

Implementors§