Struct Hex

Source
pub struct Hex(/* private fields */);
Expand description

An Hex representation of the sRGB colour space.

Implementations§

Source§

impl Hex

Source

pub const fn new(hex: u32) -> Self

Source

pub fn can_use_3_digit(self) -> bool

Source

pub fn can_use_4_digit(self) -> bool

Source

pub const fn has_alpha(&self) -> bool

Trait Implementations§

Source§

impl Clone for Hex

Source§

fn clone(&self) -> Hex

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 Debug for Hex

Source§

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

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

impl Display for Hex

Source§

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

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

impl From<A98Rgb> for Hex

Source§

fn from(value: A98Rgb) -> Self

Converts to this type from the input type.
Source§

impl From<Color> for Hex

Source§

fn from(value: Color) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for A98Rgb

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Color

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Hsl

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Hsv

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Hwb

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Lab

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Lch

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for LinearRgb

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Oklab

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Oklch

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for RgbColor

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for Srgb

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for XyzD50

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hex> for XyzD65

Source§

fn from(value: Hex) -> Self

Converts to this type from the input type.
Source§

impl From<Hsl> for Hex

Source§

fn from(value: Hsl) -> Self

Converts to this type from the input type.
Source§

impl From<Hsv> for Hex

Source§

fn from(value: Hsv) -> Self

Converts to this type from the input type.
Source§

impl From<Hwb> for Hex

Source§

fn from(value: Hwb) -> Self

Converts to this type from the input type.
Source§

impl From<Lab> for Hex

Source§

fn from(value: Lab) -> Self

Converts to this type from the input type.
Source§

impl From<Lch> for Hex

Source§

fn from(value: Lch) -> Self

Converts to this type from the input type.
Source§

impl From<LinearRgb> for Hex

Source§

fn from(value: LinearRgb) -> Self

Converts to this type from the input type.
Source§

impl From<Named> for Hex

Source§

fn from(value: Named) -> Self

Converts to this type from the input type.
Source§

impl From<Oklab> for Hex

Source§

fn from(value: Oklab) -> Self

Converts to this type from the input type.
Source§

impl From<Oklch> for Hex

Source§

fn from(value: Oklch) -> Self

Converts to this type from the input type.
Source§

impl From<Srgb> for Hex

Source§

fn from(value: Srgb) -> Self

Converts to this type from the input type.
Source§

impl From<XyzD50> for Hex

Source§

fn from(value: XyzD50) -> Self

Converts to this type from the input type.
Source§

impl From<XyzD65> for Hex

Source§

fn from(value: XyzD65) -> Self

Converts to this type from the input type.
Source§

impl Hash for Hex

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 Ord for Hex

Source§

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

Source§

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

Source§

fn partial_cmp(&self, other: &Hex) -> 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 Copy for Hex

Source§

impl Eq for Hex

Source§

impl StructuralPartialEq for Hex

Auto Trait Implementations§

§

impl Freeze for Hex

§

impl RefUnwindSafe for Hex

§

impl Send for Hex

§

impl Sync for Hex

§

impl Unpin for Hex

§

impl UnwindSafe for Hex

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<C, T> ColorDistance<T> for C
where C: Copy, Lab: From<C> + From<T>,

Source§

fn close_to(&self, other: T, tolerance: f64) -> bool

Compares self to other via delta_e, checking that the result is less than or equal to tolerance. Read more
Source§

fn far_from(&self, other: T, tolerance: f64) -> bool

Compares self to other via delta_e, checking that the result is greater than or equal to tolerance. Read more
Source§

fn delta_e(&self, other: T) -> f64

This uses the CIEDE2000 Delta E formula difference between self and other. 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.
Source§

impl<C, T> WcagColorContrast<T> for C
where C: Copy, T: Copy, Srgb: From<C> + From<T>,

Source§

fn wcag_contrast_ratio(&self, other: T) -> f64

Calculate the contrast ratio between self and other. colors according to WCAG 2.1. Returns a value between 1:1 and 21:1 Read more
Source§

fn wcag_level(&self, other: T) -> WcagLevel

Get the WCAG level for the contrast between self and other. Read more
Source§

fn find_minimum_contrast<Space>( &self, other: T, level: WcagLevel, ) -> Option<Space>
where Self: WcagColorContrast<Space>, Space: ColorMix<Self, T> + From<Self> + From<T> + Copy + PartialEq + Debug, Srgb: From<Space>, Hex: From<Space>,

Find the closest color that meets a specific WCAG level against a background. Read more