[−][src]Struct linfb::shape::Color
RGBA color used in many places in the library. Alpha channel is [0-255]
, not [0-1]
.
Can be created from 4-tuple of u8
, 3-tuple of u8
(assuming 255
in alpha channel) and hex
string:
// All of these are equivalent: let c1: Color = (128, 128, 128).into(); let c2: Color = (128, 128, 128, 255).into(); let c3: Color = "#808080".try_into().unwrap(); let c4: Color = "#808080ff".try_into().unwrap();
Can be multiplied to [0, 1]
f32
coefficient, which affects every channel besides alpha:
let color: Color = (128, 128, 128, 128).into(); // All channels set to 128 assert_eq!(color * 0.5, (64, 64, 64, 128).into());
Fields
red: u8
green: u8
blue: u8
alpha: u8
Methods
impl Color
[src]
pub fn hex(color_string: &str) -> Result<Self>
[src]
Create Color
object from hex string.
Equivalent to .try_into()
on string slice:
let c1: Color = "#112233".try_into().unwrap(); let c2: Color = Color::hex("#112233").unwrap(); assert_eq!(c1, c2); let c3: Color = "#11223344".try_into().unwrap(); let c3: Color = Color::hex("#11223344").unwrap(); assert_eq!(c1, c2);
Trait Implementations
impl From<(u8, u8, u8)> for Color
[src]
impl From<(u8, u8, u8, u8)> for Color
[src]
impl Clone for Color
[src]
impl Copy for Color
[src]
impl Eq for Color
[src]
impl PartialEq<Color> for Color
[src]
impl Debug for Color
[src]
impl<'_> TryFrom<&'_ str> for Color
[src]
type Error = Error
The type returned in the event of a conversion error.
fn try_from(color_string: &str) -> Result<Self>
[src]
impl Mul<f32> for Color
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, coeff: f32) -> Self
[src]
impl MulAssign<f32> for Color
[src]
fn mul_assign(&mut self, coeff: f32)
[src]
Auto Trait Implementations
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
impl RefUnwindSafe for Color
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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, U> TryFrom<U> 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, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T> Downcast for T where
T: Any,
[src]
T: Any,