A Rust implementation of HSLuv.
Demo

Demo link: http://www.hsluv.org/syntax/#006925
Installation
Add this line to your application's Cargo.toml:
[]
= "0.1.2"
Usage
hueis a 64bit float between 0 and 360saturationis a 64bit float between 0 and 100lightnessis a 64bit float between 0 and 100hexis the hexadecimal format of the colorredis a 64bit float between 0 and 1greenis a 64bit float between 0 and 1blueis a 64bit float between 0 and 1
extern crate hsluv;
use *;
All API calls take and return a 3-tuple of 64bit floats, (f64, f64, f64) except the *_to_hex() functions: hsluv_to_hex(), hpluv_to_hex(), rgb_to_hex() which return String.
hsluv::hsluv_to_hex((hue, saturation, lightness)) -> color as a hex string
hsluv_to_hex // => #ff0000
hsluv::hsluv_to_rgb((hue, saturation, lightness)) -> color as rgb
hsluv_to_rgb // => (0.9998643703868711, 0.00000000000006849859221502719, 0.000008791283550555612)
hsluv::hex_to_hsluv(hex) -> list of floats as defined above
hex_to_hsluv // => (12.177050630061776, 100.0000000000022, 53.23711559542933)
hsluv::rgb_to_hsluv(rgb) -> list of floats as defined above
rgb_to_hsluv // => (12.17705063006216, 100.00000000000209, 52.711595266911985)
For HPLuv (the pastel variant), use:
hpluv_to_hexhpluv_to_rgbhex_to_hpluvrgb_to_hpluv
Testing
Run cargo test.
Contributing
- Fork it ( http://github.com/dvdplm/hsluv-rust )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request