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 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.