Struct Rgba

struct Rgba<T, A = T> { ... }

A Red + Green + Blue + Alpha pixel.

Examples

use rgb::Rgba;

let pixel: Rgba<u8> = Rgba { r: 0, g: 0, b: 0, a: 255 };

Fields

r: T

Red Component

g: T

Green Component

b: T

Blue Component

a: A

Alpha Component

Implementations

impl<T, A> Rgba<T, A>

fn rgb_mut(self: &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>

const fn new_alpha(r: T, g: T, b: T, a: A) -> Self

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

impl<T: Clone> Rgba<T>

fn iter(self: &Self) -> Cloned<Iter<'_, T>>

Iterate over all components (length=4)

impl<T: Clone, A> Rgba<T, A>

fn bgr(self: &Self) -> BGR<T>

Copy RGB components out of the RGBA struct

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

impl<T: Clone, A> Rgba<T, A>

fn rgb(self: &Self) -> RGB<T>

Copy RGB components out of the RGBA struct

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

impl<T: Copy> Rgba<T>

const fn new(red: T, green: T, blue: T, alpha: T) -> Self

Creates a new Rgba pixel type from its components.

Alternatively, you can use struct literal syntax to create the new pixel type:

use rgb::Rgba;

let pixel = Rgba {r : red, g : green, b : blue, a : alpha};

impl<T: Copy, A: Clone> Rgba<T, A>

fn map_rgb<F, U, B>(self: &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

fn with_alpha(self: &Self, a: A) -> Self

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

fn map_alpha<F, B>(self: &Self, f: F) -> RGBA<T, B>
where
    F: FnOnce(A) -> B

Create a new RGBA with a new alpha value created by the callback. Allows changing of the type used for the alpha channel.

impl From for Rgba<f32>

fn from(other: RGBA<i16>) -> Self

impl From for Rgba<f32>

fn from(other: RGBA<u16>) -> Self

impl From for Rgba<f32>

fn from(other: RGBA<u8>) -> Self

impl From for Rgba<f64>

fn from(other: RGBA<f32>) -> Self

impl From for Rgba<f64>

fn from(other: RGBA<i16>) -> Self

impl From for Rgba<f64>

fn from(other: RGBA<u16>) -> Self

impl From for Rgba<f64>

fn from(other: RGBA<u8>) -> Self

impl From for Rgba<f64>

fn from(other: RGBA<i32>) -> Self

impl From for Rgba<i16>

fn from(other: RGBA<u8>) -> Self

impl From for Rgba<i32>

fn from(other: RGBA<u16>) -> Self

impl From for Rgba<u16>

fn from(other: RGBA<u8>) -> Self

impl From for Rgba<u32>

fn from(other: RGBA<u8>) -> Self

impl From for Rgba<u32>

fn from(other: RGBA<u16>) -> Self

impl From for Rgba<u64>

fn from(other: RGBA<u16>) -> Self

impl<R, S> From for Rgba<S>

fn from(value: (R, R, R, R)) -> Self

impl<T> Add for Rgba<T>

fn add(self: Self, r: T) -> <Self as >::Output

impl<T> AddAssign for Rgba<T>

fn add_assign(self: &mut Self, r: T)

impl<T> Any for Rgba<T, A>

fn type_id(self: &Self) -> TypeId

impl<T> AsMut for Rgba<T>

fn as_mut(self: &mut Self) -> &mut [T]

impl<T> AsRef for Rgba<T>

fn as_ref(self: &Self) -> &[T]

impl<T> Borrow for Rgba<T, A>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Rgba<T, A>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Rgba<T, A>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> ComponentSlice for Rgba<T>

fn as_slice(self: &Self) -> &[T]
fn as_mut_slice(self: &mut Self) -> &mut [T]

impl<T> Div for Rgba<T>

fn div(self: Self, r: T) -> <Self as >::Output

impl<T> DivAssign for Rgba<T>

fn div_assign(self: &mut Self, r: T)

impl<T> From for Rgba<T>

fn from(other: ABGR<T>) -> Self

impl<T> From for Rgba<T>

fn from(other: BGRA<T>) -> Self

impl<T> From for Rgba<T>

fn from(other: ARGB<T>) -> Self

impl<T> From for Rgba<T, A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FromIterator for Rgba<T>

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> Mul for Rgba<T>

fn mul(self: Self, r: T) -> <Self as >::Output

impl<T> MulAssign for Rgba<T>

fn mul_assign(self: &mut Self, r: T)

impl<T> Sub for Rgba<T>

fn sub(self: Self, r: T) -> <Self as >::Output

impl<T> SubAssign for Rgba<T>

fn sub_assign(self: &mut Self, r: T)

impl<T, A> AddAssign for Rgba<T, A>

fn add_assign(self: &mut Self, other: RGBA<T, A>)

impl<T, A> Freeze for Rgba<T, A>

impl<T, A> RefUnwindSafe for Rgba<T, A>

impl<T, A> Send for Rgba<T, A>

impl<T, A> StructuralPartialEq for Rgba<T, A>

impl<T, A> SubAssign for Rgba<T, A>

fn sub_assign(self: &mut Self, other: RGBA<T, A>)

impl<T, A> Sum for Rgba<T, A>

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

impl<T, A> Sync for Rgba<T, A>

impl<T, A> Unpin for Rgba<T, A>

impl<T, A> UnsafeUnpin for Rgba<T, A>

impl<T, A> UnwindSafe for Rgba<T, A>

impl<T, U> Into for Rgba<T, A>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Rgba<T, A>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Rgba<T, A>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>

impl<T: $crate::clone::Clone, A: $crate::clone::Clone> Clone for Rgba<T, A>

fn clone(self: &Self) -> Rgba<T, A>

impl<T: $crate::cmp::Eq, A: $crate::cmp::Eq> Eq for Rgba<T, A>

impl<T: $crate::cmp::Ord, A: $crate::cmp::Ord> Ord for Rgba<T, A>

fn cmp(self: &Self, other: &Rgba<T, A>) -> Ordering

impl<T: $crate::cmp::PartialEq, A: $crate::cmp::PartialEq> PartialEq for Rgba<T, A>

fn eq(self: &Self, other: &Rgba<T, A>) -> bool

impl<T: $crate::cmp::PartialOrd, A: $crate::cmp::PartialOrd> PartialOrd for Rgba<T, A>

fn partial_cmp(self: &Self, other: &Rgba<T, A>) -> Option<Ordering>

impl<T: $crate::default::Default, A: $crate::default::Default> Default for Rgba<T, A>

fn default() -> Rgba<T, A>

impl<T: $crate::fmt::Debug, A: $crate::fmt::Debug> Debug for Rgba<T, A>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T: $crate::hash::Hash, A: $crate::hash::Hash> Hash for Rgba<T, A>

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl<T: $crate::marker::Copy, A: $crate::marker::Copy> Copy for Rgba<T, A>

impl<T: Add, A: Add> Add for Rgba<T, A>

fn add(self: Self, other: RGBA<T, A>) -> <Self as >::Output

impl<T: Clone> From for Rgba<T, u8>

fn from(other: Gray<T>) -> Self

impl<T: Clone, A> From for Rgba<T, A>

fn from(other: GrayAlpha<T, A>) -> Self

impl<T: Copy> From for Rgba<T>

fn from(other: [T; 4]) -> Self

impl<T: Copy> From for Rgba<T, u16>

fn from(other: RGB<T>) -> Self

impl<T: Copy> From for Rgba<T, u16>

fn from(other: BGR<T>) -> Self

impl<T: Copy> From for Rgba<T, u8>

fn from(other: BGR<T>) -> Self

impl<T: Copy> From for Rgba<T, u8>

fn from(other: RGB<T>) -> Self

impl<T: Copy, A: Copy, B> ColorComponentMap for Rgba<T, A>

fn map_colors<F>(self: &Self, f: F) -> RGBA<B, A>
where
    F: FnMut(T) -> B

impl<T: Copy, B> ComponentMap for Rgba<T>

fn map<F>(self: &Self, f: F) -> RGBA<B>
where
    F: FnMut(T) -> B

impl<T: Sub, A: Sub> Sub for Rgba<T, A>

fn sub(self: Self, other: RGBA<T, A>) -> <Self as >::Output

impl<T: fmt::Display, A: fmt::Display> Display for Rgba<T, A>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result