Enum ambient_color::Color
source · pub enum Color {
Rgba {
red: f32,
green: f32,
blue: f32,
alpha: f32,
},
RgbaLinear {
red: f32,
green: f32,
blue: f32,
alpha: f32,
},
Hsla {
hue: f32,
saturation: f32,
lightness: f32,
alpha: f32,
},
}
Variants§
Rgba
Fields
sRGBA color
RgbaLinear
Fields
RGBA color in the Linear sRGB colorspace (often colloquially referred to as “linear”, “RGB”, or “linear RGB”).
Hsla
Fields
HSL (hue, saturation, lightness) color with an alpha channel
Implementations§
source§impl Color
impl Color
pub const WHITE: Color = _
pub const BLACK: Color = _
pub const TRANSPARENT: Color = _
sourcepub const fn rgba_linear(r: f32, g: f32, b: f32, a: f32) -> Color
pub const fn rgba_linear(r: f32, g: f32, b: f32, a: f32) -> Color
New Color
from linear RGB colorspace.
sourcepub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color
pub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color
New Color
with HSL representation in sRGB colorspace.
sourcepub const fn hsla(
hue: f32,
saturation: f32,
lightness: f32,
alpha: f32
) -> Color
pub const fn hsla( hue: f32, saturation: f32, lightness: f32, alpha: f32 ) -> Color
New Color
with HSL representation in sRGB colorspace.
sourcepub fn hex<T: AsRef<str>>(hex: T) -> Result<Color, HexColorError>
pub fn hex<T: AsRef<str>>(hex: T) -> Result<Color, HexColorError>
New Color
from sRGB colorspace.
pub fn u8_debug(v: u8) -> Self
sourcepub fn as_rgba_linear(self: &Color) -> Color
pub fn as_rgba_linear(self: &Color) -> Color
Converts a Color
to variant Color::RgbaLinear
sourcepub fn as_rgba_f32(self: Color) -> [f32; 4]
pub fn as_rgba_f32(self: Color) -> [f32; 4]
Converts a Color
to a [f32; 4]
from sRGB colorspace
sourcepub fn as_linear_rgba_f32(self: Color) -> [f32; 4]
pub fn as_linear_rgba_f32(self: Color) -> [f32; 4]
Converts a Color
to a [f32; 4]
from linear RGB colorspace
sourcepub fn as_hsla_f32(self: Color) -> [f32; 4]
pub fn as_hsla_f32(self: Color) -> [f32; 4]
Converts a Color
to a [f32; 4]
from HSL colorspace
sourcepub fn as_rgba_u32(self: Color) -> u32
pub fn as_rgba_u32(self: Color) -> u32
Converts Color
to a u32
from sRGB colorspace.
Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian).
A
will be the most significant byte and R
the least significant.
sourcepub fn as_linear_rgba_u32(self: Color) -> u32
pub fn as_linear_rgba_u32(self: Color) -> u32
Converts Color to a u32 from linear RGB colorspace.
Maps the RGBA channels in RGBA order to a little-endian byte array (GPUs are little-endian).
A
will be the most significant byte and R
the least significant.
pub fn saturate(self, amount: f32) -> Self
pub fn desaturate(self, amount: f32) -> Self
pub fn lighten(self, amount: f32) -> Self
pub fn darken(self, amount: f32) -> Self
Trait Implementations§
source§impl AddAssign<Vec4> for Color
impl AddAssign<Vec4> for Color
source§fn add_assign(&mut self, rhs: Vec4)
fn add_assign(&mut self, rhs: Vec4)
+=
operation. Read moresource§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 moresource§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
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>,
source§impl MulAssign<Vec3> for Color
impl MulAssign<Vec3> for Color
source§fn mul_assign(&mut self, rhs: Vec3)
fn mul_assign(&mut self, rhs: Vec3)
*=
operation. Read moresource§impl MulAssign<Vec4> for Color
impl MulAssign<Vec4> for Color
source§fn mul_assign(&mut self, rhs: Vec4)
fn mul_assign(&mut self, rhs: Vec4)
*=
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 more