[−]Struct smart_leds::RGBA
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,
T: Clone,
impl<T, A> RGBA<T, A> where
T: Clone,
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,
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,
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,
T: Copy,
impl<ComponentType, AlphaComponentType> PartialEq<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: PartialEq<AlphaComponentType>,
ComponentType: PartialEq<ComponentType>,
AlphaComponentType: PartialEq<AlphaComponentType>,
ComponentType: PartialEq<ComponentType>,
fn eq(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
fn ne(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
impl<ComponentType, AlphaComponentType> Debug for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Debug,
ComponentType: Debug,
AlphaComponentType: Debug,
ComponentType: Debug,
impl<T> AsMut<[T]> for RGBA<T, T>
fn as_mut(&mut self) -> &mut [T]
impl From<RGBA<u8, u8>> for RGBA<f32, f32>
impl<T, A> From<GrayAlpha<T, A>> for RGBA<T, A> where
T: Clone,
T: Clone,
impl From<RGBA<u16, u16>> for RGBA<i32, i32>
impl<T> From<[T; 4]> for RGBA<T, T> where
T: Copy,
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,
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,
T: Copy,
Assumes 65535 is opaque
impl<T> From<BGR<T>> for RGBA<T, u16> where
T: Copy,
T: Copy,
Assumes 255 is opaque
impl<T> From<BGR<T>> for RGBA<T, u8> where
T: Copy,
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>,
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.
fn add(self, other: RGBA<T, A>) -> <RGBA<T, A> as Add<RGBA<T, A>>>::Output
impl<T> Add<T> for RGBA<T, T> where
T: Copy + Add<T, Output = T> + Clone + Add<T>,
T: Copy + Add<T, Output = T> + Clone + Add<T>,
px + 1
type Output = RGBA<T, T>
The resulting type after applying the +
operator.
fn add(self, r: T) -> <RGBA<T, T> as Add<T>>::Output
impl<ComponentType, AlphaComponentType> Clone for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Clone,
ComponentType: Clone,
AlphaComponentType: Clone,
ComponentType: Clone,
fn clone(&self) -> RGBA<ComponentType, AlphaComponentType>
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>,
AlphaComponentType: PartialOrd<AlphaComponentType>,
ComponentType: PartialOrd<ComponentType>,
fn partial_cmp(
&self,
other: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
&self,
other: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
fn lt(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
fn le(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
fn gt(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
fn ge(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
impl<ComponentType, AlphaComponentType> Eq for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Eq,
ComponentType: Eq,
AlphaComponentType: Eq,
ComponentType: Eq,
impl<T, A> Display for RGBA<T, A> where
A: Display,
T: Display,
A: Display,
T: Display,
impl<T> Into<[T; 4]> for RGBA<T, T>
fn into(self) -> [T; 4]
impl<T, A> Into<(T, T, T, A)> for RGBA<T, A>
fn into(self) -> (T, T, T, A)
impl<T, A> Sub<RGBA<T, A>> for RGBA<T, A> where
A: Sub<A>,
T: Sub<T>,
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.
fn sub(self, other: RGBA<T, A>) -> <RGBA<T, A> as Sub<RGBA<T, A>>>::Output
impl<T> AsRef<[T]> for RGBA<T, T>
fn as_ref(&self) -> &[T]
impl<ComponentType, AlphaComponentType> Hash for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Hash,
ComponentType: Hash,
AlphaComponentType: Hash,
ComponentType: Hash,
fn hash<__HComponentTypeAlphaComponentType>(
&self,
state: &mut __HComponentTypeAlphaComponentType
) where
__HComponentTypeAlphaComponentType: Hasher,
&self,
state: &mut __HComponentTypeAlphaComponentType
) where
__HComponentTypeAlphaComponentType: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T> ComponentSlice<T> for RGBA<T, T>
fn as_slice(&self) -> &[T]
fn as_mut_slice(&mut self) -> &mut [T]
impl<ComponentType, AlphaComponentType> Ord for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Ord,
ComponentType: Ord,
AlphaComponentType: Ord,
ComponentType: Ord,
fn cmp(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> Ordering
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
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>,
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>,
T: Copy + Mul<T, Output = T> + Clone + Mul<T>,
px * 1
type Output = RGBA<T, T>
The resulting type after applying the *
operator.
fn mul(self, r: T) -> <RGBA<T, T> as Mul<T>>::Output
impl<ComponentType, AlphaComponentType> Copy for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Copy,
ComponentType: Copy,
AlphaComponentType: Copy,
ComponentType: Copy,
impl<ComponentType, AlphaComponentType> Default for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Default,
ComponentType: Default,
AlphaComponentType: Default,
ComponentType: Default,
Auto Trait Implementations
impl<ComponentType, AlphaComponentType> Unpin for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Unpin,
ComponentType: Unpin,
AlphaComponentType: Unpin,
ComponentType: Unpin,
impl<ComponentType, AlphaComponentType> Send for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Send,
ComponentType: Send,
AlphaComponentType: Send,
ComponentType: Send,
impl<ComponentType, AlphaComponentType> Sync for RGBA<ComponentType, AlphaComponentType> where
AlphaComponentType: Sync,
ComponentType: Sync,
AlphaComponentType: Sync,
ComponentType: Sync,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,