Struct rgb::RGBA
[−]
[src]
#[repr(C)]pub struct RGBA<ComponentType, AlphaComponentType = ComponentType> { pub r: ComponentType, pub g: ComponentType, pub b: ComponentType, pub a: AlphaComponentType, }
This is it. 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
Fields
r: ComponentType
Red
g: ComponentType
Green
b: ComponentType
Blue
a: AlphaComponentType
Alpha
Methods
impl<T: Clone> RGBA<T>[src]
fn new(r: T, g: T, b: T, a: T) -> Self
fn iter(&self) -> Cloned<Iter<T>>
Iterate over all components (length=4)
impl<T: Clone, A> RGBA<T, A>[src]
impl<T, A> RGBA<T, A>[src]
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]
fn map_rgb<F, U, B>(&self, f: F) -> RGBA<U, B> where
F: FnMut(T) -> U,
U: Clone,
B: From<A> + Clone,
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: Copy, B> ComponentMap<RGBA<B>, T, B> for RGBA<T>[src]
fn map<F>(&self, f: F) -> RGBA<B> where
F: FnMut(T) -> B,
F: FnMut(T) -> B,
Convenience function (equivalent of self.iter().map().collect()) for applying the same formula to every component. Read more
impl<T> ComponentBytes<T> for RGBA<T>[src]
fn as_slice(&self) -> &[T]
The components interpreted as an array, e.g. RGB gives 3-element slice. The red component is first.
fn as_mut_slice(&mut self) -> &mut [T]
fn as_bytes(&self) -> &[u8]
The components interpreted as raw bytes, in machine's native endian. Bytes of the red component are first.
impl<T> FromIterator<T> for RGBA<T>[src]
fn from_iter<I: IntoIterator<Item = T>>(into_iter: I) -> Self
Creates a value from an iterator. Read more
impl<T: Display, A: Display> Display for RGBA<T, A>[src]
impl<T: Add> Add<RGBA<T>> for RGBA<T>[src]
type Output = RGBA<<T as Add>::Output>
The resulting type after applying the + operator
fn add(self, other: RGBA<T>) -> Self::Output
The method for the + operator
impl<T: Sub> Sub<RGBA<T>> for RGBA<T>[src]
type Output = RGBA<<T as Sub>::Output>
The resulting type after applying the - operator
fn sub(self, other: RGBA<T>) -> Self::Output
The method for the - operator
impl<T: Clone + Copy + Add> Add<T> for RGBA<T> where
T: Add<Output = T>, [src]
T: Add<Output = T>,
type Output = RGBA<T>
The resulting type after applying the + operator
fn add(self, r: T) -> Self::Output
The method for the + operator
impl<T: Clone + Copy + Mul> Mul<T> for RGBA<T> where
T: Mul<Output = T>, [src]
T: Mul<Output = T>,
type Output = RGBA<T>
The resulting type after applying the * operator
fn mul(self, r: T) -> Self::Output
The method for the * operator
impl From<RGBA<u16>> for RGBA<i32>[src]
impl From<RGBA<u8>> for RGBA<f32>[src]
impl From<RGBA<u8>> for RGBA<f64>[src]
impl From<RGBA<u16>> for RGBA<f32>[src]
impl From<RGBA<u16>> for RGBA<f64>[src]
impl From<RGBA<i16>> for RGBA<f32>[src]
impl From<RGBA<i16>> for RGBA<f64>[src]
impl From<RGBA<i32>> for RGBA<f64>[src]
impl From<RGBA<f32>> for RGBA<f64>[src]
impl<ComponentType: Copy, AlphaComponentType: Copy> Copy for RGBA<ComponentType, AlphaComponentType>[src]
impl<ComponentType: Clone, AlphaComponentType: Clone> Clone for 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
Performs copy-assignment from source. Read more
impl<ComponentType: Debug, AlphaComponentType: Debug> Debug for RGBA<ComponentType, AlphaComponentType>[src]
impl<ComponentType: Default, AlphaComponentType: Default> Default for 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: PartialEq, AlphaComponentType: PartialEq> PartialEq for RGBA<ComponentType, AlphaComponentType>[src]
fn eq(&self, __arg_0: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests for !=.
impl<ComponentType: Ord, AlphaComponentType: Ord> Ord for RGBA<ComponentType, AlphaComponentType>[src]
fn cmp(&self, __arg_0: &RGBA<ComponentType, AlphaComponentType>) -> Ordering
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self
ord_max_min)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
ord_max_min)Compares and returns the minimum of two values. Read more
impl<ComponentType: PartialOrd, AlphaComponentType: PartialOrd> PartialOrd for RGBA<ComponentType, AlphaComponentType>[src]
fn partial_cmp(
&self,
__arg_0: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
&self,
__arg_0: &RGBA<ComponentType, AlphaComponentType>
) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, __arg_0: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, __arg_0: &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, __arg_0: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, __arg_0: &RGBA<ComponentType, AlphaComponentType>) -> bool
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more