farver
A Rust converter to transform CSS colors. 🎨
Installation
Add the farver
crate to your Cargo.toml
's list of dependencies:
= "3.1.0"
farver
What is farver?
This crate allows you to create and manipulate colors using Less
functions, and to be able to use a common color type if you need
to convert to interact with multiple crates
The RGB color model is often useful when you'd like to represent a color using a certain amount of red, green, and blue.
); //
However, it is also possible to represent the same color using the HSL color model, which specifies the hue, saturation, and luminosity of a color:
); //
You can also use CSS preprocessors like Less to manipulate these colors in interesting ways.
$ ); // )
$ ); // )
$ ); // )
This crate allows you to perform operations that map to Less' color operations API. These operations can be applied on both RGB & HSL color models.
Examples
Represent colors as a valid CSS string:
use ;
let salmon = rgb;
let chartreuse = hsla;
assert_eq!;
assert_eq!;
Convert between different color model representations:
use ;
let chartreuse = rgb;
assert_eq!;
assert_eq!;
assert_eq!;
Manipulate single colors to create new color model representations:
use ;
let chartreuse = hsl;
assert_eq!;
assert_eq!;
assert_eq!;
Manipulate multiple colors to create new color model representations:
use ;
let chartreuse = hsl;
let red = rgba;
assert_eq!;
assert_eq!;
assert_eq!;
Check out the documentation to learn more about what color operations are available to use!
Helpful Links
The following links may be helpful while using this crate.
- CSS3's RGB color model
- CSS3's HSL color model
- Less' color operation functions
Contributing
Installation
git clone https://github.com/nyxkrage/farver
cd farver
cargo build
Linting + plugins
Please use the below tools to ensure code consistency when contributing to this crate.
- Rustfmt for formatting code style
Building + testing
cargo build
– Builds the cratecargo test
– Runs the test suite
License
This project is licensed under the ISC License.