#[repr(C)]pub struct Hsla {
pub h: f32,
pub s: f32,
pub l: f32,
pub a: f32,
}
Fields§
§h: f32
§s: f32
§l: f32
§a: f32
Implementations§
source§impl Hsla
impl Hsla
sourcepub fn is_transparent(&self) -> bool
pub fn is_transparent(&self) -> bool
Returns true if the HSLA color is fully transparent, false otherwise.
sourcepub fn blend(self, other: Hsla) -> Hsla
pub fn blend(self, other: Hsla) -> Hsla
Blends other
on top of self
based on other
’s alpha value. The resulting color is a combination of self
’s and other
’s colors.
If other
’s alpha value is 1.0 or greater, other
color is fully opaque, thus other
is returned as the output color.
If other
’s alpha value is 0.0 or less, other
color is fully transparent, thus self
is returned as the output color.
Else, the output color is calculated as a blend of self
and other
based on their weighted alpha values.
Assumptions:
- Alpha values are contained in the range [0, 1], with 1 as fully opaque and 0 as fully transparent.
- The relative contributions of
self
andother
is based onself
’s alpha value (self.a
) andother
’s alpha value (other.a
),self
contributingself.a * (1.0 - other.a)
andother
contributing it’s own alpha value. - RGB color components are contained in the range [0, 1].
- If
self
andother
colors are out of the valid range, the blend operation’s output and behavior is undefined.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Hsla
impl<'de> Deserialize<'de> for Hsla
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl From<Hsla> for HighlightStyle
impl From<Hsla> for HighlightStyle
source§impl Ord for Hsla
impl Ord for Hsla
source§impl PartialEq<Hsla> for Hsla
impl PartialEq<Hsla> for Hsla
source§impl PartialOrd<Hsla> for Hsla
impl PartialOrd<Hsla> for Hsla
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Hsla
impl Eq for Hsla
Auto Trait Implementations§
impl RefUnwindSafe for Hsla
impl Send for Hsla
impl Sync for Hsla
impl Unpin for Hsla
impl UnwindSafe for Hsla
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IsDefault for Twhere
T: Default + PartialEq<T> + Copy,
impl<T> IsDefault for Twhere T: Default + PartialEq<T> + Copy,
source§fn is_default(&self) -> bool
fn is_default(&self) -> bool
Checks that type has a default value.