in reply to Best way to validate a string as a color?
It seems to me that I could compare with names from the list which on my Linux machine is in /usr/share/X11/rgb.txt (and add a check for colors of the form #rrggbb, no reason to exclude those). Can I expect that list to be standard on all systems (Linux, Windows, Macs)? Even if it is standard, is that the best way to do it?
Yes, /usr/share/X11/rgb.txt should be part of standard X11, so you should be able to use it on (almost) any Unix system running X11. Windows is something completely different. You won't find the /usr/share/X11 on a native Windows. MacOS X inherits from Unix, but does many things differently. AFAIK, you can run X11 on MacOS X, but it does not run X11 out of the box.
I doubt the content of rgb.txt changes very much, so a quick and dirty way would be to include that file with your program. On the other hand, some part of Perl/Tk must be able to handle colors even on Windows and MacOS X. So, maybe call a Tk method to convert a string to a color and check if it fails.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Best way to validate a string as a color?
by kcott (Archbishop) on Oct 18, 2017 at 04:32 UTC | |
|
Re^2: Best way to validate a string as a color?
by pra (Initiate) on Oct 18, 2017 at 11:20 UTC |