[−][src]Struct tiny_skia::Color
An RGBA color value, holding four floating point components.
Guarantees
- All values are in 0..=1 range.
Implementations
impl Color
[src]
pub const TRANSPARENT: Color
[src]
A transparent color.
pub const BLACK: Color
[src]
A black color.
pub const WHITE: Color
[src]
A white color.
pub fn from_rgba(r: f32, g: f32, b: f32, a: f32) -> Option<Self>
[src]
Creates a new color from 4 components.
All values must be in 0..=1 range.
pub fn from_rgba8(r: u8, g: u8, b: u8, a: u8) -> Self
[src]
Creates a new color from 4 components.
u8 will be divided by 255 to get the float component.
pub fn red(&self) -> f32
[src]
Returns color's red component.
The value is guarantee to be in a 0..=1 range.
pub fn green(&self) -> f32
[src]
Returns color's green component.
The value is guarantee to be in a 0..=1 range.
pub fn blue(&self) -> f32
[src]
Returns color's blue component.
The value is guarantee to be in a 0..=1 range.
pub fn alpha(&self) -> f32
[src]
Returns color's alpha component.
The value is guarantee to be in a 0..=1 range.
pub fn set_red(&mut self, c: f32)
[src]
Sets the red component value.
The new value will be clipped to the 0..=1 range.
pub fn set_green(&mut self, c: f32)
[src]
Sets the green component value.
The new value will be clipped to the 0..=1 range.
pub fn set_blue(&mut self, c: f32)
[src]
Sets the blue component value.
The new value will be clipped to the 0..=1 range.
pub fn set_alpha(&mut self, c: f32)
[src]
Sets the alpha component value.
The new value will be clipped to the 0..=1 range.
pub fn apply_opacity(&mut self, opacity: f32)
[src]
Shifts color's opacity.
Essentially, multiplies color's alpha by opacity.
opacity
will be clamped to the 0..=1 range first.
The final alpha will also be clamped.
pub fn is_opaque(&self) -> bool
[src]
Check that color is opaque.
Alpha == 1.0
pub fn premultiply(&self) -> PremultipliedColor
[src]
Converts into a premultiplied color.
pub fn to_color_u8(&self) -> ColorU8
[src]
Converts into ColorU8
.
Trait Implementations
impl Clone for Color
[src]
impl Copy for Color
[src]
impl Debug for Color
[src]
impl PartialEq<Color> 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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> 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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,