pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
Expand description
This represents an RGBA color
Fields§
§r: u8
§g: u8
§b: u8
§a: u8
Implementations§
Source§impl Color
impl Color
pub fn blend(&self, other: Color) -> Color
Sourcepub fn brightness(&self) -> f32
pub fn brightness(&self) -> f32
ignores alpha
pub fn is_dark(&self) -> bool
pub fn is_transparent(&self) -> bool
pub fn darken(&self) -> Color
pub fn lighten(&self) -> Color
Sourcepub fn with_brightness(&self, amount: f32) -> Color
pub fn with_brightness(&self, amount: f32) -> Color
Copy color with brightness
Sourcepub fn with_saturate(&self, amount: f32) -> Color
pub fn with_saturate(&self, amount: f32) -> Color
De/saturate color by percentage Negative amount increases saturation
Sourcepub fn desaturate(&self) -> Color
pub fn desaturate(&self) -> Color
Decrease saturation by 10%
Trait Implementations§
Source§impl ChangeColors for Color
impl ChangeColors for Color
Source§fn with_saturate(&self, amount: f32) -> Color
fn with_saturate(&self, amount: f32) -> Color
De/saturate color by percentage
Negative amount increases saturation
So
-0.1
is 10% more saturatedSource§fn with_brightness(&self, amount: f32) -> Color
fn with_brightness(&self, amount: f32) -> Color
Change brightness to
amount
So 1.1
is 10% brighterSource§fn desaturate(&self) -> Selfwhere
Self: Sized,
fn desaturate(&self) -> Selfwhere
Self: Sized,
Decrease saturation by 10%
fn lighten(&self) -> Selfwhere
Self: Sized,
fn darken(&self) -> Selfwhere
Self: Sized,
Source§impl ColorConversion<u32> for Color
impl ColorConversion<u32> for Color
Source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
Source§fn deserialize<D>(d: D) -> Result<Color, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(d: D) -> Result<Color, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Color> for TextFormat
impl From<Color> for TextFormat
Source§fn from(color: Color) -> TextFormat
fn from(color: Color) -> TextFormat
Converts to this type from the input type.
Source§impl Serialize for Color
impl Serialize for Color
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.