pub struct Gradient { /* private fields */ }Expand description
Colours at places along the bar, from 0 (the soft start) to 1 (its end), blended in between.
use egui::Color32;
use egui_pop_core::slider::Gradient;
let g = Gradient::new([(0.0, Color32::BLACK), (1.0, Color32::WHITE)]);
assert_eq!(g.color_at(0.5), Color32::from_gray(128));
assert_eq!(Gradient::hue().color_at(0.0), Gradient::hue().color_at(1.0));Implementations§
Source§impl Gradient
impl Gradient
Sourcepub fn new(stops: impl IntoIterator<Item = (f32, Color32)>) -> Self
pub fn new(stops: impl IntoIterator<Item = (f32, Color32)>) -> Self
From stops (place, colour), places in [0, 1] (sorted here; the
first and last colours run to the ends).
Sourcepub fn sampled(samples: usize, f: impl Fn(f32) -> Color32) -> Self
pub fn sampled(samples: usize, f: impl Fn(f32) -> Color32) -> Self
samples colours of f over [0, 1] (at least two).
Sourcepub fn temperature(from: f32, to: f32) -> Self
pub fn temperature(from: f32, to: f32) -> Self
The colour of light from from to to kelvin (a white balance’s
illuminant: warm at low temperatures, blue at high ones), linear
in kelvin. Gradient::reversed shows the correction instead.
Trait Implementations§
impl StructuralPartialEq for Gradient
Auto Trait Implementations§
impl Freeze for Gradient
impl RefUnwindSafe for Gradient
impl Send for Gradient
impl Sync for Gradient
impl Unpin for Gradient
impl UnsafeUnpin for Gradient
impl UnwindSafe for Gradient
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