radiant_rs

Struct Color

Source
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

Source

pub const TRANSPARENT: Color = _

Source

pub const WHITE: Color = _

Source

pub const BLACK: Color = _

Source

pub const RED: Color = _

Source

pub const GREEN: Color = _

Source

pub const BLUE: Color = _

Source

pub const YELLOW: Color = _

Source

pub const CYAN: Color = _

Source

pub const MAGENTA: Color = _

Source

pub fn alpha(alpha: f32) -> Color

Creates a new instance with color channels set to one and the alpha channel set to given value.

Source

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.

Source

pub fn alpha_pm(alpha: f32) -> Color

Creates a new instance with all channels set to given value.

Source

pub fn lightness(value: f32) -> Color

Creates a new instance with color channels set to given value and the alpha channel set to one.

Source

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)

Source

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/

Source

pub fn r(&self) -> f32

Returns value of the instance’s red channel.

Source

pub fn g(&self) -> f32

Returns value of the instance’s green channel.

Source

pub fn b(&self) -> f32

Returns value of the instance’s blue channel.

Source

pub fn a(&self) -> f32

Returns value of the instance’s alpha channel.

Source

pub fn set(&mut self, value: Color)

Sets the instance’s channels from another color object.

Source

pub fn set_r(&mut self, value: f32) -> &mut Color

Sets a value for the instance’s red channel

Source

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

Sets a value for the instance’s green channel.

Source

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

Sets a value for the instance’s blue channel.

Source

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

Sets a value for the instance’s alpha channel.

Source

pub fn scale(&mut self, scaling: f32) -> &mut Color

Multiplies the instance’s color channels by given scaling factor. Does not modify alpha.

Source

pub fn to_pm(&self) -> Color

Trait Implementations§

Source§

impl AsUniform for Color

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() -> Color

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

impl<'a> From<&'a Color> for [f32; 4]

Source§

fn from(source: &'a Color) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a Color> for (f32, f32, f32, f32)

Source§

fn from(source: &'a Color) -> Self

Converts to this type from the input type.
Source§

impl<T> From<[T; 4]> for Color
where T: Copy, f32: From<T>,

Source§

fn from(source: [T; 4]) -> Self

Converts to this type from the input type.
Source§

impl<T> From<(T, T, T, T)> for Color
where f32: From<T>,

Source§

fn from(source: (T, T, T, T)) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for [f32; 4]

Source§

fn from(source: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for (f32, f32, f32, f32)

Source§

fn from(source: Color) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Color

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Color

Source§

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
where T: Float, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
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, dst: *mut T)

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

impl<T> Content for T
where T: Copy,

Source§

type Owned = T

A type that holds a sized version of the content.
Source§

fn read<F, E>(size: usize, f: F) -> Result<T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

Prepares an output buffer, then turns this buffer into an Owned.
Source§

fn get_elements_size() -> usize

Returns the size of each element.
Source§

fn to_void_ptr(&self) -> *const ()

Produces a pointer to the data.
Source§

fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>

Builds a pointer to this type from a raw pointer.
Source§

fn is_size_suitable(size: usize) -> bool

Returns true if the size is suitable to store a type like this.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> 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> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
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> Erased for T