Color

Enum Color 

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

Color type.

Variants§

§

Rgba

sRGBA color

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]

Implementations§

Source§

impl Color

Source

pub const BLACK: Color

Source

pub const BLUE: Color

Source

pub const CYAN: Color

Source

pub const GRAY: Color

Source

pub const GREEN: Color

Source

pub const NONE: Color

Source

pub const ORANGE: Color

Source

pub const RED: Color

Source

pub const WHITE: Color

Source

pub const YELLOW: Color

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: AsRef<str>>(hex: T) -> Result<Color, HexColorError>

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 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_f32(self: Color) -> [f32; 4]

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

Trait Implementations§

Source§

impl Add for Color

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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 TypeUlid for Color

Source§

const ULID: Ulid

The type’s Ulid.
Source§

impl Copy for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromWorld for T
where 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 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> RawFns for T
where 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 T
where T: Clone,

Source§

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

Source§

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

Source§

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 T
where T: TypeUlid,

Source§

fn ulid(&self) -> Ulid

Source§

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

Source§

fn vzip(self) -> V

Source§

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

Source§

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