Expand description
Utility type for manpulating RGBA colors
Color
is a simple color type composed of 4 components: Red, Green, Blue, Alpha
Example
There are 3 basic ways to construct a color
use sfml::graphics::Color;
let color1 = Color::rgb(255, 0, 0); // from red/green/blue values
let color2 = Color::rgba(255, 255, 255, 128); // from red/green/blue/alpha (transparency)
let color3 = Color::GREEN; // from one of the associated color constants
Fields§
§r: u8
Red component
g: u8
Green component
b: u8
Blue component
a: u8
Alpha component (transparency)
Implementations§
source§impl Color
impl Color
sourcepub const fn rgb(red: u8, green: u8, blue: u8) -> Self
pub const fn rgb(red: u8, green: u8, blue: u8) -> Self
Construct a color from its 3 RGB components
Arguments
- red - Red component (0 .. 255)
- green - -Green component (0 .. 255)
- blue - Blue component (0 .. 255)
Return Color object constructed from the components
sourcepub const fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Self
pub const fn rgba(red: u8, green: u8, blue: u8, alpha: u8) -> Self
Construct a color from its 4 RGBA components
Arguments
- red - Red component (0 .. 255)
- green - -Green component (0 .. 255)
- blue - Blue component (0 .. 255)
- alpha - Alpha component (0 .. 255)
Return Color object constructed from the components
sourcepub const TRANSPARENT: Self = _
pub const TRANSPARENT: Self = _
Tranparent predefined color
Trait Implementations§
source§impl AddAssign<Color> for Color
impl AddAssign<Color> for Color
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl MulAssign<Color> for Color
impl MulAssign<Color> for Color
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl PartialEq<Color> for Color
impl PartialEq<Color> for Color
source§impl SubAssign<Color> for Color
impl SubAssign<Color> for Color
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read more