Struct GrayAlpha

Source
#[repr(C)]
pub struct GrayAlpha<T, A = T>(pub T, pub A);
Expand description

A pixel for grayscale value + alpha components (rgb crate v0.8)

Through a Deref hack it renames the fields from .0 and .1 to .v (value) and .a (alpha)

Tuple Fields§

§0: T
👎Deprecated: Please use the .v field instaed (it’s available through the magic of Deref to GrayA type)

Grayscale Component

This field has been renamed to .v

§1: A
👎Deprecated: Please use the .a field instead (it’s available through the magic of Deref to GrayA type)

Alpha Component. This field has been renamed to .a.

Implementations§

Source§

impl<T: Copy> GrayAlpha_v08<T>

Source

pub fn value(self) -> T

Reads the .v field

Please use the .v field directly whenever possible. This function isn’t necessary, and exists only to ease migration between major versions of the RGB crate.

Source

pub fn value_mut(&mut self) -> &mut T

Exposes the .v field for writing

Please use the .v field directly whenever possible. This function isn’t necessary, and exists only to ease migration between major versions of the RGB crate.

Source§

impl<T: Copy> GrayAlpha_v08<T>

Source

pub const fn new(value: T, alpha: T) -> Self

Creates a new GrayAlpha_v08 pixel type from its components.

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

use rgb::GrayAlpha_v08;

let pixel = GrayAlpha_v08 {0 : value, 1 : alpha};
Source§

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

Source

pub fn gray(&self) -> Gray<T>

Copy Gray component out of the GrayAlpha struct

Source§

impl<T, A> GrayAlpha<T, A>

Source

pub fn gray_mut(&mut self) -> &mut Gray<T>

Provide a mutable view of only Gray component (leaving out alpha).

Source§

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

Source

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

Create a new GrayAlpha with the new alpha value, but same gray value

Source

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

Create a new GrayAlpha with a new alpha value created by the callback.

Source

pub fn map_gray<F, U, B>(&self, f: F) -> GrayAlpha<U, B>
where F: FnOnce(T) -> U, U: Clone, B: From<A> + Clone,

Create new GrayAlpha with the same alpha value, but different Gray value

Trait Implementations§

Source§

impl<T> Add<T> for GrayAlpha<T>
where T: Copy + Add<Output = T>,

px + 1

Source§

type Output = GrayAlpha_v08<T>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

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

px + px

Source§

type Output = GrayAlpha_v08<<T as Add>::Output, <A as Add>::Output>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<T> AddAssign<T> for GrayAlpha<T>
where T: Copy + Add<Output = T>,

px + 1

Source§

fn add_assign(&mut self, r: T)

Performs the += operation. Read more
Source§

impl<T, A> AddAssign for GrayAlpha<T, A>
where T: Add<Output = T> + Copy, A: Add<Output = A> + Copy,

px + px

Source§

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

Performs the += operation. Read more
Source§

impl<T> AsMut<T> for GrayAlpha<T>

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsPixels<GrayAlpha_v08<T>> for [T]

Source§

impl<T> AsRef<T> for GrayAlpha<T>

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone, A: Clone> Clone for GrayAlpha_v08<T, A>

Source§

fn clone(&self) -> GrayAlpha_v08<T, A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy, A: Copy, B> ColorComponentMap<GrayAlpha_v08<B, A>, T, B> for GrayAlpha<T, A>

Source§

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

Convenience function for applying the same formula to every rgb/gray component, but skipping the alpha component. Read more
Source§

fn map_c<Callback>(&self, f: Callback) -> DestPixel
where Callback: FnMut(SrcComponent) -> DestComponent,

👎Deprecated: renamed to map_colors
Alias of map_colors
Source§

impl<T: Copy, B> ComponentMap<GrayAlpha_v08<B>, T, B> for GrayAlpha<T>

Source§

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

Convenience function (equivalent of self.iter().map().collect()) for applying the same formula to every component. Read more
Source§

impl<T> ComponentSlice<T> for GrayAlpha<T>

Source§

fn as_slice(&self) -> &[T]

The components interpreted as an array, e.g. one RGB expands to 3 elements. Read more
Source§

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

The components interpreted as a mutable array, e.g. one RGB expands to 3 elements. Read more
Source§

impl<T: Debug, A: Debug> Debug for GrayAlpha_v08<T, A>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Default, A: Default> Default for GrayAlpha_v08<T, A>

Source§

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

Returns the “default value” for a type. Read more
Source§

