Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to CSS color strings #446

Open
jlumpe opened this issue Oct 17, 2020 · 2 comments
Open

Convert to CSS color strings #446

jlumpe opened this issue Oct 17, 2020 · 2 comments

Comments

@jlumpe
Copy link

jlumpe commented Oct 17, 2020

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(...).

@kimikage
Copy link
Collaborator

kimikage commented Oct 17, 2020

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:

  1. 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.
  2. In auto-generated documents, there are needs for the shortest representation, but the :s/:S option of the hex() solved most of the demanded. There are only ~30 exceptions, such as red and indigo, and we can hardcode them easily.
  3. 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. 😄

@kimikage
Copy link
Collaborator

kimikage commented May 4, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants