Skip to main content

GreyAlpha

Struct GreyAlpha 

Source
pub struct GreyAlpha<T: Float + Send + Sync> { /* private fields */ }
Expand description

Grey with alpha channel.

Implementations§

Source§

impl<T: Float + Send + Sync> GreyAlpha<T>

Source

pub fn new(grey: T, alpha: T) -> Result<Self, ChromaticError>

Create a new GreyAlpha instance.

§Arguments
  • grey - The grey component, must be in range [0, 1]
  • alpha - The alpha (transparency) component, must be in range [0, 1]
§Errors

Returns an error if any component is outside the range [0, 1].

Source

pub const fn grey(&self) -> T

Get the grey component.

Source

pub const fn alpha(&self) -> T

Get the alpha component.

Source

pub fn set_grey(&mut self, grey: T) -> Result<(), ChromaticError>

Set the grey component.

§Arguments
  • grey - The new grey value, must be in range [0, 1]
§Errors

Returns an error if the value is outside the range [0, 1].

Source

pub fn set_alpha(&mut self, alpha: T) -> Result<(), ChromaticError>

Set the alpha component.

§Arguments
  • alpha - The new alpha value, must be in range [0, 1]
§Errors

Returns an error if the value is outside the range [0, 1].

Source

pub fn set_components( &mut self, grey: T, alpha: T, ) -> Result<(), ChromaticError>

Set both components at once with validation.

§Arguments
  • grey - The grey component, must be in range [0, 1]
  • alpha - The alpha component, must be in range [0, 1]
§Errors

Returns an error if any component is outside the range [0, 1].

Trait Implementations§

Source§

impl<T: Clone + Float + Send + Sync> Clone for GreyAlpha<T>

Source§

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

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Float + Send + Sync> Colour<T, { $base_components + 1 }> for GreyAlpha<T>

Source§

fn from_hex(hex: &str) -> Result<Self, ChromaticError>

Create a new colour from a hex string. Read more
Source§

fn to_hex(&self) -> Result<String, ChromaticError>

Convert the colour to a hex string. Read more
Source§

fn from_bytes(bytes: [u8; 2]) -> Result<Self, ChromaticError>

Create a new colour from a byte array. Read more
Source§

fn to_bytes(self) -> Result<[u8; 2], ChromaticError>

Convert the colour to a byte array. Read more
Source§

fn lerp(lhs: &Self, rhs: &Self, t: T) -> Result<Self, ChromaticError>

Linear interpolate between two colours of the same type. Read more
Source§

const NUM_COMPONENTS: usize = N

Number of components in the colour.
Source§

fn mix(colours: &[Self], weights: &[T]) -> Result<Self, ChromaticError>
where Self: Clone, T: AddAssign,

Mix multiple colours using weighted interpolation. Read more
Source§

fn mix_two( colour1: &Self, weight1: T, colour2: &Self, weight2: T, ) -> Result<Self, ChromaticError>
where Self: Clone, T: AddAssign,

Mix two colours with specified weights. Read more
Source§

fn gradient( start: &Self, end: &Self, steps: usize, ) -> Result<Vec<Self>, ChromaticError>
where Self: Clone,

Create a gradient between two colours with a specified number of steps. Read more
Source§

impl<T: Float + Send + Sync> Convert<T> for GreyAlpha<T>

Source§

fn to_grey(&self) -> Result<Grey<T>, ChromaticError>

Convert a colour to the Grey colour space. Read more
Source§

fn to_grey_alpha(&self) -> Result<GreyAlpha<T>, ChromaticError>

Convert a colour to the GreyAlpha colour space. Read more
Source§

fn to_hsl(&self) -> Result<Hsl<T>, ChromaticError>

Convert a colour to the Hsl colour space. Read more
Source§

fn to_hsl_alpha(&self) -> Result<HslAlpha<T>, ChromaticError>

Convert a colour to the HslAlpha colour space. Read more
Source§

fn to_hsv(&self) -> Result<Hsv<T>, ChromaticError>

Convert a colour to the Hsv colour space. Read more
Source§

fn to_hsv_alpha(&self) -> Result<HsvAlpha<T>, ChromaticError>

Convert a colour to the HsvAlpha colour space. Read more
Source§

fn to_lab(&self) -> Result<Lab<T>, ChromaticError>

Convert a colour to the Lab colour space. Read more
Source§

fn to_lab_alpha(&self) -> Result<LabAlpha<T>, ChromaticError>

Convert a colour to the LabAlpha colour space. Read more
Source§

fn to_rgb(&self) -> Result<Rgb<T>, ChromaticError>

Convert a colour to the Rgb colour space. Read more
Source§

fn to_rgb_alpha(&self) -> Result<RgbAlpha<T>, ChromaticError>

Convert a colour to the RgbAlpha colour space. Read more
Source§

fn to_srgb(&self) -> Result<Srgb<T>, ChromaticError>

Convert a colour to the Srgb colour space. Read more
Source§

fn to_srgb_alpha(&self) -> Result<SrgbAlpha<T>, ChromaticError>

Convert a colour to the SrgbAlpha colour space. Read more
Source§

fn to_xyz(&self) -> Result<Xyz<T>, ChromaticError>

Convert a colour to the Xyz colour space. Read more
Source§

fn to_xyz_alpha(&self) -> Result<XyzAlpha<T>, ChromaticError>

Convert a colour to the XyzAlpha colour space. Read more
Source§

impl<T: Debug + Float + Send + Sync> Debug for GreyAlpha<T>

Source§

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

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

impl<T: Float + Send + Sync> Display for GreyAlpha<T>

Source§

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

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

impl<T: Copy + Float + Send + Sync> Copy for GreyAlpha<T>

Auto Trait Implementations§

§

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

§

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

§

impl<T> Send for GreyAlpha<T>

§

impl<T> Sync for GreyAlpha<T>

§

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

§

impl<T> UnsafeUnpin for GreyAlpha<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for GreyAlpha<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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.