[][src]Struct duku::Color

pub struct Color {
    pub r: u8,
    pub g: u8,
    pub b: u8,
    pub a: u8,
}

Color bytes in RGBA.

Makes it easier to handle/convert colors.

Example

This example is not tested
let red = Color::RED;
let (h, s, v) = rgb.to_hsv();

Fields

r: u8

the red component

g: u8

the green component

b: u8

the blue component

a: u8

the alpha component

Implementations

impl Color[src]

pub const fn rgb(r: u8, g: u8, b: u8) -> Self[src]

Create color from RGB bytes

pub const fn rgba(r: u8, g: u8, b: u8, a: u8) -> Self[src]

Create color from RGBA bytes

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

Create color from HSV components

pub fn rgb_norm(r: f32, g: f32, b: f32) -> Self[src]

Create color from RGB normalized floats

pub fn rgba_norm(r: f32, g: f32, b: f32, a: f32) -> Self[src]

Create color from RGBA normalized floats

pub const fn gray(v: u8) -> Self[src]

Create color from gray value byte

pub fn gray_norm(v: f32) -> Self[src]

Create color from gray value normalized float

pub fn to_rgb_norm(&self) -> [f32; 3][src]

Get RGB components as normalized floats

pub fn to_rgba_norm(&self) -> [f32; 4][src]

Get RGBA components as normalized floats

pub fn to_hsv(&self) -> (u16, u8, u8)[src]

Get HSV components

pub fn to_srgb(&self) -> Self[src]

Convert color to sRGB color space

pub fn to_linear(&self) -> Self[src]

Convert color to linear color space

pub const WHITE: Self[src]

Shorthand for Color::rgb(255, 255, 255)

pub const SILVER: Self[src]

Shorthand for Color::rgb(192, 192, 192)

pub const GRAY: Self[src]

Shorthand for Color::rgb(128, 128, 128)

pub const BLACK: Self[src]

Shorthand for Color::rgb(0, 0, 0)

pub const RED: Self[src]

Shorthand for Color::rgb(255, 0, 0)

pub const MAROON: Self[src]

Shorthand for Color::rgb(128, 0, 0)

pub const YELLOW: Self[src]

Shorthand for Color::rgb(255, 255, 0)

pub const OLIVE: Self[src]

Shorthand for Color::rgb(128, 128, 0)

pub const AQUA: Self[src]

Shorthand for Color::rgb(0, 255, 255)

pub const TEAL: Self[src]

Shorthand for Color::rgb(0, 128, 128)

pub const BLUE: Self[src]

Shorthand for Color::rgb(0, 0, 255)

pub const NAVY: Self[src]

Shorthand for Color::rgb(0, 0, 128)

pub const FUCHSIA: Self[src]

Shorthand for Color::rgb(128, 0, 128)

pub const PURPLE: Self[src]

Shorthand for Color::rgb(128, 0, 128)

pub const GREEN: Self[src]

Shorthand for Color::rgb(0, 255, 0)

pub const SKY_BLUE: Self[src]

Shorthand for Color::rgb(135, 206, 235)

pub const ORANGE: Self[src]

Shorthand for Color::rgb(255, 127, 0)

Trait Implementations

impl Clone for Color[src]

impl Copy for Color[src]

impl Debug for Color[src]

impl Eq for Color[src]

impl From<[f32; 3]> for Color[src]

impl From<[f32; 4]> for Color[src]

impl From<[u8; 3]> for Color[src]

impl From<[u8; 4]> for Color[src]

impl From<Color> for Vector3[src]

impl From<Color> for Vector4[src]

impl Hash for Color[src]

impl PartialEq<Color> for Color[src]

impl StructuralEq for Color[src]

impl StructuralPartialEq for Color[src]

Auto Trait Implementations

impl RefUnwindSafe for Color

impl Send for Color

impl Sync for Color

impl Unpin for Color

impl UnwindSafe for Color

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.