[−][src]Trait colorsys::ColorTransform
A collection of methods to some special modification of color. Some methods (like saturate, lighten, etc.) requires (inside implementation) converting to another color space and converting back.
Required methods
fn lighten(&mut self, amt: f64)
Makes color lighter or (if amt is negative) darker.
Amt is percent - 1..100
to make color lighter; -100..-1
for blacking-out
fn saturate(&mut self, sat: SaturationInSpace)
Saturate/desaturate color.
Value is percent: -100..100
.
You need specify in what color space you want to increase/decrease saturation.
fn adjust_hue(&mut self, hue: f64)
increase/decrease color tone. Value is degree - -360..360
.
fn grayscale_simple(&mut self)
Brings color to a shade of gray. For more specific grayscale methods see Rgb.grayscale
fn invert(&mut self)
Just inverts color
Implementors
impl ColorTransform for Hsl
[src]
fn lighten(&mut self, amt: f64)
[src]
fn saturate(&mut self, sat: SaturationInSpace)
[src]
fn adjust_hue(&mut self, hue: f64)
[src]
fn grayscale_simple(&mut self)
[src]
fn invert(&mut self)
[src]
impl ColorTransform for Rgb
[src]
fn lighten(&mut self, amt: f64)
[src]
Lighten or darken color. amt is a percent with negative values - -100..100
Example
use colorsys::{Rgb,ColorTransform, ColorTuple}; let tuple = (30.0, 108.0, 77.0); let mut rgb = Rgb::from(&tuple); rgb.lighten(20.0); assert_eq!(rgb.to_css_string(), "rgb(52,188,134)" ); rgb.lighten(-20.0); assert_eq!(rgb.to_css_string(), "rgb(30,108,77)" ); rgb.lighten(-20.0); assert_eq!(rgb.to_css_string(), "rgb(8,28,20)" ); rgb.lighten(301.123); assert_eq!(rgb.to_css_string(), "rgb(255,255,255)" );