[][src]Struct duku::Hsb

pub struct Hsb {
    pub h: u16,
    pub s: u8,
    pub b: u8,
    pub a: u8,
}

Color bytes in HSB with alpha.

Makes it easier to handle/convert colors.

HSB is the same as HSV.

Examples

let red = Hsb::new(0, 100, 100);

Fields

h: u16

the hue component in range 0 to 360

s: u8

the saturation component in range 0 to 100

b: u8

the brightness component in range 0 to 100

a: u8

the alpha component

Implementations

impl Hsb[src]

pub fn new(h: u16, s: u8, b: u8) -> Self[src]

Create color

Converts components to correct ranges

pub const fn alpha(self, a: u8) -> Self[src]

Create color, modifying the color's alpha

Examples

let color = Hsb::new(0, 100, 100).alpha(50);

pub const fn shift(self, h: u16) -> Self[src]

Create color, shifting the hue by value

Examples

let red = Hsb::new(360, 100, 100);
let yellow = red.shift(60);

pub fn darken(self, v: u8) -> Self[src]

Create color, darkening by some value

Examples

let red = Hsb::new(0, 100, 100);
let dark_red = red.darken(5);

pub fn brighten(self, v: u8) -> Self[src]

Create color, brightening by some value

Examples

let red = Hsb::new(0, 100, 50);
let bright_red = red.brighten(5);

pub fn saturate(self, v: u8) -> Self[src]

Create color, saturating by some value

Examples

let red = Hsb::new(0, 50, 100);
let saturated_red = red.saturate(5);

pub fn desaturate(self, v: u8) -> Self[src]

Create color, desaturating by some value

Examples

let red = Hsb::new(0, 100, 100);
let desaturated_red = red.desaturate(5);

Trait Implementations

impl Clone for Hsb[src]

impl Copy for Hsb[src]

impl Debug for Hsb[src]

impl Default for Hsb[src]

impl Eq for Hsb[src]

impl<'_> From<&'_ str> for Hsb[src]

impl From<Hsb> for Rgb[src]

impl From<Hsb> for Rgbf[src]

impl From<Rgb> for Hsb[src]

impl From<Rgbf> for Hsb[src]

impl Hash for Hsb[src]

impl Mix for Hsb[src]

impl PartialEq<Hsb> for Hsb[src]

impl StructuralEq for Hsb[src]

impl StructuralPartialEq for Hsb[src]

Auto Trait Implementations

impl RefUnwindSafe for Hsb

impl Send for Hsb

impl Sync for Hsb

impl Unpin for Hsb

impl UnwindSafe for Hsb

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.