#[repr(C)]pub struct RGBA<ComponentType, AlphaComponentType = ComponentType> {
pub r: ComponentType,
pub g: ComponentType,
pub b: ComponentType,
pub a: AlphaComponentType,
}
Expand description
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
Implementations
sourceimpl<T: Copy, A: Clone> RGBA<T, A>
impl<T: Copy, A: Clone> RGBA<T, A>
Trait Implementations
sourceimpl<T, A> AddAssign<RGBA<T, A>> for RGBA<T, A>where
T: Add<Output = T> + Copy,
A: Add<Output = A> + Copy,
impl<T, A> AddAssign<RGBA<T, A>> for RGBA<T, A>where
T: Add<Output = T> + Copy,
A: Add<Output = A> + Copy,
px + px
sourcefn add_assign(&mut self, other: RGBA<T, A>)
fn add_assign(&mut self, other: RGBA<T, A>)
Performs the
+=
operation. Read moresourceimpl<T> AddAssign<T> for RGBA<T>where
T: Copy + Add<Output = T>,
impl<T> AddAssign<T> for RGBA<T>where
T: Copy + Add<Output = T>,
px + 1
sourcefn add_assign(&mut self, r: T)
fn add_assign(&mut self, r: T)
Performs the
+=
operation. Read moresourceimpl<T> AsPixels<RGBA<T, T>> for [T]
impl<T> AsPixels<RGBA<T, T>> for [T]
sourcefn as_pixels(&self) -> &[RGBA<T>]
fn as_pixels(&self) -> &[RGBA<T>]
Reinterpret the slice as a read-only/shared slice of pixels.
Multiple consecutive elements in the slice are intepreted as a single pixel
(depending on format, e.g. 3 for RGB, 4 for RGBA). Read more
sourcefn as_pixels_mut(&mut self) -> &mut [RGBA<T>]
fn as_pixels_mut(&mut self) -> &mut [RGBA<T>]
Reinterpret the slice as a mutable/exclusive slice of pixels.
Multiple consecutive elements in the slice are intepreted as a single pixel
(depending on format, e.g. 3 for RGB, 4 for RGBA). Read more
sourceimpl<ComponentType: Clone, AlphaComponentType: Clone> Clone for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Clone, AlphaComponentType: Clone> Clone for RGBA<ComponentType, AlphaComponentType>
sourceimpl<T: Copy, B> ComponentMap<RGBA<B, B>, T, B> for RGBA<T>
impl<T: Copy, B> ComponentMap<RGBA<B, B>, T, B> for RGBA<T>
sourceimpl<T> ComponentSlice<T> for RGBA<T>
impl<T> ComponentSlice<T> for RGBA<T>
sourceimpl<ComponentType: Debug, AlphaComponentType: Debug> Debug for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Debug, AlphaComponentType: Debug> Debug for RGBA<ComponentType, AlphaComponentType>
sourceimpl<ComponentType: Default, AlphaComponentType: Default> Default for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Default, AlphaComponentType: Default> Default for RGBA<ComponentType, AlphaComponentType>
sourceimpl<'de, ComponentType, AlphaComponentType> Deserialize<'de> for RGBA<ComponentType, AlphaComponentType>where
ComponentType: Deserialize<'de>,
AlphaComponentType: Deserialize<'de>,
impl<'de, ComponentType, AlphaComponentType> Deserialize<'de> for RGBA<ComponentType, AlphaComponentType>where
ComponentType: Deserialize<'de>,
AlphaComponentType: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T> DivAssign<T> for RGBA<T>where
T: Copy + Div<Output = T>,
impl<T> DivAssign<T> for RGBA<T>where
T: Copy + Div<Output = T>,
px * 1
sourcefn div_assign(&mut self, r: T)
fn div_assign(&mut self, r: T)
Performs the
/=
operation. Read moresourceimpl<T, A> From<(T, T, T, A)> for RGBA<T, A>
impl<T, A> From<(T, T, T, A)> for RGBA<T, A>
sourcefn from(other: (T, T, T, A)) -> Self
fn from(other: (T, T, T, A)) -> Self
Converts to this type from the input type.
sourceimpl<T> FromIterator<T> for RGBA<T>
impl<T> FromIterator<T> for RGBA<T>
sourcefn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Self
Takes exactly 4 elements from the iterator and creates a new instance. Panics if there are fewer elements in the iterator.
sourceimpl<ComponentType: Hash, AlphaComponentType: Hash> Hash for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Hash, AlphaComponentType: Hash> Hash for RGBA<ComponentType, AlphaComponentType>
sourceimpl<T, A> Into<(T, T, T, A)> for RGBA<T, A>
impl<T, A> Into<(T, T, T, A)> for RGBA<T, A>
sourcefn into(self) -> (T, T, T, A)
fn into(self) -> (T, T, T, A)
Converts this type into the (usually inferred) input type.
sourceimpl<T> MulAssign<T> for RGBA<T>where
T: Copy + Mul<Output = T>,
impl<T> MulAssign<T> for RGBA<T>where
T: Copy + Mul<Output = T>,
px * 1
sourcefn mul_assign(&mut self, r: T)
fn mul_assign(&mut self, r: T)
Performs the
*=
operation. Read moresourceimpl<ComponentType: Ord, AlphaComponentType: Ord> Ord for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Ord, AlphaComponentType: Ord> Ord for RGBA<ComponentType, AlphaComponentType>
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl<ComponentType: PartialEq, AlphaComponentType: PartialEq> PartialEq<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: PartialEq, AlphaComponentType: PartialEq> PartialEq<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType>
sourceimpl<ComponentType: PartialOrd, AlphaComponentType: PartialOrd> PartialOrd<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: PartialOrd, AlphaComponentType: PartialOrd> PartialOrd<RGBA<ComponentType, AlphaComponentType>> for RGBA<ComponentType, AlphaComponentType>
sourcefn partial_cmp(
&self,
other: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
fn partial_cmp(
&self,
other: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl<ComponentType, AlphaComponentType> Serialize for RGBA<ComponentType, AlphaComponentType>where
ComponentType: Serialize,
AlphaComponentType: Serialize,
impl<ComponentType, AlphaComponentType> Serialize for RGBA<ComponentType, AlphaComponentType>where
ComponentType: Serialize,
AlphaComponentType: Serialize,
sourceimpl<T, A> SubAssign<RGBA<T, A>> for RGBA<T, A>where
T: Sub<Output = T> + Copy,
A: Sub<Output = A> + Copy,
impl<T, A> SubAssign<RGBA<T, A>> for RGBA<T, A>where
T: Sub<Output = T> + Copy,
A: Sub<Output = A> + Copy,
px - px
sourcefn sub_assign(&mut self, other: RGBA<T, A>)
fn sub_assign(&mut self, other: RGBA<T, A>)
Performs the
-=
operation. Read moresourceimpl<T> SubAssign<T> for RGBA<T>where
T: Copy + Sub<Output = T>,
impl<T> SubAssign<T> for RGBA<T>where
T: Copy + Sub<Output = T>,
px - 1
sourcefn sub_assign(&mut self, r: T)
fn sub_assign(&mut self, r: T)
Performs the
-=
operation. Read moresourceimpl<T, A> Sum<RGBA<T, A>> for RGBA<T, A>where
T: Default + Add<Output = T>,
A: Default + Add<Output = A>,
impl<T, A> Sum<RGBA<T, A>> for RGBA<T, A>where
T: Default + Add<Output = T>,
A: Default + Add<Output = A>,
impl<ComponentType: Copy, AlphaComponentType: Copy> Copy for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Eq, AlphaComponentType: Eq> Eq for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType, AlphaComponentType> StructuralEq for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType, AlphaComponentType> StructuralPartialEq for RGBA<ComponentType, AlphaComponentType>
Auto Trait Implementations
impl<ComponentType, AlphaComponentType> RefUnwindSafe for RGBA<ComponentType, AlphaComponentType>where
AlphaComponentType: RefUnwindSafe,
ComponentType: RefUnwindSafe,
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,
impl<ComponentType, AlphaComponentType> Unpin for RGBA<ComponentType, AlphaComponentType>where
AlphaComponentType: Unpin,
ComponentType: Unpin,
impl<ComponentType, AlphaComponentType> UnwindSafe for RGBA<ComponentType, AlphaComponentType>where
AlphaComponentType: UnwindSafe,
ComponentType: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more