Colors.jl
Colors.jl copied to clipboard
Convert to CSS color strings
We have hex(::Colorant)
, but it would be nice to have functions to convert colors to the other formats accepted by parse
, specifically CSS's rgb(...)
, rgba(...)
, and hsl(...)
.
As long as the names of that new functions do not cause confusion, I think it's a good idea to add them. Would you like to submit a PR?
FWIW, here's why just "I" didn't really tackle the conversion to CSS notations in Colors.jl:
- Many tools support the interactive visualization of hex notation today (e.g.
#C0FFEE
) and there is little benefit in using function notation in auto-generated documents. - In auto-generated documents, there are needs for the shortest representation, but the
:s
/:S
option of thehex()
solved most of the demanded. There are only ~30 exceptions, such asred
andindigo
, and we can hardcode them easily. - Any conversion to function notation can be written in a few lines of script. On the other hand, function notation has some preferences (e.g. number of significant digits), and there is no easy way to specify them.
The only technical challenge is "3.". For example, using the printf
format is nonsense, because you can use the @printf
. :smile:
Development of Colors v0.13 series has started. Although any new features can be added in v0.13.x, it is preferable that they are included in the v0.13.0 release.
@jlumpe (or anyone else who wants to add this feature), please propose a design for the API. As mentioned above, I don't have a good idea about the API.