Struct AlphaLast

Source
#[repr(C)]
pub struct AlphaLast<A, C> { /* private fields */ }
Expand description

A contiguous color with alpha last, preceded by other color components.

§Layout

template<typename C, typename A>
struct AlphaLast {
  C color;
  A alpha;
}

Implementations§

Source§

impl<A, C> AlphaLast<A, C>

Source

pub const fn with_color(alpha: A, color: C) -> Self

Creates a new instance of AlphaFirst with the given color and alpha components.

Source

pub const fn alpha(&self) -> A
where A: Copy,

Returns the alpha component of this color.

Source

pub const fn color(&self) -> C
where C: Copy,

Returns the color component of this color.

Source

pub fn into_inner(self) -> (C, A)

Consumes and returns the color and alpha components of this color.

Source§

impl AlphaLast<u8, Gray<u8>>

Source

pub const fn new(gray: u8, alpha: u8) -> Self

Creates a new 8-bit grayscale color with alpha.

Source§

impl AlphaLast<u16, Gray<u16>>

Source

pub const fn new(gray: u16, alpha: u16) -> Self

Creates a new 16-bit grayscale color with alpha.

Source§

impl AlphaLast<f32, Gray<f32>>

Source

pub const fn new(gray: f32, alpha: f32) -> Self

Creates a new 32-bit floating-point grayscale color with alpha.

Source§

impl AlphaLast<f32, Rgb<f32>>

Source

pub const fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Self

Creates a new RGBA color from the individual components.

§Examples
use gem::{alpha::HasAlpha, rgb::{HasRed, HasGreen, HasBlue, Rgbaf32}};

let color = Rgbaf32::from_rgba(1.0, 0.0, 0.0, 1.0);
assert_eq!(color.red(), 1.0);
assert_eq!(color.green(), 0.0);
assert_eq!(color.blue(), 0.0);
assert_eq!(color.alpha(), 1.0);

Trait Implementations§

Source§

impl<A: Clone, C: Clone> Clone for AlphaLast<A, C>

Source§

fn clone(&self) -> AlphaLast<A, C>

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<A: Debug, C: Debug> Debug for AlphaLast<A, C>

Source§

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

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

impl<A: Default, C: Default> Default for AlphaLast<A, C>

Source§

fn default() -> AlphaLast<A, C>

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

impl<A, C> HasAlpha for AlphaLast<A, C>
where A: Copy,

Source§

type Component = A

The type of the alpha component.
Source§

fn alpha(&self) -> Self::Component

Returns the value of the alpha component.
Source§

fn set_alpha(&mut self, value: Self::Component)

Sets the alpha component to the given value. Read more
Source§

fn new_alpha(value: Self::Component) -> Self
where Self: Sized + Default,

Creates a new color with the given alpha component. Read more
Source§

fn with_alpha(self, value: Self::Component) -> Self
where Self: Sized,

Converts the color into a new type with the alpha component set to the given value. Read more
Source§

impl<A, C> HasBlue for AlphaLast<A, C>
where A: Copy, C: Copy + HasBlue,

Source§

type Component = <C as HasBlue>::Component

The type of the blue component.
Source§

fn blue(&self) -> Self::Component

Returns the value of the blue component.
Source§

fn set_blue(&mut self, value: Self::Component)

Sets the blue component to the given value. Read more
Source§

fn with_blue(self, value: Self::Component) -> Self
where Self: Copy + Clone,

Converts the color into a new type with the blue component set to the given value. Read more
Source§

impl<A, C> HasGreen for AlphaLast<A, C>
where A: Copy, C: Copy + HasGreen,

Source§

type Component = <C as HasGreen>::Component

The type of the green component.
Source§

fn green(&self) -> Self::Component

Returns the value of the green component.
Source§

fn set_green(&mut self, value: Self::Component)

Sets the green component to the given value. Read more
Source§

fn with_green(self, value: Self::Component) -> Self
where Self: Copy + Clone,

Converts the color into a new type with the green component set to the given value. Read more
Source§

impl<A, C> HasRed for AlphaLast<A, C>
where A: Copy, C: Copy + HasRed,

Source§

type Component = <C as HasRed>::Component

The type of the red component.
Source§

fn red(&self) -> Self::Component

Returns the value of the red component.
Source§

fn set_red(&mut self, value: Self::Component)

Sets the red component to the given value. Read more
Source§

fn with_red(self, value: Self::Component) -> Self
where Self: Copy + Clone,

Converts the color into a new type with the red component set to the given value. Read more
Source§

impl<A: Ord, C: Ord> Ord for AlphaLast<A, C>

Source§

fn cmp(&self, other: &AlphaLast<A, C>) -> 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<A: PartialEq, C: PartialEq> PartialEq for AlphaLast<A, C>

Source§

fn eq(&self, other: &AlphaLast<A, C>) -> 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<A: PartialOrd, C: PartialOrd> PartialOrd for AlphaLast<A, C>

Source§

fn partial_cmp(&self, other: &AlphaLast<A, C>) -> 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<A, C> Zeroable for AlphaLast<A, C>
where A: Zeroable, C: Zeroable,

§

fn zeroed() -> Self

Source§

impl<A: Copy, C: Copy> Copy for AlphaLast<A, C>

Source§

impl<A: Eq, C: Eq> Eq for AlphaLast<A, C>

Source§

impl<A, C> Pod for AlphaLast<A, C>
where A: Pod, C: Pod,

Source§

impl<A, C> StructuralPartialEq for AlphaLast<A, C>

Auto Trait Implementations§

§

impl<A, C> Freeze for AlphaLast<A, C>
where C: Freeze, A: Freeze,

§

impl<A, C> RefUnwindSafe for AlphaLast<A, C>

§

impl<A, C> Send for AlphaLast<A, C>
where C: Send, A: Send,

§

impl<A, C> Sync for AlphaLast<A, C>
where C: Sync, A: Sync,

§

impl<A, C> Unpin for AlphaLast<A, C>
where C: Unpin, A: Unpin,

§

impl<A, C> UnwindSafe for AlphaLast<A, C>
where C: 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
§

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

§

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.
§

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<T> RgbColor for T
where T: HasRed + HasGreen + HasBlue + Default,

Source§

fn from_rgb( red: <Self as HasRed>::Component, green: <Self as HasGreen>::Component, blue: <Self as HasBlue>::Component, ) -> Self

Creates a new color with the given red, green, and blue components. Read more
Source§

fn into_rgb( self, ) -> (<Self as HasRed>::Component, <Self as HasGreen>::Component, <Self as HasBlue>::Component)

Returns the inner representation of the color as a tuple of red, green, and blue components.
Source§

impl<T> RgbaColor for T

Source§

fn from_rgba( red: <Self as HasRed>::Component, green: <Self as HasGreen>::Component, blue: <Self as HasBlue>::Component, alpha: <Self as HasAlpha>::Component, ) -> Self

Creates a new color with the given red, green, blue, and alpha components. Read more
Source§

fn into_rgba( self, ) -> (<Self as HasRed>::Component, <Self as HasGreen>::Component, <Self as HasBlue>::Component, <Self as HasAlpha>::Component)

Returns the inner representation of the color as a tuple of red, green, blue, and alpha components.
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.
§

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

§

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