pub struct Color {
    pub r: u8,
    pub g: u8,
    pub b: u8,
    pub a: u8,
}Expand description
An RGBA (red, green, blue, alpha) color.
All components are stored as u8 and have a color range of 0-255.
Fields§
§r: u8The red component value.
g: u8The green component value.
b: u8The blue component value.
a: u8The alpha component value.
Implementations§
Source§impl Color
 
impl Color
pub const TRANSPARENT: Self
pub const BLACK: Self
pub const GRAY: Self
pub const WHITE: Self
pub const RED: Self
pub const GREEN: Self
pub const BLUE: Self
pub const YELLOW: Self
pub const CYAN: Self
pub const MAGENTA: Self
Sourcepub const fn from_rgb(rgb: u32, alpha: u8) -> Self
 
pub const fn from_rgb(rgb: u32, alpha: u8) -> Self
Creates a Color from a 32-bit rgb value and an alpha value.
The byte-ordering of the 32-bit rgb value is XXRRGGBB.
The most significant byte, represented by XX, is ignored;
the alpha value is provided separately.
This is followed by the red (RR), green (GG), and blue (BB) components values,
respectively.
§Examples
use swf::Color;
let red = Color::from_rgb(0xFF0000, 255);
let green = Color::from_rgb(0x00FF00, 255);
let blue = Color::from_rgb(0x0000FF, 255);Sourcepub const fn from_rgba(rgba: u32) -> Self
 
pub const fn from_rgba(rgba: u32) -> Self
Creates a Color from a 32-bit rgba value.
The byte-ordering of the 32-bit rgba value is AARRGGBB.
§Examples
use swf::Color;
let red = Color::from_rgba(0xFFFF0000);
let green = Color::from_rgba(0xFF00FF00);
let blue = Color::from_rgba(0xFF0000FF);Sourcepub const fn to_rgb(&self) -> u32
 
pub const fn to_rgb(&self) -> u32
Converts the color to a 32-bit RGB value.
The alpha value does not get stored.
§Examples
Basic usage:
use swf::Color;
let color = Color::from_rgb(0xFF00FF, 255);
assert_eq!(color.to_rgb(), 0xFF00FF);Alpha values do not get stored:
use swf::Color;
let color1 = Color::from_rgb(0xFF00FF, 255);
let color2 = Color::from_rgb(0xFF00FF, 0);
assert_eq!(color1.to_rgb(), color2.to_rgb());Trait Implementations§
Source§impl Mul<Color> for &ColorTransform
 
impl Mul<Color> for &ColorTransform
impl Copy for Color
impl Eq for Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnwindSafe for Color
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more