pub struct Rgba {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}Expand description
RGBA color with sRGB-style channels conventionally stored in the 0.0..=1.0 range.
Fields§
§r: f32§g: f32§b: f32§a: f32Implementations§
Source§impl Rgba
impl Rgba
pub const BLACK: Self
pub const WHITE: Self
pub const fn new(r: f32, g: f32, b: f32, a: f32) -> Self
pub const fn rgb8(r: u8, g: u8, b: u8) -> Self
pub const fn rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
pub fn mix(self, other: Self, amount: f32) -> Self
pub fn sanitized(self) -> Self
Sourcepub fn relative_luminance(self) -> f32
pub fn relative_luminance(self) -> f32
Returns WCAG relative luminance, clamping non-finite or out-of-range color channels.
Sourcepub fn contrast_ratio(self, other: Self) -> f32
pub fn contrast_ratio(self, other: Self) -> f32
Returns the WCAG contrast ratio between two colors.
Sourcepub fn readable_text_color(self) -> Self
pub fn readable_text_color(self) -> Self
Chooses black or white text, whichever has higher contrast on this color.
pub fn to_array(self) -> [f32; 4]
Trait Implementations§
impl Copy for Rgba
Source§impl<'de> Deserialize<'de> for Rgba
impl<'de> Deserialize<'de> for Rgba
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
impl StructuralPartialEq for Rgba
Auto Trait Implementations§
impl Freeze for Rgba
impl RefUnwindSafe for Rgba
impl Send for Rgba
impl Sync for Rgba
impl Unpin for Rgba
impl UnsafeUnpin for Rgba
impl UnwindSafe for Rgba
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