Struct rgb::Gray

source ·
#[repr(C)]
pub struct Gray<T>(pub T);
Available on non-crate feature unstable-experimental only.
Expand description

A Grayscale pixel (rgb crate v0.8)

Tuple Fields§

§0: T

Grayscale Component. This field will be renamed to v.

Implementations§

source§

impl<T: Copy> Gray_v08<T>

source

pub fn value(self) -> T

Reads the .0 field

This function isn’t necessary, but it is forwards-compatible with the next major version of the RGB crate.

source

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

Exposes the .0 field for writing

This function isn’t necessary, but it is forwards-compatible with the next major version of the RGB crate.

source

pub fn with_alpha(self, add_alpha_value: T) -> GrayAlpha_v08<T>

Add alpha component to this pixel

source§

impl<T: Copy> Gray_v08<T>

source

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

Creates a new Gray_v08 pixel type from its components.

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

use rgb::Gray_v08;

let pixel = Gray_v08 {0 : value};

Trait Implementations§

source§

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

px + 1

source§

type Output = Gray_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> Add for Gray_v08<T>

px + px

source§

type Output = Gray_v08<<T as Add>::Output>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T> AddAssign<T> for Gray_v08<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> AddAssign for Gray_v08<T>
where T: Add<Output = T> + Copy,

px + px

source§

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

Performs the += operation. Read more
source§

impl<T> AsMut<T> for Gray<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<Gray_v08<T>> for [T]

source§

impl<T> AsRef<T> for Gray<T>

source§

fn as_ref(&self) -> &T

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

impl<T: Clone> Clone for Gray_v08<T>

source§

fn clone(&self) -> Gray_v08<T>

Returns a copy 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, B> ColorComponentMap<Gray_v08<B>, T, B> for Gray<T>

source§

fn map_colors<F>(&self, f: F) -> Gray<B>
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<Gray_v08<B>, T, B> for Gray<T>

source§

fn map<F>(&self, f: F) -> Gray<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 Gray<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> Debug for Gray_v08<T>

source§

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

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

impl<T: Default> Default for Gray_v08<T>

source§

fn default() -> Gray_v08<T>

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

impl<T> Deref for Gray<T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<'de, T> Deserialize<'de> for Gray_v08<T>
where T: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

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

px / 1

source§

type Output = Gray_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 Gray_v08<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<Gray_v08<R>> for (S,)
where R: Into<S>,

source§

fn from(value: Gray_v08<R>) -> 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: Clone> From<Gray_v08<T>> for Rgb<T>

source§

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

Converts to this type from the input type.
source§

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

source§

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

Converts to this type from the input type.
source§

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

source§

fn from(component: T) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for Gray_v08<T>

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 Gray_v08<T>
where T: Copy + Mul<Output = T>,

px * 1

source§

type Output = Gray_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: Mul> Mul for Gray_v08<T>

px * px

source§

type Output = Gray_v08<<T as Mul>::Output>

The resulting type after applying the * operator.
source§

fn mul(self, other: Gray<T>) -> Self::Output

Performs the * operation. Read more
source§

impl<T> MulAssign<T> for Gray_v08<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> MulAssign for Gray_v08<T>
where T: Mul<Output = T> + Copy,

px * px

source§

fn mul_assign(&mut self, other: Gray<T>)

Performs the *= operation. Read more
source§

impl<T: Ord> Ord for Gray_v08<T>

source§

fn cmp(&self, other: &Gray_v08<T>) -> 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 + PartialOrd,

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

impl<T: PartialEq> PartialEq for Gray_v08<T>

source§

fn eq(&self, other: &Gray_v08<T>) -> 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> PartialOrd for Gray_v08<T>

source§

fn partial_cmp(&self, other: &Gray_v08<T>) -> 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> Serialize for Gray_v08<T>
where T: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

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

px - 1

source§

type Output = Gray_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> Sub for Gray_v08<T>

px - px

source§

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

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T> SubAssign<T> for Gray_v08<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> SubAssign for Gray_v08<T>
where T: Sub<Output = T> + Copy,

px - px

source§

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

Performs the -= operation. Read more
source§

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

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> Zeroable for Gray<T>
where T: Zeroable,

Available on crate feature as-bytes only.
source§

fn zeroed() -> Self

source§

impl<T: Copy> Copy for Gray_v08<T>

source§

impl<T: Eq> Eq for Gray_v08<T>

source§

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

Available on crate feature as-bytes only.
source§

impl<T> StructuralPartialEq for Gray_v08<T>

Auto Trait Implementations§

§

impl<T> Freeze for Gray_v08<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Gray_v08<T>
where T: RefUnwindSafe,

§

impl<T> Send for Gray_v08<T>
where T: Send,

§

impl<T> Sync for Gray_v08<T>
where T: Sync,

§

impl<T> Unpin for Gray_v08<T>
where T: Unpin,

§

impl<T> UnwindSafe for Gray_v08<T>
where T: 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, dst: *mut T)

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

impl<T> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

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