pub struct Color { /* private fields */ }Expand description
Complete RGBA paint with one opaque RGB identity and one opacity coefficient.
RGB channels are exact bytes; alpha is finite and within [0, 1].
Use Color::alpha to replace alpha without multiplying it.
use lichtung_plot::Color;
let paint = Color::hex("#12345680")?;
assert_eq!(paint.get_alpha(), 128.0 / 255.0);
assert_eq!(paint.alpha(1.0)?, Color::rgb(18, 52, 86));Implementations§
Source§impl Color
impl Color
Sourcepub const fn rgb(red: u8, green: u8, blue: u8) -> Self
pub const fn rgb(red: u8, green: u8, blue: u8) -> Self
Construct an opaque paint from exact RGB channels.
Sourcepub fn rgba(red: u8, green: u8, blue: u8, alpha: f64) -> Result<Self>
pub fn rgba(red: u8, green: u8, blue: u8, alpha: f64) -> Result<Self>
Construct a paint with exact RGB and a finite alpha coefficient in [0, 1].
Trait Implementations§
impl Copy for Color
impl Eq for Color
Source§impl From<Color> for ColorSource
impl From<Color> for ColorSource
Source§impl From<OpaqueColor> for Color
impl From<OpaqueColor> for Color
Source§fn from(rgb: OpaqueColor) -> Self
fn from(rgb: OpaqueColor) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Forget for Color
impl Freeze for Color
impl Move for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.