csscolorparser-rs
csscolorparser-rs copied to clipboard
Rust CSS color parser library
I also added the lighten and darken HSLA methods from [TinyColor](https://github.com/bgrins/TinyColor/blob/master/tinycolor.js#L581C3-L587C4)
The `.repeat()` calls allocate a `String`, instead it's possible to parse the single digit into an `u8` and then repeat the hex value with bitwise operations.
From https://www.w3.org/TR/css-color-4/#predefined-xyz, these are exactly equivalent: ``` #7654CD rgb(46.27% 32.94% 80.39%) lab(44.36% 36.05 -58.99) ``` But the test is fails for lab. https://github.com/mazznoer/csscolorparser-rs/blob/a213f2b62388db7abf6b1dd132cda4afb77f6993/tests/parser.rs#L47-L64
Hi would you be open to provide a From csscolor for [ratatui::style::color](https://docs.rs/ratatui/latest/ratatui/style/enum.Color.html) implementation behind a feature? To convert from your color type to ratatui color. That way it would be...
Example: ``` rgb(from red r g b) hwb(from red calc(h + 15) w b) etc. ```
This is a continuation of #19 Also adds the HSLA lighten and darken methods.
It would be nice to have an alternative gamut clipping method like described in https://bottosson.github.io/posts/gamutclipping/ Clamping often gives unintended results. I'd be happy to try implementing this and sending in...
Examples: ``` rgb(200 none 0) rgb(none 90% 35%) hwb(none 0% 50%) ```