pub struct ColorLookupTable { /* private fields */ }Expand description
A pre-computed lookup table for O(1) color lookups.
This table maps a range of values to RGBA colors using a fixed-size array.
It is created from a DiscreteColorScale and provides fast color lookups
during rendering.
§Example
use nexrad_render::{ColorLookupTable, nws_reflectivity_scale};
let scale = nws_reflectivity_scale();
let lut = ColorLookupTable::from_scale(&scale, -32.0, 95.0, 256);
// O(1) lookup returning [R, G, B, A] bytes
let color = lut.color(45.0);Implementations§
Source§impl ColorLookupTable
impl ColorLookupTable
Sourcepub fn from_scale(
scale: &DiscreteColorScale,
min_value: f32,
max_value: f32,
size: usize,
) -> Self
pub fn from_scale( scale: &DiscreteColorScale, min_value: f32, max_value: f32, size: usize, ) -> Self
Creates a lookup table from a discrete color scale.
§Arguments
scale- The color scale to sample frommin_value- The minimum value to mapmax_value- The maximum value to mapsize- The number of entries in the lookup table (256 recommended)
Values outside the min/max range will be clamped to the nearest entry.
Sourcepub fn from_color_scale(
scale: &ColorScale,
min_value: f32,
max_value: f32,
size: usize,
) -> Self
pub fn from_color_scale( scale: &ColorScale, min_value: f32, max_value: f32, size: usize, ) -> Self
Creates a lookup table from any ColorScale (discrete or continuous).
This is the preferred way to create a LUT for the new rendering entry points.
Trait Implementations§
Source§impl Clone for ColorLookupTable
impl Clone for ColorLookupTable
Source§fn clone(&self) -> ColorLookupTable
fn clone(&self) -> ColorLookupTable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ColorLookupTable
impl RefUnwindSafe for ColorLookupTable
impl Send for ColorLookupTable
impl Sync for ColorLookupTable
impl Unpin for ColorLookupTable
impl UnsafeUnpin for ColorLookupTable
impl UnwindSafe for ColorLookupTable
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more