pub struct Composite { /* private fields */ }
Expand description
Object to style RawPixels
.
Implementations§
Source§impl Composite
impl Composite
Sourcepub fn new_rgb(vmin: Vec<f64>, vmax: Vec<f64>) -> Self
pub fn new_rgb(vmin: Vec<f64>, vmax: Vec<f64>) -> Self
Create a RGB Composite
that maps 3 pixel values (from 3 different bands) into RGBA
components.
§Example
use map_engine::cmap::{Composite, HandleGet, viridis};
let comp = Composite::new_rgb(vec![0.0, 0.0, 0.0], vec![100.0, 100.0, 100.0]);
assert_eq!(comp.get(&[0.0, 50.0, 100.0], None), [0, 127, 255, 255]);
Sourcepub fn new_gradient(
vmin: f64,
vmax: f64,
cmap_f: &'static dyn Fn(f64, f64) -> GradientLinearRGBA,
) -> Self
pub fn new_gradient( vmin: f64, vmax: f64, cmap_f: &'static dyn Fn(f64, f64) -> GradientLinearRGBA, ) -> Self
Create a Composite
that maps 1 pixel value into RGBA using the provided function.
You can use one of the functions provided in the cmap module.
§Example
use map_engine::cmap::{Composite, HandleGet, viridis};
let comp = Composite::new_gradient(0.0, 100.0, &viridis);
assert_eq!(comp.get(&[0.0], None), [68, 1, 84, 255]);
Sourcepub fn new_custom_gradient(vmin: f64, vmax: f64, colours: Vec<Colour>) -> Self
pub fn new_custom_gradient(vmin: f64, vmax: f64, colours: Vec<Colour>) -> Self
Create an equally-spaced Composite
that maps 1 pixel value into RGBA using a sequence of Colour
.
§Example
use map_engine::{
colour::Colour,
cmap::{Composite, HandleGet},
};
let comp = Composite::new_custom_gradient(0.0, 100.0, vec![
Colour::from((255, 0, 0, 255)), // red
Colour::from((0, 0, 255, 255)), // blue
]);
assert_eq!(comp.get(&[50.0], None), [127, 0, 127, 255]); // purple
Sourcepub fn new_gradient_with_breaks(cols_and_breaks: Vec<(f64, Colour)>) -> Self
pub fn new_gradient_with_breaks(cols_and_breaks: Vec<(f64, Colour)>) -> Self
Create an Composite
with custom breaks that maps 1 pixel value into RGBA.
§Example
use map_engine::{
colour::Colour,
cmap::{Composite, HandleGet},
};
let comp = Composite::new_gradient_with_breaks(vec![
(0.0, Colour::from((255, 0, 0, 255))), // red
(25.0, Colour::from((127, 0, 127, 255))), // purple shifted to the red
(100.0, Colour::from((0, 0, 255, 255))), // blue
]);
assert_eq!(comp.get(&[25.0], None), [127, 0, 127, 255]); // purple
Sourcepub fn new_discrete_palette(cols_and_breaks: Vec<(isize, Colour)>) -> Self
pub fn new_discrete_palette(cols_and_breaks: Vec<(isize, Colour)>) -> Self
Create an discrete Composite
that maps 1 pixel value into RGBA.
§Example
use map_engine::{
colour::Colour,
cmap::{Composite, HandleGet},
};
let comp = Composite::new_discrete_palette(vec![
(0, Colour::from((255, 0, 0, 255))), // red
(1, Colour::from((0, 255, 0, 255))), // green
(2, Colour::from((0, 0, 255, 255))), // blue
]);
assert_eq!(comp.get(&[0.0], None), [255, 0, 0, 255]); // red
assert_eq!(comp.get(&[3.0], None), [0, 0, 0, 0]); // transparent if not defined
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Composite
impl RefUnwindSafe for Composite
impl Send for Composite
impl Sync for Composite
impl Unpin for Composite
impl UnwindSafe for Composite
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified
method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford
method by default
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Convert into T with values clamped to the color defined bounds Read more
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Convert into T. The resulting color might be invalid in its color space Read more
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
Convert into T, returning ok if the color is inside of its defined
range, otherwise an
OutOfBounds
error is returned which contains
the unclamped color. Read more