-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
bevy_color: adding 'palettes' module. #12067
Conversation
Two palettes are added: - Basic: A basic palette with 16 colors. - X11: A palette with the colors from the X11/HTML4.0 color names.
@@ -0,0 +1,38 @@ | |||
//! Named colors from the CSS1 specification, also known as | |||
//! [basic colors](https://en.wikipedia.org/wiki/Web_colors#Basic_colors). | |||
//! This is the same set of colors as VGA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VGA should be spelled out, and a link would be nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a link. I don't want to spell it out because the name "video graphics array" is actually confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like namespacing color palettes like this :) And it'll ease the migration. However, I really think we should avoid committing Python code in order to avoid complicating the developer experience.
We should either remove it completely, or swap it for a simple Rust equivalent.
I'm not personally familiar with the x11 naming and it seems to me like more people would understand if it was called css instead. As in, name the palette css so people can do It's very possible it's just a me thing though. |
@@ -0,0 +1,301 @@ | |||
//! [Extended colors from the CSS4 specification](https://en.wikipedia.org/wiki/Web_colors#Extended_colors), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, we should link to the spec
https://www.w3.org/TR/css-color-4/#named-colors
Removed python code and changed x11 -> css. |
Out of curiosity, how much precision is actually needed here? This certainly seems like enough at a glance, just curious.
Any reason not to just use the original integer values here? Or consistently format with 1 decimal.
|
@rparrett My python script rounded everything to the nearest thousandth to make the code prettier. I figured one part in a thousand would be imperceptible to the human eye. I don't really have an opinion otherwise. |
Seems like thousandths are good enough, hundredths would not be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. The concept of a colour palette is distinct from the colour types themselves, so I like putting them in separate modules. Also opens up the possibility of adding more palettes with colliding names (e.g. blue in Tailwind might not be the same blue in basic, etc.)
Two palettes are added: - Basic: A basic palette with 16 colors. - CSS: A palette with the colors from the "extended CSS"/X11/HTML4.0 color names.
Two palettes are added: - Basic: A basic palette with 16 colors. - CSS: A palette with the colors from the "extended CSS"/X11/HTML4.0 color names.
Just an interesting data point regarding float precision: Old crimson:
New crimson:
The increased precision resulted in CI picking up a color change in examples using Seeing what I assume is the same situation in the Neat. |
Yeah, the new colors actually match CSS4 values, to three decimals I believe. They were machine-generated via a Python script originally. |
Yeah, I had previously commented on the precision. Just commenting here to confirm that yes, the third decimal matters. |
I saved a copy of the script, but it's not checked in anywhere. The actual colors were cut and pasted from the CSS standard website, and then converted into Rust source code. |
Just to be totally clear, I am saying that things are better now with the increased precision. |
Here's a Gist containing the Python script I used to generate the color palettes: https://gist.github.com/viridia/0143965eaa7805145a115b85b04b79fd |
Two palettes are added: