Struct radiant_rs::Color
[−]
[src]
pub struct Color(pub f32, pub f32, pub f32, pub f32);
A color value consisting of four floating point values for the color channels red, green, blue and alpha.
Various drawing methods accept color instances to be used as multiplicators in the drawing
process, e.g. Sprite::draw()
allows multiplying the sprite-
texture's color channels by given color.
Methods
impl Color
[src]
pub const TRANSPARENT: Color
TRANSPARENT: Color = Color(0.0, 0.0, 0.0, 0.0)
pub const WHITE: Color
WHITE: Color = Color(1.0, 1.0, 1.0, 1.0)
pub const BLACK: Color
BLACK: Color = Color(0.0, 0.0, 0.0, 1.0)
pub const RED: Color
RED: Color = Color(1.0, 0.0, 0.0, 1.0)
pub const GREEN: Color
GREEN: Color = Color(0.0, 1.0, 0.0, 1.0)
pub const BLUE: Color
BLUE: Color = Color(0.0, 0.0, 1.0, 1.0)
pub const YELLOW: Color
YELLOW: Color = Color(1.0, 1.0, 0.0, 1.0)
pub const CYAN: Color
CYAN: Color = Color(0.0, 1.0, 1.0, 1.0)
pub const MAGENTA: Color
MAGENTA: Color = Color(1.0, 0.0, 1.0, 1.0)
pub fn alpha(alpha: f32) -> Color
[src]
Creates a new instance with color channels set to one and the alpha channel set to given value.
pub fn alpha_mask(alpha: f32) -> Color
[src]
Creates a new instance with color channels set to zero and the alpha channel set to given value.
pub fn alpha_pm(alpha: f32) -> Color
[src]
Creates a new instance with all channels set to given value.
pub fn lightness(value: f32) -> Color
[src]
Creates a new instance with color channels set to given value and the alpha channel set to one.
pub fn from_hsl(hue: f32, saturation: f32, lightness: f32, alpha: f32) -> Color
[src]
Creates a new instance from given HSL (range 0.0 - 1.0)
pub fn from_temperature(temperature: f32, alpha: f32) -> Color
[src]
Creates a new instance from given color-temperature (~1000 to ~40000).
Based on http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
pub fn r(&self) -> f32
[src]
Returns value of the instance's red channel.
pub fn g(&self) -> f32
[src]
Returns value of the instance's green channel.
pub fn b(&self) -> f32
[src]
Returns value of the instance's blue channel.
pub fn a(&self) -> f32
[src]
Returns value of the instance's alpha channel.
pub fn set(&mut self, value: Color)
[src]
Sets the instance's channels from another color object.
pub fn set_r(&mut self, value: f32) -> &mut Color
[src]
Sets a value for the instance's red channel
pub fn set_g(&mut self, value: f32) -> &mut Color
[src]
Sets a value for the instance's green channel.
pub fn set_b(&mut self, value: f32) -> &mut Color
[src]
Sets a value for the instance's blue channel.
pub fn set_a(&mut self, value: f32) -> &mut Color
[src]
Sets a value for the instance's alpha channel.
pub fn scale(&mut self, scaling: f32) -> &mut Color
[src]
Multiplies the instance's color channels by given scaling factor. Does not modify alpha.
pub fn to_pm(&self) -> Color
[src]
Trait Implementations
impl Copy for Color
[src]
impl Clone for Color
[src]
fn clone(&self) -> Color
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for Color
[src]
impl PartialEq for Color
[src]
fn eq(&self, __arg_0: &Color) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Color) -> bool
[src]
This method tests for !=
.
impl<T> From<(T, T, T, T)> for Color where
f32: From<T>,
[src]
f32: From<T>,
impl<T> From<[T; 4]> for Color where
T: Copy,
f32: From<T>,
[src]
T: Copy,
f32: From<T>,