pub struct HSV {
pub h: f32,
pub s: f32,
pub v: f32,
}Expand description
HSV color.
| Field | Range | Description |
|---|---|---|
h | 0..360 | Hue angle (wraps at 360) |
s | 0..1 | Saturation |
v | 0..1 | Value (brightness) |
§Why no arithmetic?
HSV does not implement ChannelArray, [Add], [Sub], [Mul],
or lerp. Hue is an angle on a circle — componentwise interpolation
between 350° and 10° would pass through 180° instead of the short arc
through 0°. This produces incorrect visual results.
To manipulate HSV colors, convert to RGBA, do your math there,
then convert back:
use optic_color::*;
let hsv = HSV::new(350.0, 0.8, 0.9);
let mut rgba: RGBA = hsv.into();
rgba = rgba.lighten(0.1);For hue-aware interpolation between two colors, use Gradient with
[GradientColorSpace::Hsv].
Fields§
§h: f32§s: f32§v: f32Implementations§
Source§impl HSV
impl HSV
Sourcepub fn new(h: f32, s: f32, v: f32) -> Self
pub fn new(h: f32, s: f32, v: f32) -> Self
Construct an HSV color with clamping.
Hue is clamped to 0..360, saturation and value to 0..1.
Sourcepub fn to_rgba_alpha(self, alpha: f32) -> RGBA
pub fn to_rgba_alpha(self, alpha: f32) -> RGBA
Convert to RGBA with a custom alpha, without going through ToRgba.
Equivalent to self.to_rgba().with_alpha(alpha).
Trait Implementations§
impl Copy for HSV
Auto Trait Implementations§
impl Freeze for HSV
impl RefUnwindSafe for HSV
impl Send for HSV
impl Sync for HSV
impl Unpin for HSV
impl UnsafeUnpin for HSV
impl UnwindSafe for HSV
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more