[]Struct smart_leds::RGBA

#[repr(C)]
pub struct RGBA<ComponentType, AlphaComponentType = ComponentType> {
    pub r: ComponentType,
    pub g: ComponentType,
    pub b: ComponentType,
    pub a: AlphaComponentType,
}

The RGBA pixel

The component type can be u8 (aliased as RGBA8), u16 (aliased as RGBA16), or any other type (but simple copyable types are recommended.)

You can specify a different type for alpha, but it's only for special cases (e.g. if you use a newtype like RGBA<LinearLight<u16>, u16>).

Fields

r: ComponentType

Red

g: ComponentType

Green

b: ComponentType

Blue

a: AlphaComponentType

Alpha

Methods

impl<T> RGBA<T, T>

pub const fn new(r: T, g: T, b: T, a: T) -> RGBA<T, T>

Convenience function for creating a new pixel The order of arguments is R,G,B,A

impl<T, A> RGBA<T, A>

pub const fn new_alpha(r: T, g: T, b: T, a: A) -> RGBA<T, A>

Convenience function for creating a new pixel The order of arguments is R,G,B,A

impl<T> RGBA<T, T> where
    T: Clone

pub fn iter(&self) -> Cloned<Iter<T>>

Iterate over all components (length=4)

impl<T, A> RGBA<T, A> where
    T: Clone

pub fn rgb(&self) -> RGB<T>

Copy RGB components out of the RGBA struct

Note: you can use .into() to convert between other types

impl<T, A> RGBA<T, A>

pub fn rgb_mut(&mut self) -> &mut RGB<T>

Provide a mutable view of only RGB components (leaving out alpha). Useful to change color without changing opacity.

impl<T, A> RGBA<T, A> where
    A: Clone,
    T: Copy

pub fn map_rgb<F, U, B>(&self, f: F) -> RGBA<U, B> where
    B: From<A> + Clone,
    F: FnMut(T) -> U,
    U: Clone

Create new RGBA with the same alpha value, but different RGB values

Trait Implementations

impl<T, B> ComponentMap<RGBA<B, B>, T, B> for RGBA<T, T> where
    T: Copy

impl<ComponentType, AlphaComponentType> PartialEq<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: PartialEq<AlphaComponentType>,
    ComponentType: PartialEq<ComponentType>, 

impl<ComponentType, AlphaComponentType> Debug for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Debug,
    ComponentType: Debug

impl<T> AsMut<[T]> for RGBA<T, T>

impl From<RGBA<u8, u8>> for RGBA<f32, f32>

impl<T, A> From<GrayAlpha<T, A>> for RGBA<T, A> where
    T: Clone

impl From<RGBA<u16, u16>> for RGBA<i32, i32>

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

impl From<RGBA<i16, i16>> for RGBA<f64, f64>

impl From<RGBA<f32, f32>> for RGBA<f64, f64>

impl From<RGBA<u8, u8>> for RGBA<f64, f64>

impl<T, A> From<(T, T, T, A)> for RGBA<T, A>

impl From<RGBA<u16, u16>> for RGBA<f32, f32>

impl<T> From<RGB<T>> for RGBA<T, u8> where
    T: Copy

Assumes 255 is opaque

impl From<RGBA<i32, i32>> for RGBA<f64, f64>

impl From<RGBA<u16, u16>> for RGBA<f64, f64>

impl<T> From<RGB<T>> for RGBA<T, u16> where
    T: Copy

Assumes 65535 is opaque

impl<T> From<BGR<T>> for RGBA<T, u16> where
    T: Copy

Assumes 255 is opaque

impl<T> From<BGR<T>> for RGBA<T, u8> where
    T: Copy

Assumes 255 is opaque

impl<T> From<BGRA<T, T>> for RGBA<T, T>

impl From<RGBA<i16, i16>> for RGBA<f32, f32>

impl<T, A> Add<RGBA<T, A>> for RGBA<T, A> where
    A: Add<A>,
    T: Add<T>, 

px + px

type Output = RGBA<<T as Add<T>>::Output, <A as Add<A>>::Output>

The resulting type after applying the + operator.

impl<T> Add<T> for RGBA<T, T> where
    T: Copy + Add<T, Output = T> + Clone + Add<T>, 

px + 1

type Output = RGBA<T, T>

The resulting type after applying the + operator.

impl<ComponentType, AlphaComponentType> Clone for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Clone,
    ComponentType: Clone

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<ComponentType, AlphaComponentType> PartialOrd<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: PartialOrd<AlphaComponentType>,
    ComponentType: PartialOrd<ComponentType>, 

impl<ComponentType, AlphaComponentType> Eq for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Eq,
    ComponentType: Eq

impl<T, A> Display for RGBA<T, A> where
    A: Display,
    T: Display

impl<T> Into<[T; 4]> for RGBA<T, T>

impl<T, A> Into<(T, T, T, A)> for RGBA<T, A>

impl<T, A> Sub<RGBA<T, A>> for RGBA<T, A> where
    A: Sub<A>,
    T: Sub<T>, 

px - px

type Output = RGBA<<T as Sub<T>>::Output, <A as Sub<A>>::Output>

The resulting type after applying the - operator.

impl<T> AsRef<[T]> for RGBA<T, T>

impl<ComponentType, AlphaComponentType> Hash for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Hash,
    ComponentType: Hash

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

Feeds a slice of this type into the given [Hasher]. Read more

impl<T> ComponentSlice<T> for RGBA<T, T>

impl<ComponentType, AlphaComponentType> Ord for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Ord,
    ComponentType: Ord

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl<T> FromIterator<T> for RGBA<T, T>

fn from_iter<I>(into_iter: I) -> RGBA<T, T> where
    I: IntoIterator<Item = T>, 

Takes exactly 4 elements from the iterator and creates a new instance. Panics if there are fewer elements in the iterator.

impl<T> Mul<T> for RGBA<T, T> where
    T: Copy + Mul<T, Output = T> + Clone + Mul<T>, 

px * 1

type Output = RGBA<T, T>

The resulting type after applying the * operator.

impl<ComponentType, AlphaComponentType> Copy for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Copy,
    ComponentType: Copy

impl<ComponentType, AlphaComponentType> Default for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Default,
    ComponentType: Default

Auto Trait Implementations

impl<ComponentType, AlphaComponentType> Unpin for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Unpin,
    ComponentType: Unpin

impl<ComponentType, AlphaComponentType> Send for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Send,
    ComponentType: Send

impl<ComponentType, AlphaComponentType> Sync for RGBA<ComponentType, AlphaComponentType> where
    AlphaComponentType: Sync,
    ComponentType: Sync

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]