Struct scarlet::colormap::GradientColorMap
source · 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>
impl<T: ColorPoint> GradientColorMap<T>
sourcepub fn new_linear(start: T, end: T) -> GradientColorMap<T>
pub fn new_linear(start: T, end: T) -> GradientColorMap<T>
Constructs a new linear GradientColorMap
, without padding, from two colors.
sourcepub fn new_cbrt(start: T, end: T) -> GradientColorMap<T>
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>
impl<T: Clone + ColorPoint> Clone for GradientColorMap<T>
source§fn clone(&self) -> GradientColorMap<T>
fn clone(&self) -> GradientColorMap<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: ColorPoint> ColorMap<T> for GradientColorMap<T>
impl<T: ColorPoint> ColorMap<T> for GradientColorMap<T>
source§fn transform_single(&self, x: f64) -> T
fn transform_single(&self, x: f64) -> T
Color
. This should never fail or panic
except for NaN and similar: there should be some Color that marks out-of-range data.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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.