HSVColor

Struct HSVColor 

Source
pub struct HSVColor<T, A = T> {
    pub h: T,
    pub s: T,
    pub v: T,
    pub a: A,
}
Expand description

A color in the HSV Color Space.

Fields§

§h: T

Hue is a degree on the color_parser wheel from [0f32, 360f32).

0 is red, 120 is green, 240 is blue.

§s: T

Saturation is a percentage value in [0f32, 1f32].

0% means a shade of gray and 100% is the full color_parser.

§v: T

Saturation is a percentage value in [0f32, 1f32].

0% means a shade of gray and 100% is the full color_parser.

§a: A

Alpha is a percentage value in [0f32, 1f32].

0% is transparent, 100% is opaque.

Implementations§

Source§

impl HSVColor<f32>

Source

pub fn new(h: f32, s: f32, v: f32, a: f32) -> HSVColor<f32>

Create a new color in the HSV Color Space.

§Warning

The raw value is created, and the legality of the data will not be verified

The legal HSVA32 range is:

  • h: [0°, 360°)
  • s: [0%, 100%]
  • v: [0%, 100%]
  • a: [0%, 100%]
§Examples
let hsva32 = HSVA32::new(720.0, 100.0, 100.0, 100.0);
assert_eq!(hsva32.h, 0.0);
Source

pub fn normalize(&self) -> HSVColor<f32>

Make a normalized hsva color

Source§

impl<T, A> HSVColor<T, A>

Source

pub fn with_hue(self, h: T) -> HSVColor<T, A>

Build a new color with the given hue.

Source

pub fn with_saturation(self, s: T) -> HSVColor<T, A>

Build a new color with the given saturation.

Source

pub fn with_brightness(self, v: T) -> HSVColor<T, A>

Build a new color with the given brightness.

Source

pub fn with_alpha(self, a: A) -> HSVColor<T, A>

Build a new color with the given α.

Trait Implementations§

Source§

impl<T, A> Clone for HSVColor<T, A>
where T: Clone, A: Clone,

Source§

fn clone(&self) -> HSVColor<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> Debug for HSVColor<T, A>
where T: Debug, A: Debug,

Source§

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

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

impl Display for HSVColor<f32>

Source§

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

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

impl From<HSVColor<f32>> for RGBColor<f32>

Source§

fn from(hsva: HSVColor<f32>) -> RGBColor<f32>

Converts to this type from the input type.
Source§

impl From<HSVColor<f32>> for RGBColor<u8>

Source§

fn from(hsva: HSVColor<f32>) -> RGBColor<u8>

Converts to this type from the input type.
Source§

impl From<RGBColor<f32>> for HSVColor<f32>

Source§

fn from(rgba: RGBColor<f32>) -> HSVColor<f32>

Converts to this type from the input type.
Source§

impl From<RGBColor<u8>> for HSVColor<f32>

Source§

fn from(rgba: RGBColor<u8>) -> HSVColor<f32>

Converts to this type from the input type.
Source§

impl From<RGBColor<u8, ()>> for HSVColor<f32>

Source§

fn from(rgba: RGBColor<u8, ()>) -> HSVColor<f32>

Converts to this type from the input type.
Source§

impl<T, A> PartialEq for HSVColor<T, A>
where T: PartialEq, A: PartialEq,

Source§

fn eq(&self, other: &HSVColor<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, A> Copy for HSVColor<T, A>
where T: Copy, A: Copy,

Source§

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

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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