pub struct Color(pub f32, pub f32, pub f32, pub f32);
Expand description
A color value consisting of four floating point values for the color channels red, green, blue and alpha.
Various drawing methods accept color instances to be used as multiplicators in the drawing
process, e.g. Sprite::draw()
allows multiplying the sprite-
texture’s color channels by given color.
Tuple Fields§
§0: f32
§1: f32
§2: f32
§3: f32
Implementations§
Source§impl Color
impl Color
pub const TRANSPARENT: Color = _
pub const WHITE: Color = _
pub const BLACK: Color = _
pub const RED: Color = _
pub const GREEN: Color = _
pub const BLUE: Color = _
pub const YELLOW: Color = _
pub const CYAN: Color = _
pub const MAGENTA: Color = _
Sourcepub fn alpha(alpha: f32) -> Color
pub fn alpha(alpha: f32) -> Color
Creates a new instance with color channels set to one and the alpha channel set to given value.
Sourcepub fn alpha_mask(alpha: f32) -> Color
pub fn alpha_mask(alpha: f32) -> Color
Creates a new instance with color channels set to zero and the alpha channel set to given value.
Sourcepub fn alpha_pm(alpha: f32) -> Color
pub fn alpha_pm(alpha: f32) -> Color
Creates a new instance with all channels set to given value.
Sourcepub fn lightness(value: f32) -> Color
pub fn lightness(value: f32) -> Color
Creates a new instance with color channels set to given value and the alpha channel set to one.
Sourcepub fn from_hsl(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Color
pub fn from_hsl(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Color
Creates a new instance from given HSL (range 0.0 - 1.0)
Sourcepub fn from_temperature(temperature: f32, alpha: f32) -> Color
pub fn from_temperature(temperature: f32, alpha: f32) -> Color
Creates a new instance from given color-temperature (~1000 to ~40000).
Based on http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
Sourcepub fn set_g(&mut self, value: f32) -> &mut Color
pub fn set_g(&mut self, value: f32) -> &mut Color
Sets a value for the instance’s green channel.
Sourcepub fn set_b(&mut self, value: f32) -> &mut Color
pub fn set_b(&mut self, value: f32) -> &mut Color
Sets a value for the instance’s blue channel.
Sourcepub fn set_a(&mut self, value: f32) -> &mut Color
pub fn set_a(&mut self, value: f32) -> &mut Color
Sets a value for the instance’s alpha channel.
Sourcepub fn scale(&mut self, scaling: f32) -> &mut Color
pub fn scale(&mut self, scaling: f32) -> &mut Color
Multiplies the instance’s color channels by given scaling factor. Does not modify alpha.
pub fn to_pm(&self) -> Color
Trait Implementations§
Source§impl<T> From<(T, T, T, T)> for Color
impl<T> From<(T, T, T, T)> for Color
Source§fn from(source: (T, T, T, T)) -> Self
fn from(source: (T, T, T, T)) -> Self
impl Copy for Color
impl StructuralPartialEq 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<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Content for Twhere
T: Copy,
impl<T> Content for Twhere
T: Copy,
Source§fn read<F, E>(size: usize, f: F) -> Result<T, E>
fn read<F, E>(size: usize, f: F) -> Result<T, E>
Owned
.Source§fn get_elements_size() -> usize
fn get_elements_size() -> usize
Source§fn to_void_ptr(&self) -> *const ()
fn to_void_ptr(&self) -> *const ()
Source§fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
Source§fn is_size_suitable(size: usize) -> bool
fn is_size_suitable(size: usize) -> bool
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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