#[repr(C)]pub struct ColorF {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
Expand description
Represents RGBA screen colors with floating point numbers.
All components must be between 0.0 and 1.0. An alpha value of 1.0 is opaque while 0.0 is fully transparent.
Fields§
§r: f32
§g: f32
§b: f32
§a: f32
Implementations§
Source§impl ColorF
impl ColorF
pub const BLACK: ColorF = _
pub const TRANSPARENT: ColorF = _
pub const WHITE: ColorF = _
Sourcepub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Self
Constructs a new ColorF
from its components.
Sourcepub fn scale_rgb(&self, scale: f32) -> Self
pub fn scale_rgb(&self, scale: f32) -> Self
Multiply the RGB channels (but not alpha) with a given factor.
pub fn scale_alpha(&self, scale: f32) -> Self
pub fn to_array(&self) -> [f32; 4]
Sourcepub fn premultiplied(&self) -> PremultipliedColorF
pub fn premultiplied(&self) -> PremultipliedColorF
Multiply the RGB components with the alpha channel.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ColorF
impl<'de> Deserialize<'de> for ColorF
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 MallocSizeOf for ColorF
impl MallocSizeOf for ColorF
Source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
impl Copy for ColorF
impl StructuralPartialEq for ColorF
Auto Trait Implementations§
impl Freeze for ColorF
impl RefUnwindSafe for ColorF
impl Send for ColorF
impl Sync for ColorF
impl Unpin for ColorF
impl UnwindSafe for ColorF
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