(1) If you want meaningful
names ... There's a file rgb.txt
floating around the net with standard names in RGB space. It was originally distributed by the X Windows consortium, found in /usr/lib/X11/rgb.txt if you have one. If you initialize your GD palette with those, and remember the color#->name map after each, you can then use colorClosest() to find the closest name. Warning: You'll need to use the TrueColor option otherwise the 897 colors will overflow your 256 color palette.
You're in luck, CPAN is having a special on rgb.txt: "Color::Rgb - Simple rgb.txt parsing class". The CPAN TGZ includes Rgb.pm and rgb.txt.
(2) Or if you want geometric generalizations and want to code it yourself, Color::Object handles HSV/HSL/RGB conversions, and can give you something not unlike angles in colorspace that you could round, interpret, and convert back.
For background on colorspace stuff and all sorts of graphics processing, check out the Graphic Gems series and source archive and the successor journal jgt. They speak C over there, but it's easily transliterated.
-- bill n1vux
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||