Struct Hsv

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

The HSV device-dependent polar color model

hsv-diagram

HSV is defined by a hue (base color), saturation (color richness) and value (color intensity). HSV is modeled as a cylinder, however the underlying space is conical. This causes some level of distortion and a degeneracy at S=0 or V=0. Thus, while easy to reason about, it is not good for perceptual uniformity. It does an okay job with averaging colors or doing other math, but prefer the CIE spaces for uniform gradients.

Hsv takes two type parameters: the cartesian channel scalar, and an angular channel scalar.

Hsv is in the same color space and encoding as the parent RGB space, it is merely a geometric transformation and distortion.

For an undistorted device-dependent polar color model, look at Hsi.

Implementations§

Source§

impl<T, A> Hsv<T, A>

Source

pub fn new(hue: A, saturation: T, value: T) -> Self

Construct an Hsv instance from hue, saturation and value

Source

pub fn color_cast<TOut, AOut>(&self) -> Hsv<TOut, AOut>

Convert the internal channel scalar format

Source

pub fn hue(&self) -> A

Returns the hue scalar

Source

pub fn saturation(&self) -> T

Returns the saturation scalar

Source

pub fn value(&self) -> T

Returns the value scalar

Source

pub fn hue_mut(&mut self) -> &mut A

Returns a mutable reference to the hue channel scalar

Source

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

Returns a mutable reference to the saturation channel scalar

Source

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

Returns a mutable reference to the value channel scalar

Source

pub fn set_hue(&mut self, val: A)

Set the hue channel value

Source

pub fn set_saturation(&mut self, val: T)

Set the saturation channel value

Source

pub fn set_value(&mut self, val: T)

Set the value channel value

Trait Implementations§

Source§

impl<T, A> AbsDiffEq for Hsv<T, A>

Source§

type Epsilon = <T as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
Source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
Source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
Source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of ApproxEq::abs_diff_eq.
Source§

impl<T, A> Bounded for Hsv<T, A>

Source§

fn normalize(self) -> Self

Return a value clipped inside the normalized range
Source§

fn is_normalized(&self) -> bool

Return true if the value is normalized
Source§

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

Source§

fn clone(&self) -> Hsv<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, A> Color for Hsv<T, A>

Source§

type Tag = HsvTag

The unique tag unit struct identifying the color type
Source§

type ChannelsTuple = (A, T, T)

A tuple of types for each channel in the color
Source§

fn num_channels() -> u32

Return how many channels the color has
Source§

fn to_tuple(self) -> Self::ChannelsTuple

Convert a color into a tuple of channels
Source§

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

Source§

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

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

impl<T, A> Default for Hsv<T, A>

Source§

fn default() -> Self

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

impl<T, A> Display for Hsv<T, A>

Source§

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

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

impl<T, A> EncodableColor for Hsv<T, A>

Source§

fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>
where E: ColorEncoding,

Specify what encoding the color has. This does not actually encode anything Read more
Source§

fn linear(self) -> EncodedColor<Self, LinearEncoding>

Specify that the color is linear
Source§

fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>

Specify that the color is sRGB encoded Read more
Source§

fn gamma_encoded<T: Float>( self, gamma: T, ) -> EncodedColor<Self, GammaEncoding<T>>

Specify that the color is gamma encoded with a given gamma
Source§

impl<T, A> From<Hsv<T, A>> for Rgb<T>

Source§

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

Converts to this type from the input type.
Source§

impl<T, A> From<Rgb<T>> for Hsv<T, A>

Source§

fn from(from: Rgb<T>) -> Self

Converts to this type from the input type.
Source§

impl<T, A> FromColor<Hsv<T, A>> for Hwb<T, A>

Source§

fn from_color(from: &Hsv<T, A>) -> Self

Construct Self from from
Source§

impl<T, A> FromColor<Hsv<T, A>> for Rgb<T>

Source§

fn from_color(from: &Hsv<T, A>) -> Self

Construct Self from from
Source§

impl<T, A> FromColor<Hwb<T, A>> for Hsv<T, A>

Source§

fn from_color(from: &Hwb<T, A>) -> Self

Construct Self from from
Source§

impl<T, A> FromColor<Rgb<T>> for Hsv<T, A>

Source§

fn from_color(from: &Rgb<T>) -> Self

Construct Self from from
Source§

impl<T, A> FromTuple for Hsv<T, A>

Source§

fn from_tuple(values: Self::ChannelsTuple) -> Self

Construct Self from a tuple of channel values
Source§

impl<T: Hash, A: Hash> Hash for Hsv<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, A> Invert for Hsv<T, A>

Source§

fn invert(self) -> Self

Invert Self
Source§

impl<T, A> Lerp for Hsv<T, A>

Source§

type Position = <A as Lerp>::Position

The type of the pos argument
Source§

fn lerp(&self, right: &Self, pos: Self::Position) -> Self

Interpolate between self and right Read more
Source§

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

Source§

fn eq(&self, other: &Hsv<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 Hsv<T, A>

Source§

fn partial_cmp(&self, other: &Hsv<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, A> PolarColor for Hsv<T, A>

Source§

type Angular = A

The angular channel’s scalar type
Source§

type Cartesian = T

The remaining channels’ scalar types
Source§

impl<T, A> RelativeEq for Hsv<T, A>

Source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
Source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
Source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool

The inverse of ApproxEq::relative_eq.
Source§

impl<T, A> UlpsEq for Hsv<T, A>

Source§

fn default_max_ulps() -> u32

The default ULPs to tolerate when testing values that are far-apart. Read more
Source§

fn ulps_eq(&self, other: &Self, epsilon: Self::Epsilon, max_ulps: u32) -> bool

A test for equality that uses units in the last place (ULP) if the values are far apart.
Source§

fn ulps_ne(&self, other: &Rhs, epsilon: Self::Epsilon, max_ulps: u32) -> bool

The inverse of ApproxEq::ulps_eq.
Source§

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

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T, A> UnwindSafe for Hsv<T, A>
where A: UnwindSafe, 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.