tags:

views:

272

answers:

2

Hello all,

I have come across this great function/command. Colour to RGB, you can do this:

col2rgb("peachpuff")
//returns hex

It will return one hex value. I want to extend this using Perl, Python or PHP but I want to be able to pass in, for example, "yellow" and the function returns all types of yellows - their hex/rgb/?/etc value.

I already have a quick solution implemented, which involves mapping colour names to hex values but now I want to get more precise and use some formulas etc to determine what's what.

However, as usual, I don't have a clue on how to do this! So I appreciate any implementation advice on how to do this.

Thanks all

A: 

Why don't you use the ccs Color names. W3c webstandard --> CSS3/SVG Farben

donkey
I am making use of a similar mapping already but it will return only one value. Not other similar colours or the yellow or green colour of families, if i passed in yellow or green.
Abs
+1  A: 

The canonical CSS color names originated in X11 and the intersection of the sets - along with their RGB values can be - found at Wikipedia.

A more easily parsed list can be found in various rgb.txt files scattered over the web, but these are likely the X11 set not the CSS set.

added: Given an RGB value you can compute nearby colors by HSL conversion. Color palettes - sets of colors that go well together - are an art not a science, Google 'em.

msw
I am making use of a similar mapping already but it will return only one value. Not other similar colours or the yellow or green colour of families, if i passed in yellow or green.
Abs
If "yellow" is in-putted, return all other yellows that exist. This isn't a colour palette!! I had a look at that page already today - it didn't seem to find nearby colors, I'll have a look again, maybe the maths is a bit difficult for me.
Abs
`grep yellow rgb.txt` will do what I think you are asking, but it will give poor results because many color-names that you might call "yellow" don't have "yellow" in their names. You probably need to read up on what color means to better understand the question you are trying to ask. The idea "yellows" is more complicated than we normally think.
msw