#[repr(C)]
pub enum Color { Rgba { red: f32, green: f32, blue: f32, alpha: f32, }, }
Expand description

Color type.

Variants§

§

Rgba

Fields

§red: f32

Red channel. [0.0, 1.0]

§green: f32

Green channel. [0.0, 1.0]

§blue: f32

Blue channel. [0.0, 1.0]

§alpha: f32

Alpha channel. [0.0, 1.0]

sRGBA color

Implementations§

source§

impl Color

source

pub const BLACK: Color = Color::rgb(0.0, 0.0, 0.0)

source

pub const BLUE: Color = Color::rgb(0.0, 0.0, 1.0)

source

pub const CYAN: Color = Color::rgb(0.0, 1.0, 1.0)

source

pub const GRAY: Color = Color::rgb(0.5, 0.5, 0.5)

source

pub const GREEN: Color = Color::rgb(0.0, 1.0, 0.0)

source

pub const NONE: Color = Color::rgba(0.0, 0.0, 0.0, 0.0)

source

pub const ORANGE: Color = Color::rgb(1.0, 0.65, 0.0)

source

pub const RED: Color = Color::rgb(1.0, 0.0, 0.0)

source

pub const WHITE: Color = Color::rgb(1.0, 1.0, 1.0)

source

pub const YELLOW: Color = Color::rgb(1.0, 1.0, 0.0)

source

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

New Color from sRGB colorspace.

Arguments
  • r - Red channel. [0.0, 1.0]
  • g - Green channel. [0.0, 1.0]
  • b - Blue channel. [0.0, 1.0]

See also Color::rgba, Color::rgb_u8, Color::hex.

source

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

New Color from sRGB colorspace.

Arguments
  • r - Red channel. [0.0, 1.0]
  • g - Green channel. [0.0, 1.0]
  • b - Blue channel. [0.0, 1.0]
  • a - Alpha channel. [0.0, 1.0]

See also Color::rgb, Color::rgba_u8, Color::hex.

source

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

New Color from sRGB colorspace.

Examples
let color = Color::hex("FF00FF").unwrap(); // fuchsia
let color = Color::hex("FF00FF7F").unwrap(); // partially transparent fuchsia
source

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

New Color from sRGB colorspace.

Arguments
  • r - Red channel. [0, 255]
  • g - Green channel. [0, 255]
  • b - Blue channel. [0, 255]

See also Color::rgb, Color::rgba_u8, Color::hex.

source

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

New Color from sRGB colorspace.

Arguments
  • r - Red channel. [0, 255]
  • g - Green channel. [0, 255]
  • b - Blue channel. [0, 255]
  • a - Alpha channel. [0, 255]

See also Color::rgba, Color::rgb_u8, Color::hex.

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 Color

Set red in sRGB colorspace.

source

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

Set green in sRGB colorspace.

source

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

Set blue in sRGB colorspace.

source

pub fn a(&self) -> f32

Get alpha.

source

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

Set alpha.

source

pub fn as_rgba(&self) -> Color

Converts a Color to variant Color::Rgba

source

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

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

Trait Implementations§

source§

impl Add<Color> for Color

§

type Output = Color

The resulting type after applying the + operator.
source§

fn add(self, rhs: Color) -> <Color as Add<Color>>::Output

Performs the + operation. Read more
source§

impl AddAssign<Color> 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<(), Error>

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

impl Default for Color

source§

fn default() -> Color

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

impl From<[f32; 3]> for Color

source§

fn from(_: [f32; 3]) -> Color

Converts to this type from the input type.
source§

impl From<[f32; 4]> for Color

source§

fn from(_: [f32; 4]) -> Color

Converts to this type from the input type.
source§

impl From<Color> for Vec4

source§

fn from(color: Color) -> Vec4

Converts to this type from the input type.
source§

impl From<Vec4> for Color

source§

fn from(vec4: Vec4) -> Color

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]) -> <Color as Mul<[f32; 3]>>::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]) -> <Color as Mul<[f32; 4]>>::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) -> <Color as Mul<Vec3>>::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) -> <Color as Mul<Vec4>>::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) -> <Color as Mul<f32>>::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 TypeUlid for Color

source§

const ULID: Ulid = ::type_ulid::Ulid(2030302175124572590461920474176519685u128)

The type’s Ulid.
source§

impl Copy 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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> FromWorld for Twhere T: Default,

source§

fn from_world(_world: &mut World) -> T

Creates Self using data from the given World.
source§

impl<T, U> Into<U> for Twhere 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> RawFns for Twhere T: Clone,

source§

unsafe extern "C" fn raw_drop(ptr: *mut u8)

Drop the value at ptr. Read more
source§

unsafe extern "C" fn raw_clone(src: *const u8, dst: *mut u8)

Clone the value at src, writing the new value to dst. Read more
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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<T> TypeUlidDynamic for Twhere T: TypeUlid,

source§

fn ulid(&self) -> Ulid

§

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

§

fn vzip(self) -> V

source§

impl<T> EcsData for Twhere T: Clone + Sync + Send + 'static,

source§

impl<T> TypedEcsData for Twhere T: TypeUlid + EcsData,