"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
(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 In reply to Re: Convert RGB to an actual color
by Anonymous Monk
|
|