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

§red: f32

Red component. [0.0, 1.0]

§green: f32

Green component. [0.0, 1.0]

§blue: f32

Blue component. [0.0, 1.0]

§alpha: f32

Alpha component. [0.0, 1.0]

sRGBA color

§

RgbaLinear

Fields

§red: f32

Red component. [0.0, 1.0]

§green: f32

Green component. [0.0, 1.0]

§blue: f32

Blue component. [0.0, 1.0]

§alpha: f32

Alpha component. [0.0, 1.0]

RGBA color in the Linear sRGB colorspace (often colloquially referred to as “linear”, “RGB”, or “linear RGB”).

§

Hsla

Fields

§hue: f32

Hue component. [0.0, 360.0]

§saturation: f32

Saturation component. [0.0, 1.0]

§lightness: f32

Lightness component. [0.0, 1.0]

§alpha: f32

Alpha component. [0.0, 1.0]

HSL (hue, saturation, lightness) color with an alpha channel

Implementations§

source§

impl Color

source

pub const WHITE: Color = _

source

pub const BLACK: Color = _

source

pub const TRANSPARENT: Color = _

source

pub const fn rgb(r: f32, g: f32, b: f32) -> Color

New Color from sRGB colorspace.

source

pub const fn rgba(r: f32, g: f32, b: f32, a: f32) -> Color

New Color from sRGB colorspace.

source

pub const fn rgb_linear(r: f32, g: f32, b: f32) -> Color

New Color from linear RGB colorspace.

source

pub const fn rgba_linear(r: f32, g: f32, b: f32, a: f32) -> Color

New Color from linear RGB colorspace.

source

pub const fn hsl(hue: f32, saturation: f32, lightness: f32) -> Color

New Color with HSL representation in sRGB colorspace.

source

pub const fn hsla( hue: f32, saturation: f32, lightness: f32, alpha: f32 ) -> Color

New Color with HSL representation in sRGB colorspace.

source

pub fn hex<T: AsRef<str>>(hex: T) -> Result<Color, HexColorError>

New Color from sRGB colorspace.

source

pub fn u8_debug(v: u8) -> Self

source

pub fn rgb_u8(r: u8, g: u8, b: u8) -> Color

New Color from sRGB colorspace.

source

pub fn rgba_u8(r: u8, g: u8, b: u8, a: u8) -> Color

New Color from sRGB colorspace.

source

pub fn r(&self) -> f32

Get red in sRGB colorspace.

source

pub fn g(&self) -> f32

Get green in sRGB colorspace.

source

pub fn b(&self) -> f32

Get blue in sRGB colorspace.

source

pub fn set_r(&mut self, r: f32) -> &mut Self

Set red in sRGB colorspace.

source

pub fn set_g(&mut self, g: f32) -> &mut Self

Set green in sRGB colorspace.

source

pub fn set_b(&mut self, b: f32) -> &mut Self

Set blue in sRGB colorspace.

source

pub fn a(&self) -> f32

Get alpha.

source

pub fn set_a(&mut self, a: f32) -> &mut Self

Set alpha.

source

pub fn as_rgba(self: &Color) -> Color

Converts a Color to variant Color::Rgba

source

pub fn as_rgba_linear(self: &Color) -> Color

Converts a Color to variant Color::RgbaLinear

source

pub fn as_hsla(self: &Color) -> Color

Converts a Color to variant Color::Hsla

source

pub fn as_rgba_f32(self: Color) -> [f32; 4]

Converts a Color to a [f32; 4] from sRGB colorspace

source

pub fn as_linear_rgba_f32(self: Color) -> [f32; 4]

Converts a Color to a [f32; 4] from linear RGB colorspace

source

pub fn as_hsla_f32(self: Color) -> [f32; 4]

Converts a Color to a [f32; 4] from HSL colorspace

source

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.

source

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.

source

pub fn saturate(self, amount: f32) -> Self

source

pub fn desaturate(self, amount: f32) -> Self

source

pub fn lighten(self, amount: f32) -> Self

source

pub fn darken(self, amount: f32) -> Self

Trait Implementations§

source§

impl Add<Vec4> for Color

§

type Output = Color

The resulting type after applying the + operator.
source§

fn add(self, rhs: Vec4) -> Self::Output

Performs the + operation. Read more
source§

impl Add for Color

§

type Output = Color

The resulting type after applying the + operator.
source§

fn add(self, rhs: Color) -> Self::Output

Performs the + operation. Read more
source§

impl AddAssign<Vec4> for Color

source§

fn add_assign(&mut self, rhs: Vec4)

Performs the += operation. Read more
source§

impl AddAssign for Color

source§

fn add_assign(&mut self, rhs: Color)

Performs the += operation. Read more
source§

impl Clone for Color

source§

fn clone(&self) -> Color

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Color

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Color

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Color

source§

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 From<[f32; 3]> for Color

source§

fn from([r, g, b]: [f32; 3]) -> Self

Converts to this type from the input type.
source§

impl From<[f32; 4]> for Color

source§

fn from([r, g, b, a]: [f32; 4]) -> Self

Converts to this type from the input type.
source§

impl From<Color> for [f32; 4]

source§

fn from(color: Color) -> Self

Converts to this type from the input type.
source§

impl From<Color> for Vec3

source§

fn from(color: Color) -> Self

Converts to this type from the input type.
source§

impl From<Color> for Vec4

source§

fn from(color: Color) -> Self

Converts to this type from the input type.
source§

impl From<Vec4> for Color

source§

fn from(vec4: Vec4) -> Self

Converts to this type from the input type.
source§

impl Mul<[f32; 3]> for Color

§

type Output = Color

The resulting type after applying the * operator.
source§

fn mul(self, rhs: [f32; 3]) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<[f32; 4]> for Color

§

type Output = Color

The resulting type after applying the * operator.
source§

fn mul(self, rhs: [f32; 4]) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vec3> for Color

§

type Output = Color

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec3) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<Vec4> for Color

§

type Output = Color

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Vec4) -> Self::Output

Performs the * operation. Read more
source§

impl Mul<f32> for Color

§

type Output = Color

The resulting type after applying the * operator.
source§

fn mul(self, rhs: f32) -> Self::Output

Performs the * operation. Read more
source§

impl MulAssign<[f32; 3]> for Color

source§

fn mul_assign(&mut self, rhs: [f32; 3])

Performs the *= operation. Read more
source§

impl MulAssign<[f32; 4]> for Color

source§

fn mul_assign(&mut self, rhs: [f32; 4])

Performs the *= operation. Read more
source§

impl MulAssign<Vec3> for Color

source§

fn mul_assign(&mut self, rhs: Vec3)

Performs the *= operation. Read more
source§

impl MulAssign<Vec4> for Color

source§

fn mul_assign(&mut self, rhs: Vec4)

Performs the *= operation. Read more
source§

impl MulAssign<f32> for Color

source§

fn mul_assign(&mut self, rhs: f32)

Performs the *= operation. Read more
source§

impl PartialEq for Color

source§

fn eq(&self, other: &Color) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Color

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Color

source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,