Struct scarlet::colormap::GradientColorMap [] [src]

pub struct GradientColorMap<T: ColorPoint> {
    pub start: T,
    pub end: T,
    pub normalization: NormalizeMapping,
    pub padding: (f64, f64),
}

A gradient colormap: a continuous, evenly-spaced shift between two colors A and B such that 0 maps to A, 1 maps to B, and any number in between maps to a weighted mix of them in a given coordinate space. Uses the gradient functions in the ColorPoint trait to complete this. Out-of-range values are simply clamped to the correct range: calling this on negative numbers will return A, and calling this on numbers larger than 1 will return B.

Fields

The start of the gradient. Calling this colormap on 0 or any negative number returns this color.

The end of the gradient. Calling this colormap on 1 or any larger number returns this color.

Any additional added nonlinearity imposed on the gradient: for example, a cube root mapping emphasizes differences in the low end of the range.

Any desired padding: offsets introduced that artificially shift the limits of the range. Expressed as (new_min, new_max), where both are floats and new_min < new_max. For example, having padding of (1/8, 1) would remove the lower eighth of the color map while keeping the overall map smooth and continuous. Padding of (0., 1.) is the default and normal behavior.

Methods

impl<T: ColorPoint> GradientColorMap<T>
[src]

[src]

Constructs a new linear GradientColorMap, without padding, from two colors.

[src]

Constructs a new cube root GradientColorMap, without padding, from two colors.

Trait Implementations

impl<T: Debug + ColorPoint> Debug for GradientColorMap<T>
[src]

[src]

Formats the value using the given formatter.

impl<T: Clone + ColorPoint> Clone for GradientColorMap<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: ColorPoint> ColorMap<T> for GradientColorMap<T>
[src]

[src]

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. Read more

[src]

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. Read more