pub struct Color {
pub r: f32,
pub g: f32,
pub b: f32,
pub a: f32,
}
Expand description
A color in the sRGB
color space.
Fields§
§r: f32
Red component, 0.0 - 1.0
g: f32
Green component, 0.0 - 1.0
b: f32
Blue component, 0.0 - 1.0
a: f32
Transparency, 0.0 - 1.0
Implementations§
source§impl Color
impl Color
sourcepub const TRANSPARENT: Color = _
pub const TRANSPARENT: Color = _
A color with no opacity.
sourcepub fn new(r: f32, g: f32, b: f32, a: f32) -> Color
pub fn new(r: f32, g: f32, b: f32, a: f32) -> Color
Creates a new Color
.
In debug mode, it will panic if the values are not in the correct range: 0.0 - 1.0
sourcepub const fn from_rgb(r: f32, g: f32, b: f32) -> Color
pub const fn from_rgb(r: f32, g: f32, b: f32) -> Color
Creates a Color
from its RGB components.
sourcepub const fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Color
pub const fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Color
Creates a Color
from its RGBA components.
sourcepub fn from_rgba8(r: u8, g: u8, b: u8, a: f32) -> Color
pub fn from_rgba8(r: u8, g: u8, b: u8, a: f32) -> Color
Creates a Color
from its RGB8 components and an alpha value.
sourcepub fn from_linear_rgba(r: f32, g: f32, b: f32, a: f32) -> Self
pub fn from_linear_rgba(r: f32, g: f32, b: f32, a: f32) -> Self
Creates a Color
from its linear RGBA components.
sourcepub fn into_rgba8(self) -> [u8; 4]
pub fn into_rgba8(self) -> [u8; 4]
Converts the Color
into its RGBA8 equivalent.
sourcepub fn into_linear(self) -> [f32; 4]
pub fn into_linear(self) -> [f32; 4]
Converts the Color
into its linear values.
Trait Implementations§
source§impl From<Color> for Background
impl From<Color> for Background
source§impl PartialEq for Color
impl PartialEq for Color
impl Copy for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
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