#[repr(C)]pub struct Rgba<T, A = T> {
pub r: T,
pub g: T,
pub b: T,
pub a: A,
}
Expand description
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§
source§impl<T: Copy, A: Clone> Rgba<T, A>
impl<T: Copy, A: Clone> Rgba<T, A>
sourcepub fn map_rgb<F, U, B>(&self, f: F) -> RGBA<U, B>
👎Deprecated: Renamed to map_colors()
pub fn map_rgb<F, U, B>(&self, f: F) -> RGBA<U, B>
Create new RGBA with the same alpha value, but different RGB values
sourcepub fn with_alpha(&self, a: A) -> Self
pub fn with_alpha(&self, a: A) -> Self
Create a new RGBA with the new alpha value, but same RGB values
Trait Implementations§
source§impl<T> AddAssign<T> for Rgba<T>
impl<T> AddAssign<T> for Rgba<T>
px + 1
source§fn add_assign(&mut self, r: T)
fn add_assign(&mut self, r: T)
Performs the
+=
operation. Read moresource§impl<T, A> AddAssign for Rgba<T, A>
impl<T, A> AddAssign for Rgba<T, A>
px + px
source§fn add_assign(&mut self, other: RGBA<T, A>)
fn add_assign(&mut self, other: RGBA<T, A>)
Performs the
+=
operation. Read moresource§impl<T> AsPixels<Rgba<T>> for [T]
impl<T> AsPixels<Rgba<T>> for [T]
source§fn as_pixels_mut(&mut self) -> &mut [RGBA<T>]
fn as_pixels_mut(&mut self) -> &mut [RGBA<T>]
Use
::bytemuck::cast_slice_mut()
instead. Read moresource§impl<T: Copy, A: Copy, B> ColorComponentMap<Rgba<B, A>, T, B> for Rgba<T, A>
impl<T: Copy, A: Copy, B> ColorComponentMap<Rgba<B, A>, T, B> for Rgba<T, A>
source§impl<T> ComponentSlice<T> for Rgba<T>
impl<T> ComponentSlice<T> for Rgba<T>
source§impl<T> DivAssign<T> for Rgba<T>
impl<T> DivAssign<T> for Rgba<T>
px * 1
source§fn div_assign(&mut self, r: T)
fn div_assign(&mut self, r: T)
Performs the
/=
operation. Read moresource§impl<R, S> From<(R, R, R, R)> for Rgba<S>where
R: Into<S>,
impl<R, S> From<(R, R, R, R)> for Rgba<S>where
R: Into<S>,
source§fn from(value: (R, R, R, R)) -> Self
fn from(value: (R, R, R, R)) -> Self
Converts to this type from the input type.
source§impl<T> FromIterator<T> for Rgba<T>
impl<T> FromIterator<T> for Rgba<T>
source§fn 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.
source§impl<T> MulAssign<T> for Rgba<T>
impl<T> MulAssign<T> for Rgba<T>
px * 1
source§fn mul_assign(&mut self, r: T)
fn mul_assign(&mut self, r: T)
Performs the
*=
operation. Read moresource§impl<T: Ord, A: Ord> Ord for Rgba<T, A>
impl<T: Ord, A: Ord> Ord for Rgba<T, A>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<T: PartialOrd, A: PartialOrd> PartialOrd for Rgba<T, A>
impl<T: PartialOrd, A: PartialOrd> PartialOrd for Rgba<T, A>
source§impl<T> SubAssign<T> for Rgba<T>
impl<T> SubAssign<T> for Rgba<T>
px - 1
source§fn sub_assign(&mut self, r: T)
fn sub_assign(&mut self, r: T)
Performs the
-=
operation. Read moresource§impl<T, A> SubAssign for Rgba<T, A>
impl<T, A> SubAssign for Rgba<T, A>
px - px
source§fn sub_assign(&mut self, other: RGBA<T, A>)
fn sub_assign(&mut self, other: RGBA<T, A>)
Performs the
-=
operation. Read moresource§impl<T, A> Zeroable for Rgba<T, A>
impl<T, A> Zeroable for Rgba<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.
impl<T: Copy, A: Copy> Copy for Rgba<T, A>
impl<T: Eq, A: Eq> Eq for Rgba<T, A>
impl<T, A> Pod for Rgba<T, A>
This is unsound. You can disable as-bytes
feature, enable bytemuck
, and use bytemuck::cast_slice()
instead.
impl<T, A> StructuralPartialEq for Rgba<T, A>
Auto Trait Implementations§
impl<T, A> Freeze for Rgba<T, A>
impl<T, A> RefUnwindSafe for Rgba<T, A>where
T: RefUnwindSafe,
A: RefUnwindSafe,
impl<T, A> Send for Rgba<T, A>
impl<T, A> Sync for Rgba<T, A>
impl<T, A> Unpin for Rgba<T, A>
impl<T, A> UnwindSafe for Rgba<T, A>where
T: UnwindSafe,
A: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
source§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)