#[repr(C)]pub struct Hsv<T, A = Deg<T>> { /* private fields */ }Expand description
The HSV device-dependent polar color model

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>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Sourcepub fn new(hue: A, saturation: T, value: T) -> Self
pub fn new(hue: A, saturation: T, value: T) -> Self
Construct an Hsv instance from hue, saturation and value
Sourcepub fn color_cast<TOut, AOut>(&self) -> Hsv<TOut, AOut>where
T: ChannelFormatCast<TOut>,
A: ChannelFormatCast<AOut>,
AOut: AngularChannelScalar,
TOut: PosNormalChannelScalar,
pub fn color_cast<TOut, AOut>(&self) -> Hsv<TOut, AOut>where
T: ChannelFormatCast<TOut>,
A: ChannelFormatCast<AOut>,
AOut: AngularChannelScalar,
TOut: PosNormalChannelScalar,
Convert the internal channel scalar format
Sourcepub fn saturation(&self) -> T
pub fn saturation(&self) -> T
Returns the saturation scalar
Sourcepub fn saturation_mut(&mut self) -> &mut T
pub fn saturation_mut(&mut self) -> &mut T
Returns a mutable reference to the saturation channel scalar
Sourcepub fn set_saturation(&mut self, val: T)
pub fn set_saturation(&mut self, val: T)
Set the saturation channel value
Trait Implementations§
Source§impl<T, A> AbsDiffEq for Hsv<T, A>where
T: PosNormalChannelScalar + AbsDiffEq<Epsilon = A::Epsilon>,
A: AngularChannelScalar + AbsDiffEq,
A::Epsilon: Clone + Float,
impl<T, A> AbsDiffEq for Hsv<T, A>where
T: PosNormalChannelScalar + AbsDiffEq<Epsilon = A::Epsilon>,
A: AngularChannelScalar + AbsDiffEq,
A::Epsilon: Clone + Float,
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
Source§impl<T, A> Bounded for Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> Bounded for Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Source§impl<T, A> Color for Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> Color for Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Source§type ChannelsTuple = (A, T, T)
type ChannelsTuple = (A, T, T)
Source§fn num_channels() -> u32
fn num_channels() -> u32
Source§fn to_tuple(self) -> Self::ChannelsTuple
fn to_tuple(self) -> Self::ChannelsTuple
Source§impl<T, A> EncodableColor for Hsv<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Turns<T>>,
impl<T, A> EncodableColor for Hsv<T, A>where
T: PosNormalChannelScalar + Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<Turns<T>>,
Source§fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>where
E: ColorEncoding,
fn encoded_as<E>(self, encoding: E) -> EncodedColor<Self, E>where
E: ColorEncoding,
Source§fn linear(self) -> EncodedColor<Self, LinearEncoding>
fn linear(self) -> EncodedColor<Self, LinearEncoding>
Source§fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
fn srgb_encoded(self) -> EncodedColor<Self, SrgbEncoding>
Source§fn gamma_encoded<T: Float>(
self,
gamma: T,
) -> EncodedColor<Self, GammaEncoding<T>>
fn gamma_encoded<T: Float>( self, gamma: T, ) -> EncodedColor<Self, GammaEncoding<T>>
Source§impl<T, A> FromColor<Hsv<T, A>> for Hwb<T, A>
impl<T, A> FromColor<Hsv<T, A>> for Hwb<T, A>
Source§fn from_color(from: &Hsv<T, A>) -> Self
fn from_color(from: &Hsv<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Hsv<T, A>> for Rgb<T>
impl<T, A> FromColor<Hsv<T, A>> for Rgb<T>
Source§fn from_color(from: &Hsv<T, A>) -> Self
fn from_color(from: &Hsv<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Hwb<T, A>> for Hsv<T, A>
impl<T, A> FromColor<Hwb<T, A>> for Hsv<T, A>
Source§fn from_color(from: &Hwb<T, A>) -> Self
fn from_color(from: &Hwb<T, A>) -> Self
Self from fromSource§impl<T, A> FromColor<Rgb<T>> for Hsv<T, A>
impl<T, A> FromColor<Rgb<T>> for Hsv<T, A>
Source§fn from_color(from: &Rgb<T>) -> Self
fn from_color(from: &Rgb<T>) -> Self
Self from fromSource§impl<T, A> FromTuple for Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
impl<T, A> FromTuple for Hsv<T, A>where
T: PosNormalChannelScalar,
A: AngularChannelScalar,
Source§fn from_tuple(values: Self::ChannelsTuple) -> Self
fn from_tuple(values: Self::ChannelsTuple) -> Self
Self from a tuple of channel values