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

Comments

Projects
None yet
5 participants
@dilyanpalauzov
Copy link

commented Jun 25, 2018

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

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

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

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

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

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

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

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

Copy link
Author

commented Jun 29, 2018

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

This comment has been minimized.

Copy link
Member

commented Jul 2, 2018

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

@svgeesus

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2018

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

@svgeesus svgeesus closed this Jul 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.