[−][src]Struct pixelflut::pixel::Color
Methods
impl Color
[src]
pub fn rgb(r: u8, g: u8, b: u8) -> Color
[src]
Constructs a new Color
without using an alpha channel.
Examples
Basic usage:
use pixelflut::Color; Color::rgb(255, 255, 255);
pub fn rgba(r: u8, g: u8, b: u8, a: u8) -> Color
[src]
Constructs a new Color
using an alpha channel.
Examples
Basic usage:
use pixelflut::Color; Color::rgba(255, 255, 255, 255);
pub fn packed(r: u8, g: u8, b: u8, a: u8) -> Color
[src]
Constructs a new Color
using the alpha channel only, if a != 255.
Examples
Basic usage:
use pixelflut::Color; assert_eq!(Color::packed(123, 23, 42, 255), Color::rgb(123, 23, 42)); assert_eq!(Color::packed(123, 23, 42, 64), Color::rgba(123, 23, 42, 64));
pub fn pack(&self) -> Color
[src]
Strips the alpha channel if not existent or value is 255.Color
Examples
Basic usage:
use pixelflut::Color; assert_eq!(Color::rgba(12, 34, 56, 255).pack(), Color::rgb(12, 34, 56)); assert_eq!(Color::rgb(12, 34, 56).pack(), Color::rgb(12, 34, 56)); assert_eq!(Color::rgba(12, 34, 56, 78).pack(), Color::rgba(12, 34, 56, 78));
pub fn normalized(self) -> (u8, u8, u8, u8)
[src]
Returns a 4-Tuple with the components red, green, blue and alpha
If no alpha channel is present, 255 is returned as the alpha channel.
Examples
use pixelflut::Color; assert_eq!((255, 0, 0, 255), Color::rgb(255, 0, 0).normalized())
Trait Implementations
impl Into<(u8, u8, u8)> for Color
[src]
impl Into<(u8, u8, u8, u8)> for Color
[src]
impl Copy for Color
[src]
impl PartialEq<Color> for Color
[src]
impl From<(u8, u8, u8)> for Color
[src]
impl From<(u8, u8, u8, u8)> for Color
[src]
impl Clone for Color
[src]
fn clone(&self) -> Color
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Display for Color
[src]
impl Debug for Color
[src]
impl Hash for Color
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromStr for Color
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Color>
[src]
Converts a string to a color
Examples
use pixelflut::Color; assert_eq!(Color::rgb(0x11, 0x22, 0x33), "112233".parse().unwrap()); assert_eq!(Color::rgba(0x11, 0x22, 0x33, 0xee), "112233ee".parse().unwrap()); assert!("".parse::<Color>().is_err()); assert!("123".parse::<Color>().is_err()); assert!("12345".parse::<Color>().is_err()); assert!(" 1 2 3".parse::<Color>().is_err()); assert!("112g33".parse::<Color>().is_err());
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,