pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
Fields§
§r: f32
§g: f32
§b: f32
§a: f32
Implementations§
source§impl Color
impl Color
pub const CLEAR: Color = _
pub const BLACK: Color = _
pub const WHITE: Color = _
pub const RED: Color = _
pub const GREEN: Color = _
pub const BLUE: Color = _
pub const CYAN: Color = _
pub const YELLOW: Color = _
pub const PURPLE: Color = _
pub const PINK: Color = _
pub const ORANGE: Color = _
pub fn rgb(r: usize, g: usize, b: usize) -> Color
pub const fn rgb_f(r: f32, g: f32, b: f32) -> Color
pub fn rgba(r: usize, g: usize, b: usize, a: f32) -> Color
pub const fn rgba_f(r: f32, g: f32, b: f32, a: f32) -> Color
pub const fn grey(f: f32) -> Color
sourcepub const fn alpha(&self, a: f32) -> Color
pub const fn alpha(&self, a: f32) -> Color
Note this is incorrect for Color::CLEAR
. Can’t fix in a const fn.
sourcepub fn multiply_alpha(&self, factor: f32) -> Color
pub fn multiply_alpha(&self, factor: f32) -> Color
Multiply the color’s current alpha by the factor
, returning a new color.
pub fn hex(raw: &str) -> Color
pub fn as_hex(&self) -> String
pub fn lerp(self, other: Color, pct: f64) -> Color
pub fn shade(self, black_ratio: f64) -> Color
pub fn tint(self, white_ratio: f64) -> Color
pub fn dull(self, ratio: f64) -> Color
pub fn invert(self) -> Color
Trait Implementations§
source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
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<Color> for RewriteColor
impl From<Color> for RewriteColor
source§fn from(color: Color) -> RewriteColor
fn from(color: Color) -> RewriteColor
Converts to this type from the input type.
source§impl PartialEq for Color
impl PartialEq for Color
impl Copy 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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.