Struct turtle::color::Color
[−]
[src]
pub struct Color { pub red: f64, pub green: f64, pub blue: f64, pub alpha: f64, }
Type for representing a color.
See the module level documentation for more.
Fields
red: f64
Value between 0.0 and 255.0
green: f64
Value between 0.0 and 255.0
blue: f64
Value between 0.0 and 255.0
alpha: f64
Value between 0.0 and 1.0
Methods
impl Color
[src]
pub fn is_valid(&self) -> bool
[src]
Returns true if the values for each field are valid.
The documentation above lists the valid range for each field.
pub fn opaque(self) -> Color
[src]
Return a new color with all of the same values except with opacity (alpha) set to 1.0
use turtle::Color; let color = Color {red: 43.0, green: 79.0, blue: 23.0, alpha: 0.5}; assert_eq!(color.alpha, 0.5); let color2 = color.opaque(); assert_eq!(color.alpha, 0.5); assert_eq!(color2.alpha, 1.0);
pub fn transparent(self) -> Color
[src]
Return a new color with all of the same values except with opacity (alpha) set to 0.0
use turtle::Color; let color = Color {red: 43.0, green: 79.0, blue: 23.0, alpha: 0.5}; assert_eq!(color.alpha, 0.5); let color2 = color.transparent(); assert_eq!(color.alpha, 0.5); assert_eq!(color2.alpha, 0.0);
pub fn with_alpha(self, alpha: f64) -> Color
[src]
Return a new color with alpha set to the given value
use turtle::Color; let color = Color {red: 43.0, green: 79.0, blue: 23.0, alpha: 0.5}; assert_eq!(color.alpha, 0.5); let color2 = color.with_alpha(0.2); assert_eq!(color.alpha, 0.5); assert_eq!(color2.alpha, 0.2);
Trait Implementations
impl Debug for Color
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
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 Copy 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 Rand for Color
[src]
fn rand<R: Rng>(rng: &mut R) -> Self
[src]
Generates a random instance of this type using the specified source of randomness. Read more