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
impl Color
impl Color
pub const ALICE_BLUE: Color = Color::rgb(0.94, 0.97, 1.0)
pub const ALICE_BLUE: Color = Color::rgb(0.94, 0.97, 1.0)
pub const ANTIQUE_WHITE: Color = Color::rgb(0.98, 0.92, 0.84)
pub const ANTIQUE_WHITE: Color = Color::rgb(0.98, 0.92, 0.84)
pub const AQUAMARINE: Color = Color::rgb(0.49, 1.0, 0.83)
pub const AQUAMARINE: Color = Color::rgb(0.49, 1.0, 0.83)
pub const DARK_GREEN: Color = Color::rgb(0.0, 0.5, 0.0)
pub const DARK_GREEN: Color = Color::rgb(0.0, 0.5, 0.0)
pub const LIME_GREEN: Color = Color::rgb(0.2, 0.8, 0.2)
pub const LIME_GREEN: Color = Color::rgb(0.2, 0.8, 0.2)
pub const MIDNIGHT_BLUE: Color = Color::rgb(0.1, 0.1, 0.44)
pub const MIDNIGHT_BLUE: Color = Color::rgb(0.1, 0.1, 0.44)
pub const ORANGE_RED: Color = Color::rgb(1.0, 0.27, 0.0)
pub const ORANGE_RED: Color = Color::rgb(1.0, 0.27, 0.0)
pub const YELLOW_GREEN: Color = Color::rgb(0.6, 0.8, 0.2)
pub const YELLOW_GREEN: Color = Color::rgb(0.6, 0.8, 0.2)
pub const fn rgb_linear(r: f32, g: f32, b: f32) -> Color
pub const fn rgb_linear(r: f32, g: f32, b: f32) -> Color
New Color
from linear RGB colorspace.
pub 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.
pub 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.
pub 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.
pub fn hex<T>(hex: T) -> Result<Color, HexColorError> where
T: AsRef<str>,
pub fn hex<T>(hex: T) -> Result<Color, HexColorError> where
T: AsRef<str>,
New Color
from sRGB colorspace.
pub fn as_rgba_linear(&self) -> Color
pub fn as_rgba_linear(&self) -> Color
Converts a Color
to variant Color::RgbaLinear
pub fn as_rgba_f32(self) -> [f32; 4]
pub fn as_rgba_f32(self) -> [f32; 4]
Converts a Color
to a [f32; 4]
from sRGB colorspace
pub fn as_linear_rgba_f32(self) -> [f32; 4]
pub fn as_linear_rgba_f32(self) -> [f32; 4]
Converts a Color
to a [f32; 4]
from linear RGB colorspace
pub fn as_hsla_f32(self) -> [f32; 4]
pub fn as_hsla_f32(self) -> [f32; 4]
Converts a Color
to a [f32; 4]
from HSL colorspace
pub fn as_rgba_u32(self) -> u32
pub fn as_rgba_u32(self) -> 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.
pub fn as_linear_rgba_u32(self) -> u32
pub fn as_linear_rgba_u32(self) -> 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.
Trait Implementations
impl AddAssign<Color> for Color
impl AddAssign<Color> for Color
fn add_assign(&mut self, rhs: Color)
fn add_assign(&mut self, rhs: Color)
Performs the +=
operation. Read more
impl AddAssign<Vec4> for Color
impl AddAssign<Vec4> for Color
fn add_assign(&mut self, rhs: Vec4)
fn add_assign(&mut self, rhs: Vec4)
Performs the +=
operation. Read more
impl CreateFrom for Color
impl CreateFrom for Color
fn create_from<B>(reader: &mut Reader<B>) -> Color where
B: BufferRef,
impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
fn deserialize<__D>(
__deserializer: __D
) -> Result<Color, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Color, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl From<Color> for ColorMaterial
impl From<Color> for ColorMaterial
fn from(color: Color) -> ColorMaterial
fn from(color: Color) -> ColorMaterial
Converts to this type from the input type.
impl From<Color> for StandardMaterial
impl From<Color> for StandardMaterial
fn from(color: Color) -> StandardMaterial
fn from(color: Color) -> StandardMaterial
Converts to this type from the input type.
impl FromReflect for Color
impl FromReflect for Color
fn from_reflect(reflect: &(dyn Reflect + 'static)) -> Option<Color>
fn from_reflect(reflect: &(dyn Reflect + 'static)) -> Option<Color>
Constructs a concrete instance of Self
from a reflected value.
impl GetTypeRegistration for Color
impl GetTypeRegistration for Color
impl MulAssign<[f32; 3]> for Color
impl MulAssign<[f32; 3]> for Color
fn mul_assign(&mut self, rhs: [f32; 3])
fn mul_assign(&mut self, rhs: [f32; 3])
Performs the *=
operation. Read more
impl MulAssign<[f32; 4]> for Color
impl MulAssign<[f32; 4]> for Color
fn mul_assign(&mut self, rhs: [f32; 4])
fn mul_assign(&mut self, rhs: [f32; 4])
Performs the *=
operation. Read more
impl MulAssign<Vec3> for Color
impl MulAssign<Vec3> for Color
fn mul_assign(&mut self, rhs: Vec3)
fn mul_assign(&mut self, rhs: Vec3)
Performs the *=
operation. Read more
impl MulAssign<Vec4> for Color
impl MulAssign<Vec4> for Color
fn mul_assign(&mut self, rhs: Vec4)
fn mul_assign(&mut self, rhs: Vec4)
Performs the *=
operation. Read more
impl PartialEq<Color> for Color
impl PartialEq<Color> for Color
impl Reflect for Color
impl Reflect for Color
fn get_type_info(&self) -> &'static TypeInfo
fn get_type_info(&self) -> &'static TypeInfo
fn into_any(self: Box<Color, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<Color, Global>) -> Box<dyn Any + 'static, Global>
Returns the value as a Box<dyn Any>
.
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns the value as a &mut dyn Any
.
fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Casts this type to a reflected value
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Casts this type to a mutable reflected value
fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
fn clone_value(&self) -> Box<dyn Reflect + 'static, Global>
Clones the value as a Reflect
trait object. Read more
fn apply(&mut self, value: &(dyn Reflect + 'static))
fn apply(&mut self, value: &(dyn Reflect + 'static))
Applies a reflected value to this value. Read more
fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
fn set(
&mut self,
value: Box<dyn Reflect + 'static, Global>
) -> Result<(), Box<dyn Reflect + 'static, Global>>
Performs a type-checked assignment of a reflected value to this value. Read more
fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Returns an enumeration of “kinds” of type. Read more
fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Returns a mutable enumeration of “kinds” of type. Read more
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
fn reflect_partial_eq(&self, value: &(dyn Reflect + 'static)) -> Option<bool>
Returns a “partial equality” comparison result. Read more
fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Returns a hash of the value (which includes the type). Read more
fn serializable(&self) -> Option<Serializable<'_>>
fn serializable(&self) -> Option<Serializable<'_>>
Returns a serializable version of the value. Read more
impl Serialize for Color
impl Serialize for Color
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl ShaderSize for Color
impl ShaderSize for Color
const SHADER_SIZE: NonZeroU64 =
const SHADER_SIZE: NonZeroU64 =
Represents WGSL Size (equivalent to ShaderType::min_size
)
impl ShaderType for Color
impl ShaderType for Color
fn min_size() -> NonZeroU64
fn min_size() -> NonZeroU64
Represents the minimum size of Self
(equivalent to GPUBufferBindingLayout.minBindingSize) Read more
fn size(&self) -> NonZeroU64
fn size(&self) -> NonZeroU64
Returns the size of Self
at runtime Read more
fn assert_uniform_compat()
fn assert_uniform_compat()
Asserts that Self
meets the requirements of the
uniform address space restrictions on stored values and the
uniform address space layout constraints Read more
impl WriteInto for Color
impl WriteInto for Color
fn write_into<B>(&self, writer: &mut Writer<B>) where
B: BufferMut,
impl Copy for Color
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
impl<T, U> AsBindGroupShaderType<U> for T where
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for T where
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
fn as_bind_group_shader_type(
&self,
_images: &HashMap<Handle<Image>, <Image as RenderAsset>::PreparedAsset, RandomState, Global>
) -> U
Return the T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
impl<T> FromWorld for T where
T: Default,
impl<T> FromWorld for T where
T: Default,
fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self
using data from the given World
impl<T> GetPath for T where
T: Reflect,
impl<T> GetPath for T where
T: Reflect,
fn path(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn path(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
Returns a reference to the value specified by path
. Read more
fn path_mut(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn path_mut(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
Returns a mutable reference to the value specified by path
. Read more
fn get_path<T>(&'r self, path: &'p str) -> Result<&'r T, ReflectPathError<'p>> where
T: Reflect,
fn get_path<T>(&'r self, path: &'p str) -> Result<&'r T, ReflectPathError<'p>> where
T: Reflect,
Returns a statically typed reference to the value specified by path
.
fn get_path_mut<T>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>> where
T: Reflect,
fn get_path_mut<T>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>> where
T: Reflect,
Returns a statically typed mutable reference to the value specified by
path
. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
impl<T> TypeData for T where
T: 'static + Send + Sync + Clone,
impl<T> TypeData for T where
T: 'static + Send + Sync + Clone,
fn clone_type_data(&self) -> Box<dyn TypeData + 'static, Global>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more