#[repr(C)]pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
pub a: u8,
}
Expand description
Color, 4 components, R8G8B8A8 (32bit)
Fields§
§r: u8
Color red value
g: u8
Color green value
b: u8
Color blue value
a: u8
Color alpha value
Implementations§
Source§impl Color
impl Color
Sourcepub const DARKPURPLE: Color
pub const DARKPURPLE: Color
Dark purple color
Sourcepub const fn new(r: u8, g: u8, b: u8, a: u8) -> Self
pub const fn new(r: u8, g: u8, b: u8, a: u8) -> Self
Convenience function for creating a new color
Sourcepub fn fade(self, alpha: f32) -> Self
pub fn fade(self, alpha: f32) -> Self
Get color with alpha applied, alpha goes from 0.0f to 1.0f
Sourcepub fn from_normalized(normalized: Vector4) -> Self
pub fn from_normalized(normalized: Vector4) -> Self
Get Color from normalized values [0..1]
Sourcepub fn to_hsv(self) -> Vector3
pub fn to_hsv(self) -> Vector3
Get HSV values for a Color, hue [0..360], saturation/value [0..1]
Sourcepub fn from_hsv(hue: f32, saturation: f32, value: f32) -> Self
pub fn from_hsv(hue: f32, saturation: f32, value: f32) -> Self
Get a Color from HSV values, hue [0..360], saturation/value [0..1]
Sourcepub fn brightness(self, factor: f32) -> Self
pub fn brightness(self, factor: f32) -> Self
Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
Sourcepub fn contrast(self, contrast: f32) -> Self
pub fn contrast(self, contrast: f32) -> Self
Get color with contrast correction, contrast values between -1.0f and 1.0f
Sourcepub fn alpha(self, alpha: f32) -> Self
pub fn alpha(self, alpha: f32) -> Self
Get color with alpha applied, alpha goes from 0.0f to 1.0f
Sourcepub fn alpha_blend(self, src: Self, tint: Self) -> Self
pub fn alpha_blend(self, src: Self, tint: Self) -> Self
Get src alpha-blended into dst color with tint
Sourcepub fn get_pixel_color(source: &[u8], format: PixelFormat) -> Option<Self>
pub fn get_pixel_color(source: &[u8], format: PixelFormat) -> Option<Self>
Get Color from a source pixel pointer of certain format (uncompressed formats only)
Returns None
if buffer isn’t large enough
Sourcepub fn set_pixel_color(self, dest: &mut [u8], format: PixelFormat) -> bool
pub fn set_pixel_color(self, dest: &mut [u8], format: PixelFormat) -> bool
Set color formatted into destination pixel pointer (uncompressed formats only)
Returns true
on success, false
if buffer isn’t large enough