Struct rgb::RGBA [−][src]
#[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>
[src]
impl<T> RGBA<T>
impl<T, A> RGBA<T, A>
[src]
impl<T, A> RGBA<T, A>
impl<T: Clone> RGBA<T>
[src]
impl<T: Clone> RGBA<T>
impl<T: Clone, A> RGBA<T, A>
[src]
impl<T: Clone, A> RGBA<T, A>
impl<T, A> RGBA<T, A>
[src]
impl<T, A> RGBA<T, A>
pub fn rgb_mut(&mut self) -> &mut RGB<T>
[src]
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: Copy, A: Clone> RGBA<T, A>
[src]
impl<T: Copy, A: Clone> RGBA<T, A>
pub fn map_rgb<F, U, B>(&self, f: F) -> RGBA<U, B> where
F: FnMut(T) -> U,
U: Clone,
B: From<A> + Clone,
[src]
pub fn map_rgb<F, U, B>(&self, f: F) -> RGBA<U, B> where
F: FnMut(T) -> U,
U: Clone,
B: From<A> + Clone,
Create new RGBA with the same alpha value, but different RGB values
Trait Implementations
impl<T> FromIterator<T> for RGBA<T>
[src]
impl<T> FromIterator<T> for RGBA<T>
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Self
[src]
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.
impl<T: Copy, B> ComponentMap<RGBA<B>, T, B> for RGBA<T>
[src]
impl<T: Copy, B> ComponentMap<RGBA<B>, T, B> for RGBA<T>
fn map<F>(&self, f: F) -> RGBA<B> where
F: FnMut(T) -> B,
[src]
fn map<F>(&self, f: F) -> RGBA<B> where
F: FnMut(T) -> B,
Convenience function (equivalent of self.iter().map().collect()
) for applying the same formula to every component. Read more
impl<T> ComponentSlice<T> for RGBA<T>
[src]
impl<T> ComponentSlice<T> for RGBA<T>
fn as_slice(&self) -> &[T]
[src]
fn as_slice(&self) -> &[T]
The components interpreted as an array, e.g. one RGB
expands to 3 elements. Read more
fn as_mut_slice(&mut self) -> &mut [T]
[src]
fn as_mut_slice(&mut self) -> &mut [T]
impl<T: Copy> From<RGB<T>> for RGBA<T, u8>
[src]
impl<T: Copy> From<RGB<T>> for RGBA<T, u8>
Assumes 255 is opaque
impl<T: Copy> From<RGB<T>> for RGBA<T, u16>
[src]
impl<T: Copy> From<RGB<T>> for RGBA<T, u16>
Assumes 65535 is opaque
impl<T: Copy> From<BGR<T>> for RGBA<T, u8>
[src]
impl<T: Copy> From<BGR<T>> for RGBA<T, u8>
Assumes 255 is opaque
impl<T: Copy> From<BGR<T>> for RGBA<T, u16>
[src]
impl<T: Copy> From<BGR<T>> for RGBA<T, u16>
Assumes 255 is opaque
impl<T: Display, A: Display> Display for RGBA<T, A>
[src]
impl<T: Display, A: Display> Display for RGBA<T, A>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T: Add, A: Add> Add<RGBA<T, A>> for RGBA<T, A>
[src]
impl<T: Add, A: Add> Add<RGBA<T, A>> for RGBA<T, A>
px + px
type Output = RGBA<<T as Add>::Output, <A as Add>::Output>
The resulting type after applying the +
operator.
fn add(self, other: RGBA<T, A>) -> Self::Output
[src]
fn add(self, other: RGBA<T, A>) -> Self::Output
Performs the +
operation.
impl<T: Sub, A: Sub> Sub<RGBA<T, A>> for RGBA<T, A>
[src]
impl<T: Sub, A: Sub> Sub<RGBA<T, A>> for RGBA<T, A>
px - px
type Output = RGBA<<T as Sub>::Output, <A as Sub>::Output>
The resulting type after applying the -
operator.
fn sub(self, other: RGBA<T, A>) -> Self::Output
[src]
fn sub(self, other: RGBA<T, A>) -> Self::Output
Performs the -
operation.
impl<T: Clone + Copy + Add> Add<T> for RGBA<T> where
T: Add<Output = T>,
[src]
impl<T: Clone + Copy + Add> Add<T> for RGBA<T> where
T: Add<Output = T>,
px + 1
type Output = RGBA<T>
The resulting type after applying the +
operator.
fn add(self, r: T) -> Self::Output
[src]
fn add(self, r: T) -> Self::Output
Performs the +
operation.
impl<T: Clone + Copy + Mul> Mul<T> for RGBA<T> where
T: Mul<Output = T>,
[src]
impl<T: Clone + Copy + Mul> Mul<T> for RGBA<T> where
T: Mul<Output = T>,
px * 1
type Output = RGBA<T>
The resulting type after applying the *
operator.
fn mul(self, r: T) -> Self::Output
[src]
fn mul(self, r: T) -> Self::Output
Performs the *
operation.
impl<T, A> From<(T, T, T, A)> for RGBA<T, A>
[src]
impl<T, A> From<(T, T, T, A)> for RGBA<T, A>
impl<T, A> Into<(T, T, T, A)> for RGBA<T, A>
[src]
impl<T, A> Into<(T, T, T, A)> for RGBA<T, A>
impl From<RGBA<u16>> for RGBA<i32>
[src]
impl From<RGBA<u16>> for RGBA<i32>
impl From<RGBA<u8>> for RGBA<f32>
[src]
impl From<RGBA<u8>> for RGBA<f32>
impl From<RGBA<u8>> for RGBA<f64>
[src]
impl From<RGBA<u8>> for RGBA<f64>
impl From<RGBA<u16>> for RGBA<f32>
[src]
impl From<RGBA<u16>> for RGBA<f32>
impl From<RGBA<u16>> for RGBA<f64>
[src]
impl From<RGBA<u16>> for RGBA<f64>
impl From<RGBA<i16>> for RGBA<f32>
[src]
impl From<RGBA<i16>> for RGBA<f32>
impl From<RGBA<i16>> for RGBA<f64>
[src]
impl From<RGBA<i16>> for RGBA<f64>
impl From<RGBA<i32>> for RGBA<f64>
[src]
impl From<RGBA<i32>> for RGBA<f64>
impl From<RGBA<f32>> for RGBA<f64>
[src]
impl From<RGBA<f32>> for RGBA<f64>
impl<T: Clone, A> From<GrayAlpha<T, A>> for RGBA<T, A>
[src]
impl<T: Clone, A> From<GrayAlpha<T, A>> for RGBA<T, A>
impl<T> From<RGBA<T>> for BGRA<T>
[src]
impl<T> From<RGBA<T>> for BGRA<T>
impl<T> From<BGRA<T>> for RGBA<T>
[src]
impl<T> From<BGRA<T>> for RGBA<T>
impl<T> AsRef<[T]> for RGBA<T>
[src]
impl<T> AsRef<[T]> for RGBA<T>
impl<T> AsMut<[T]> for RGBA<T>
[src]
impl<T> AsMut<[T]> for RGBA<T>
impl<ComponentType: Copy, AlphaComponentType: Copy> Copy for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Copy, AlphaComponentType: Copy> Copy for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: Clone, AlphaComponentType: Clone> Clone for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Clone, AlphaComponentType: Clone> Clone for RGBA<ComponentType, AlphaComponentType>
fn clone(&self) -> RGBA<ComponentType, AlphaComponentType>
[src]
fn clone(&self) -> RGBA<ComponentType, AlphaComponentType>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<ComponentType: Debug, AlphaComponentType: Debug> Debug for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Debug, AlphaComponentType: Debug> Debug for RGBA<ComponentType, AlphaComponentType>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<ComponentType: Default, AlphaComponentType: Default> Default for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Default, AlphaComponentType: Default> Default for RGBA<ComponentType, AlphaComponentType>
fn default() -> RGBA<ComponentType, AlphaComponentType>
[src]
fn default() -> RGBA<ComponentType, AlphaComponentType>
Returns the "default value" for a type. Read more
impl<ComponentType: Eq, AlphaComponentType: Eq> Eq for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Eq, AlphaComponentType: Eq> Eq for RGBA<ComponentType, AlphaComponentType>
impl<ComponentType: PartialEq, AlphaComponentType: PartialEq> PartialEq for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: PartialEq, AlphaComponentType: PartialEq> PartialEq for RGBA<ComponentType, AlphaComponentType>
fn eq(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
[src]
fn eq(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
[src]
fn ne(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests for !=
.
impl<ComponentType: Ord, AlphaComponentType: Ord> Ord for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Ord, AlphaComponentType: Ord> Ord for RGBA<ComponentType, AlphaComponentType>
fn cmp(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> Ordering
[src]
fn cmp(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<ComponentType: PartialOrd, AlphaComponentType: PartialOrd> PartialOrd for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: PartialOrd, AlphaComponentType: PartialOrd> PartialOrd for RGBA<ComponentType, AlphaComponentType>
fn partial_cmp(
&self,
other: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
[src]
fn partial_cmp(
&self,
other: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
[src]
fn lt(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
[src]
fn le(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
[src]
fn gt(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
[src]
fn ge(&self, other: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<ComponentType: Hash, AlphaComponentType: Hash> Hash for RGBA<ComponentType, AlphaComponentType>
[src]
impl<ComponentType: Hash, AlphaComponentType: Hash> Hash for RGBA<ComponentType, AlphaComponentType>