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

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§

§start: T

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

§end: T

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

§normalization: NormalizeMapping

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

§padding: (f64, f64)

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.

Implementations§

source§

impl<T: ColorPoint> GradientColorMap<T>

source

pub fn new_linear(start: T, end: T) -> GradientColorMap<T>

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

source

pub fn new_cbrt(start: T, end: T) -> GradientColorMap<T>

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

Trait Implementations§

source§

impl<T: Clone + ColorPoint> Clone for GradientColorMap<T>

source§

fn clone(&self) -> GradientColorMap<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: ColorPoint> ColorMap<T> for GradientColorMap<T>

source§

fn transform_single(&self, x: 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.
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.
source§

impl<T: Debug + ColorPoint> Debug for GradientColorMap<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for GradientColorMap<T>where T: RefUnwindSafe,

§

impl<T> Send for GradientColorMap<T>where T: Send,

§

impl<T> Sync for GradientColorMap<T>where T: Sync,

§

impl<T> Unpin for GradientColorMap<T>where T: Unpin,

§

impl<T> UnwindSafe for GradientColorMap<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<G1, G2> Within<G2> for G1where G2: Contains<G1>,

source§

fn is_within(&self, b: &G2) -> bool