impl<T, A> Deref for GrayAlpha_v08<T, A>

Source§

fn deref(&self) -> &GrayA<T, A>

A trick that allows using .v and .a on the old GrayAlpha type.

Source§

type Target = GrayA<T, A>

The resulting type after dereferencing.
Source§

impl<T, A> DerefMut for GrayAlpha_v08<T, A>

Source§

fn deref_mut(&mut self) -> &mut GrayA<T, A>

A trick that allows using .v and .a on the old GrayAlpha type.

Source§

impl<T> Div<T> for GrayAlpha<T>
where T: Copy + Div<Output = T>,

px / 1

Source§

type Output = GrayAlpha_v08<T>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for GrayAlpha<T>
where T: Copy + Div<Output = T>,

px * 1

Source§

fn div_assign(&mut self, r: T)

Performs the /= operation. Read more
Source§

impl<R, S> From<(R, R)> for GrayAlpha<S>
where R: Into<S>,

Source§

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

Converts to this type from the input type.
Source§

impl<R, S> From<GrayAlpha_v08<R>> for (S, S)
where R: Into<S>,

Source§

fn from(value: GrayAlpha<R>) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl<T: Copy> From<Gray_v08<T>> for GrayAlpha<T, u16>

Assumes 65535 is opaque

Source§

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

Converts to this type from the input type.
Source§

impl<T: Copy> From<Gray_v08<T>> for GrayAlpha<T, u8>

Assumes 255 is opaque

Source§

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

Converts to this type from the input type.
Source§

impl<T: Hash, A: Hash> Hash for GrayAlpha_v08<T, A>

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Mul<T> for GrayAlpha<T>
where T: Copy + Mul<Output = T>,

px * 1

Source§

type Output = GrayAlpha_v08<T>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for GrayAlpha<T>
where T: Copy + Mul<Output = T>,

px * 1

Source§

fn mul_assign(&mut self, r: T)

Performs the *= operation. Read more
Source§

impl<T: Ord, A: Ord> Ord for GrayAlpha_v08<T, A>

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq, A: PartialEq> PartialEq for GrayAlpha_v08<T, A>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd, A: PartialOrd> PartialOrd for GrayAlpha_v08<T, A>

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T> Sub<T> for GrayAlpha<T>
where T: Copy + Sub<Output = T>,

px - 1

Source§

type Output = GrayAlpha_v08<<T as Sub>::Output>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

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

px - px

Source§

type Output = GrayAlpha_v08<<T as Sub>::Output, <A as Sub>::Output>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl<T> SubAssign<T> for GrayAlpha<T>
where T: Copy + Sub<Output = T>,

px - 1

Source§

fn sub_assign(&mut self, r: T)

Performs the -= operation. Read more
Source§

impl<T, A> SubAssign for GrayAlpha<T, A>
where T: Sub<Output = T> + Copy, A: Sub<Output = A> + Copy,

px - px

Source§

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

Performs the -= operation. Read more
Source§

impl<T, A> Sum for GrayAlpha<T, A>
where T: Default + Add<Output = T>, A: Default + Add<Output = A>,

Source§

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

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T, A> Zeroable for GrayAlpha<T, A>
where T: Zeroable, A: Zeroable,

This is unsound. You can disable as-bytes feature, enable bytemuck, and use bytemuck::cast_slice() instead.

Source§

fn zeroed() -> Self

Source§

impl<T: Copy, A: Copy> Copy for GrayAlpha_v08<T, A>

Source§

impl<T: Eq, A: Eq> Eq for GrayAlpha_v08<T, A>

Source§

impl<T, A> Pod for GrayAlpha<T, A>
where T: Pod, A: Pod,

This is unsound. You can disable as-bytes feature, enable bytemuck, and use bytemuck::cast_slice() instead.

Source§

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

Auto Trait Implementations§

§

impl<T, A> Freeze for GrayAlpha_v08<T, A>
where T: Freeze, A: Freeze,

§

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

§

impl<T, A> Send for GrayAlpha_v08<T, A>
where T: Send, A: Send,

§

impl<T, A> Sync for GrayAlpha_v08<T, A>
where T: Sync, A: Sync,

§

impl<T, A> Unpin for GrayAlpha_v08<T, A>
where T: Unpin, A: Unpin,

§

impl<T, A> UnwindSafe for GrayAlpha_v08<T, A>
where T: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

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

If this function returns true, then it must be valid to reinterpret bits as &Self.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,