Luv
Tools for converting colours between sRGB, L*u*v* and LCh(uv) colour spaces and comparing differences in colour.
sRGB colors, for this crate at least, are considered to be composed of u8
values from 0 to 255, while L*u*v* colors are represented by its own
struct that uses f32 values. The crate is biased towards sRGB thus it
also assumes that L*u*v* uses D65 reference white point.
Usage
Converting single values
To convert a single value, use one of the functions
luv::Luv::from_rgb(rgb: &[u8; 3]) -> Luvluv::Luv::from_rgba(rgba: &[u8; 4]) -> Luv(drops the fourth alpha byte)luv::Luv::to_rgb(&self) -> [u8; 3]
let pink = from_rgb;
assert_eq!;
Converting multiple values
To convert slices of values
luv::rgbs_to_luvs(rgbs: &[[u8; 3]]) -> Vec<Luv>luv::luvs_to_rgbs(luvs: &[Luv]) -> Vec<[u8; 3]>luv::rgb_bytes_to_luvs(bytes: &[u8]) -> Vec<Luv>luv::luvs_to_rgb_bytes(luvs: &[Luv]) -> Vec<u8>
let rgbs = vec!;
let luvs = rgbs_to_luvs;
use rgb_bytes_to_luvs;
let rgbs = vec!;
let luvs = rgb_bytes_to_luvs;
Features
The crate defines an approx feature. If enabled, approximate
equality as defined by approx
crate will be implemented for the
Luv and LCh types.
Other crates
The design — and to some degree code — of this crate has been based on the
lab crate which provides routines for
converting colours between sRGB, L*a*\b and LCh(ab) colour spaces.
For conversion between sRGB and XYZ colour spaces this crate relies on the
srgb crate.