Skip to main content

RGBAColor

Struct RGBAColor 

Source
pub struct RGBAColor {
    pub r: u8,
    pub g: u8,
    pub b: u8,
    pub a: u8,
}
Expand description

RGBA Color

§Examples

use xuko_misc::color::RGBAColor;
let color = RGBAColor::from(0xFF33AA);

assert_eq!(color.r, 255);
assert_eq!(color.g, 51);
assert_eq!(color.b, 170);
assert_eq!(color.a, 255);

Fields§

§r: u8

The red component of the RGBAColor

§g: u8

The green component of the RGBAColor

§b: u8

The blue component of the RGBAColor

§a: u8

The alpha component of the RGBAColor

Implementations§

Source§

impl RGBAColor

Source

pub fn new(c: impl Into<RGBAColor>) -> Self

Create a new RGBAColor from anything that implements Into<RGBAColor>

Source

pub fn try_new( c: impl TryInto<RGBAColor, Error = ColorCreationError>, ) -> Result<Self, ColorCreationError>

Create a new RGBAColor from anything that implements TryInto<RGBAColor, Error = ColorCreationError>

Source

pub const fn add(&self, other: &Self) -> Self

Add a color with another.

Source

pub const fn sub(&self, other: &Self) -> Self

Subtract a color from another.

Source

pub const fn mul(&self, other: &Self) -> Self

Multiply a color with another.

Source

pub const fn colorize(&self, other: &Self) -> Self

Colorize color to another color.

Trait Implementations§

Source§

impl Clone for RGBAColor

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RGBAColor

Source§

impl Debug for RGBAColor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

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

impl Default for RGBAColor

Source§

fn default() -> Self

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

impl Eq for RGBAColor

Source§

impl From<(u8, u8, u8)> for RGBAColor

Source§

fn from(value: (u8, u8, u8)) -> Self

Converts to this type from the input type.
Source§

impl From<(u8, u8, u8, u8)> for RGBAColor

Source§

fn from(value: (u8, u8, u8, u8)) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 3]> for RGBAColor

Source§

fn from(value: [u8; 3]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 4]> for RGBAColor

Source§

fn from(value: [u8; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for RGBAColor

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for RGBAColor

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RGBAColor

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RGBAColor

Source§

impl TryFrom<&str> for RGBAColor

Source§

type Error = ColorCreationError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for RGBAColor

Source§

type Error = ColorCreationError

The type returned in the event of a conversion error.
Source§

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.