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 RGB to the closest representation with name #2813

Closed
dilyanpalauzov opened this issue Jun 25, 2018 · 7 comments
Closed

Convert RGB to the closest representation with name #2813

dilyanpalauzov opened this issue Jun 25, 2018 · 7 comments
Labels
Closed Rejected as Invalid Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits.

Comments

@dilyanpalauzov
Copy link

RFC 7986 New Properties for iCalendar introduces a COLOR property and according to my reading the value can only be a color name, hence no RGB.

A possible UI would be, rathat than offering a mega big box of distinct possible colorus, to let the user choose any RGB colour and then convert the choice to the nearest colour that has text representation.

The question is how to calculate the nearest RGB with a text representation to a given RGB.

At first I thought that the colours listed at https://drafts.csswg.org/css-color/#named-colors have equal distance, so it is just a matter of converting each color component to the closest value that can be divided by e.g. 8. But the list contains only two values starting with #3:

limegreen #32CD32 | 50 205 50
mediumseagreen | #3CB371 | 60 179 113

but with #2 more colours start:
darkslategray | #2F4F4F | 47 79 79
forestgreen | #228B22 | 34 139 34
lightseagreen | #20B2AA | 32 178 170
seagreen | #2E8B57 | 46 139 87

So the jumps in the colours are not normed.

Isn't it better to adjust the text representations for have equal distances between each other? E.g. each R-G-B component can have distinct values: 0, 4, 8, C or alike?

What would be the current procedure to convert arbitraty RGB to the closest colour representable as text?

@svgeesus
Copy link
Contributor

At first I thought that the colours listed at https://drafts.csswg.org/css-color/#named-colors have equal distance

No, not at all. They are a historical and somewhat random set, not in the slightest evenly distributed.

@svgeesus
Copy link
Contributor

Isn't it better to adjust the text representations for have equal distances between each other?

You mean, keeping the names but changing the colors they represent? No, that would not be web compatible at all.

Also, even spacing in RGB space is not the same as evenly spaced visually.

@AmeliaBR
Copy link
Contributor

If RFC 7986 is not finalized yet, perhaps you could recommend that they accept a more flexible color definition, such as hex code. As @svgeesus notes, the named colors in CSS do not represent any kind of consistent color system, and there are many regions of the RGB cube (or any other color space) which aren't well represented.

Otherwise, your best approach for a usable UI might be to create a subset of the named colors which represent an attractive and well-balanced palette. But of course, for interoperability, you'd still need to support the full set of names.

@frivoal
Copy link
Collaborator

frivoal commented Jun 27, 2018

They are a historical and somewhat random set

If anyone looking for more, this humorous presentation will tell you more than you ever wanted to know: http://christopher.org/history-web-color-names/

@dilyanpalauzov
Copy link
Author

The RFC is finalized, but I am going to propose errata to it:

https://www.ietf.org/mail-archive/web/calsify/current/msg03048.html

@tabatkins
Copy link
Member

Yes, please, using the CSS color names is a terrible idea and I strongly recommend against spreading those any farther than absolutely necessary.

@svgeesus svgeesus added Closed Rejected as Invalid Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. labels Jul 4, 2018
@svgeesus
Copy link
Contributor

svgeesus commented Jul 4, 2018

Closing as issue is against RFC 7986 and original poster has filed issue against that specification.

@svgeesus svgeesus closed this as completed Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Rejected as Invalid Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits.
Projects
None yet
Development

No branches or pull requests

5 participants