[][src]Struct regenboog::RgbaU8

pub struct RgbaU8 {
    pub red: u8,
    pub green: u8,
    pub blue: u8,
    pub alpha: u8,
}

A type which represents a color.

This color is defined by four components:

  • red
  • green
  • blue
  • alpha

Fields

red: u8

The red component

green: u8

The green component

blue: u8

The blue component

alpha: u8

The alpha component

Implementations

impl RgbaU8[src]

pub const WHITE: RgbaU8[src]

Pure white

pub const BLACK: RgbaU8[src]

Pure black

pub const RED: RgbaU8[src]

Red

pub const GREEN: RgbaU8[src]

Green

pub const BLUE: RgbaU8[src]

Blue

pub const fn rgb(red: u8, green: u8, blue: u8) -> RgbaU8[src]

Construct a color from its red, green and blue components.

The alpha value is set to 255.

Examples

let swag_color = RgbaU8::rgb(160, 32, 240);
assert_eq!(swag_color.red  , 160);
assert_eq!(swag_color.green, 32 );
assert_eq!(swag_color.blue , 240);
assert_eq!(swag_color.alpha, 255);

pub const fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> RgbaU8[src]

Construct a color from its red, green, blue and alpha components.

Examples

let swag_color_transparent = RgbaU8::rgba(160, 32, 240, 200);
assert_eq!(swag_color_transparent.red  , 160);
assert_eq!(swag_color_transparent.green, 32 );
assert_eq!(swag_color_transparent.blue , 240);
assert_eq!(swag_color_transparent.alpha, 200);

pub const fn with_red(self, red: u8) -> RgbaU8[src]

Get a new color with the specified red component.

Examples

let yellow = RgbaU8::GREEN.with_red(255);
assert_eq!(yellow, RgbaU8::rgb(255, 255, 0));

pub const fn with_green(self, green: u8) -> RgbaU8[src]

Get a new color with the specified green component.

Examples

let cyan = RgbaU8::BLUE.with_green(255);
assert_eq!(cyan, RgbaU8::rgb(0, 255, 255));

pub const fn with_blue(self, blue: u8) -> RgbaU8[src]

Get a new color with the specified blue component.

Examples

let magenta = RgbaU8::BLUE.with_red(255);
assert_eq!(magenta, RgbaU8::rgb(255, 0, 255));

pub const fn with_alpha(self, alpha: u8) -> RgbaU8[src]

Get a new color with the specified alpha component.

Examples

let transparent_blue = RgbaU8::BLUE.with_alpha(100);
assert_eq!(transparent_blue, RgbaU8::rgba(0, 0, 255, 100));

Trait Implementations

impl Clone for RgbaU8[src]

impl Copy for RgbaU8[src]

impl Debug for RgbaU8[src]

impl Eq for RgbaU8[src]

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

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

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

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

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

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

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

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

impl Hash for RgbaU8[src]

impl Ord for RgbaU8[src]

impl PartialEq<RgbaU8> for RgbaU8[src]

impl PartialOrd<RgbaU8> for RgbaU8[src]

impl StructuralEq for RgbaU8[src]

impl StructuralPartialEq for RgbaU8[src]

Auto Trait Implementations

impl RefUnwindSafe for RgbaU8

impl Send for RgbaU8

impl Sync for RgbaU8

impl Unpin for RgbaU8

impl UnwindSafe for RgbaU8

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.