#[repr(C)]pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Fields§
§r: f32§g: f32§b: f32§a: f32Implementations§
Source§impl Color
impl Color
Sourcepub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self
Create a color using r, g, b, a. All values go from 0-1
Sourcepub const fn with_alpha(&self, alpha: f32) -> Self
pub const fn with_alpha(&self, alpha: f32) -> Self
Get the same color a different transparency/alpha.
Sourcepub const fn splat_alpha(v: f32, alpha: f32) -> Self
pub const fn splat_alpha(v: f32, alpha: f32) -> Self
Create a color where RGA is a single number.
Sourcepub fn lerp(self, other: Color, t: f32) -> Self
pub fn lerp(self, other: Color, t: f32) -> Self
Linearly interpolate to another color using 0-1.
pub const fn clamped(&self) -> Self
Sourcepub const fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
pub const fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
Create a color using RGBA. Each value goes from 0-255.
Sourcepub const fn from_rgb8(r: u8, g: u8, b: u8) -> Self
pub const fn from_rgb8(r: u8, g: u8, b: u8) -> Self
Create a color using RGB. Each value goes from 0-255. (Alpha = 1)
Sourcepub fn from_hsv(h: f32, s: f32, v: f32) -> Self
pub fn from_hsv(h: f32, s: f32, v: f32) -> Self
Create a color using hue-saturation-value-alpha. All values go from 0-1.
Sourcepub fn from_hsva(h: f32, s: f32, v: f32, a: f32) -> Self
pub fn from_hsva(h: f32, s: f32, v: f32, a: f32) -> Self
Create a color using hue-saturation-value-alpha. All values go from 0-1.
Sourcepub fn from_hex(hex: &str) -> Option<Self>
pub fn from_hex(hex: &str) -> Option<Self>
Accepts “RRGGBB”, “RGB”, “RRGGBBAA”, “RGBA”, with or without leading ‘#’
Sourcepub fn to_hex_alpha(&self) -> String
pub fn to_hex_alpha(&self) -> String
Returns “#RRGGBBAA”
Sourcepub const fn from_vec4(vec: Vector4) -> Self
pub const fn from_vec4(vec: Vector4) -> Self
Create a color from a Vector4<f32> where x -> r, y -> g, z -> b, w -> a
Sourcepub const fn to_vec4(&self) -> Vector4
pub const fn to_vec4(&self) -> Vector4
Create a Vector4<f32> from a color where r -> x, g -> y, b -> z, a -> w
Sourcepub const fn from_vec3(vec: Vector3) -> Self
pub const fn from_vec3(vec: Vector3) -> Self
Create a color from a Vector3<f32> where x -> r, y -> g, z -> b
Source§impl Color
impl Color
pub const TRANSPARENT: Self
pub const WHITE: Self
pub const BLACK: Self
pub const LIGHT_BLACK: Self
pub const GRAY: Self
pub const DARK_GRAY: Self
pub const LIGHT_GRAY: Self
pub const RED: Self
pub const DARK_RED: Self
pub const LIGHT_RED: Self
pub const GREEN: Self
pub const DARK_GREEN: Self
pub const LIGHT_GREEN: Self
pub const BLUE: Self
pub const DARK_BLUE: Self
pub const LIGHT_BLUE: Self
pub const YELLOW: Self
pub const DARK_YELLOW: Self
pub const LIGHT_YELLOW: Self
pub const MAGENTA: Self
pub const DARK_MAGENTA: Self
pub const LIGHT_MAGENTA: Self
pub const PURPLE: Self
pub const DARK_PURPLE: Self
pub const LIGHT_PURPLE: Self
pub const CYAN: Self
pub const DARK_CYAN: Self
pub const LIGHT_CYAN: Self
pub const ORANGE: Self
pub const DARK_ORANGE: Self
pub const LIGHT_ORANGE: Self
Trait Implementations§
Source§impl AddAssign for Color
impl AddAssign for Color
Source§fn add_assign(&mut self, rhs: Color)
fn add_assign(&mut self, rhs: Color)
+= operation. Read moreimpl Copy for Color
Source§impl DivAssign for Color
impl DivAssign for Color
Source§fn div_assign(&mut self, rhs: Color)
fn div_assign(&mut self, rhs: Color)
/= operation. Read moreSource§impl DivAssign<f32> for Color
impl DivAssign<f32> for Color
Source§fn div_assign(&mut self, rhs: f32)
fn div_assign(&mut self, rhs: f32)
/= operation. Read moreSource§impl MulAssign for Color
impl MulAssign for Color
Source§fn mul_assign(&mut self, rhs: Color)
fn mul_assign(&mut self, rhs: Color)
*= operation. Read moreSource§impl MulAssign<f32> for Color
impl MulAssign<f32> for Color
Source§fn mul_assign(&mut self, rhs: f32)
fn mul_assign(&mut self, rhs: f32)
*= operation. Read moreimpl Pod 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 UnsafeUnpin for Color
impl UnwindSafe for Color
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.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>
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>
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)
&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)
&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<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> 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> ⓘ
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> ⓘ
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