W3C home > Mailing lists > Public > public-css-archive@w3.org > June 2018

[csswg-drafts] Convert RGB to the closest representation with name

From: Дилян Палаузов via GitHub <sysbot+gh@w3.org>
Date: Mon, 25 Jun 2018 21:15:22 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-335570584-1529961321-sysbot+gh@w3.org>
dilyanpalauzov has just created a new issue for https://github.com/w3c/csswg-drafts:

== Convert RGB to the closest representation with name ==
[RFC 7986 New Properties for iCalendar](https://tools.ietf.org/html/rfc7986#section-5.9) 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?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2813 using your GitHub account
Received on Monday, 25 June 2018 21:15:30 UTC

This archive was generated by hypermail 2.3.1 : Monday, 25 June 2018 21:15:31 UTC