pub struct ColorRamp {
pub stops: Vec<ColorStop>,
}Expand description
An interpolated colour transfer function defined by ordered stops.
Evaluates a scalar t to a linear RGBA colour by linearly
interpolating between the two nearest stops. Values outside the
stop range are clamped to the first / last stop colour.
Fields§
§stops: Vec<ColorStop>Ordered colour stops. Must contain at least one entry.
Implementations§
Source§impl ColorRamp
impl ColorRamp
Sourcepub fn new(stops: Vec<ColorStop>) -> Self
pub fn new(stops: Vec<ColorStop>) -> Self
Create a new ramp from the given stops.
Stops are sorted by value on construction.
§Panics
Panics if stops is empty.
Sourcepub fn evaluate(&self, t: f32) -> [f32; 4]
pub fn evaluate(&self, t: f32) -> [f32; 4]
Evaluate the ramp at t, returning a linearly interpolated
RGBA colour. Clamps to the boundary stops outside the range.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ColorRamp
impl RefUnwindSafe for ColorRamp
impl Send for ColorRamp
impl Sync for ColorRamp
impl Unpin for ColorRamp
impl UnsafeUnpin for ColorRamp
impl UnwindSafe for ColorRamp
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