diff options
author | Manoj Srivastava <srivasta@debian.org> | 2008-02-07 22:52:10 +0000 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2008-02-07 22:52:10 +0000 |
commit | 19e85b18785ee11ea3f3f957f16dcd6522d249ec (patch) | |
tree | d15ce7ad6d38d5801172872b42bf076e97ac4ca9 | |
parent | 4a8efbf6e13bc47fc7a54d0d981d8d2c3c99b56c (diff) |
Imported Graphics-ColorNames-2.11
Imported Graphics-ColorNames-2.11
into srivasta@debian.org--lenny/libgraphics-colornames-perl--upstream--2.0
git-archimport-id: srivasta@debian.org--lenny/libgraphics-colornames-perl--upstream--2.0--patch-1
-rwxr-xr-x[-rw-r--r--] | Build.PL | 68 | ||||
-rwxr-xr-x[-rw-r--r--] | Changes | 312 | ||||
-rw-r--r-- | MANIFEST | 53 | ||||
-rw-r--r-- | META.yml | 89 | ||||
-rw-r--r-- | Makefile.PL | 41 | ||||
-rw-r--r-- | README | 207 | ||||
-rw-r--r-- | SIGNATURE | 48 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/Graphics/ColorNames.pm | 1308 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/Graphics/ColorNames/HTML.pm | 12 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/Graphics/ColorNames/Netscape.pm | 43 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/Graphics/ColorNames/Windows.pm | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | lib/Graphics/ColorNames/X.pm | 1547 | ||||
-rw-r--r-- | lib/Graphics/ColourNames.pm | 65 | ||||
-rw-r--r-- | t/00-Prereqs.t | 8 | ||||
-rw-r--r-- | t/00-pod-coverage.t | 15 | ||||
-rw-r--r-- | t/01-ColorNames.t | 67 | ||||
-rw-r--r-- | t/01-ColourNames.t | 77 | ||||
-rw-r--r-- | t/01-version.t | 13 | ||||
-rw-r--r-- | t/02-X.t | 14 | ||||
-rw-r--r-- | t/05-Netscape.t | 9 | ||||
-rw-r--r-- | t/06-obj.t | 31 | ||||
-rw-r--r-- | t/07-file.t | 2 | ||||
-rw-r--r-- | t/08-filehandle.t | 77 | ||||
-rw-r--r-- | t/09-colorlibrary.t | 37 | ||||
-rw-r--r-- | t/10-sub.t | 32 | ||||
-rw-r--r-- | t/90-file-port.t | 13 | ||||
-rw-r--r-- | t/90-pod-coverage.t | 17 | ||||
-rw-r--r-- | t/90-pod.t (renamed from t/00-pod.t) | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | t/rgb.txt | 0 |
29 files changed, 2306 insertions, 1909 deletions
@@ -1,27 +1,41 @@ -use Module::Build;
-
-my $build = Module::Build->new
- (
- module_name => 'Graphics::ColorNames',
- license => 'perl',
- requires => {
- 'perl' => '5.6.0',
- 'base' => 0,
- 'Carp' => 0,
- 'IO::File' => 0,
- 'Module::Load' => 0.10,
- },
- recommends => {
- 'Pod::Coverage' => 0,
- 'Test::Pod' => 1.00,
- 'Test::Prereq' => 0,
- },
- build_requires => {
- 'Test::More' => 0,
- },
- create_makefile_pl => 'traditional',
- dist_author => 'Robert Rothenberg <rrwo at cpan.org>',
- sign => 1,
-);
-
-$build->create_build_script;
+use Module::Build; + +my $build = Module::Build->new + ( + module_name => 'Graphics::ColorNames', + license => 'perl', + requires => { + 'perl' => '5.006', + 'base' => 0, +# 'AutoLoader' => 0, + 'Carp' => 0, + 'DirHandle' => 0, + 'Exporter' => 0, + 'File::Spec' => 0, + 'IO::File' => 0, + 'Module::Load' => '0.10', + 'Module::Loaded' => 0, + }, + recommends => { + 'Color::Library' => 0.02, + 'Tie::Sub' => 0, + 'Test::Pod::Coverage' => 0, + 'Test::Pod' => 1.00, + 'Test::Portability::Files' => 0, + 'Pod::Readme' => 0.09, + }, + build_requires => { + 'FileHandle' => 0, # for testing + 'Test::Exception' => 0, + 'Test::More' => 0, + }, +# autosplit => [ +# 'lib/Graphics/ColorNames.pm', +# ], + create_readme => ($Module::Build::VERSION >= 0.2702), + create_makefile_pl => 'traditional', + dist_author => 'Robert Rothenberg <rrwo at cpan.org>', + sign => 0, +); + +$build->create_build_script; @@ -1,104 +1,208 @@ -Revision history for Perl extension Graphics::ColorNames.
-
-1.06 Tue Mar 29 2005
- - cleaned up tests
- - added DSLIP information to POD
- - added Test::Pod tests
- - added Pod::Coverage tests
- - minor documentation changes
- - uses Test::Prereq to test distro prereqs
- - added SIGNATURE to distribution
-
-1.05 Fri Sep 3 2004
- - correction to Graphics::ColourNames
- - correction to README
-
-1.04 Fri Sep 3 2004
- - updates to POD
- - a filehandle for a rgb.txt file can be specified
-
-1.03 Thu Aug 26 2004
- - hooks to support CODE scheme types (as with module
- Graphics::ColorNames::GrayScale 2.00)
- - ColourNames.pm has same version of ColorNames.pm
-
-1.02 Tue Aug 24 2004
- - added Graphics::ColourNames alias
- - minor changes to ColorNames.pm
-
-1.01 Wed Aug 18 2004
- - corrected typo in REQUIREMENTS (wrong Perl version)
- - uses Module::Load for improved dynamic loading
- - EXISTS works across multiple color schemes
- - bug in FETCH that returned key has been fixed
-
-1.00 Sat Jul 31 2004
- - changed version to 1.00 as release appears to be stable
- - corrected bad link in POD
-
-0.39_04 Mon Jul 26 2004
- - rebuilt distribution with proper META.yml
-
-0.39_03 22 Jul 2004
- - added required rgb.txt for tests to MANIFEST and distro
-
-0.39_02 22 Jul 2004
- * now requires Perl 5.6.0
- - uses IO::File
- - option to parse an rgb.txt file
- - removed TODO from distribution
- - Netscape.pm, HTML.pm and Windows.pm warnings enabled
- - additions and corrections in POD
-
-0.39_01 21 Jul 2004
- - added Build.PL to distribution
- - added hex() and rgb() methods
- - created object-oriented interface
- - additions and corrections in POD
-
-0.32 5 Dec 2002
- - fixed inconsistencies with grey/gray spellings in X.pm
- - added note in POD about using rt.cpan.org for bug reports
- - minor changes in POD for Netscape.pm
- - added TODO file
-
-0.31 23 Oct 2002
- - fixed mispelling of "fuchsia" in HTML.pm
-
-0.30 4 Oct 2001
- - fixed bug with non-existent color names
- - corrected some typos in and updated the documentation
- - added multiple color naming schemes
- - when passed a value in the form of '#000000', returns that value
-
-0.24 28 Apr 2001
- - fixed colors in X.pm (such as some 'green') defined as 0x000000
- - removed duplicate grays (ie, 'gray0') from X.pm
- - renamed test suite files to enforce testing order
- - v0.23 mistakenly dated 17 Mar instead of 17 April
-
-0.23 17 Apr 2001
- - X-Windows color names now from rgb.txt (includes names with
- spaces, such as 'alice blue' as well as 'aliceblue')
- - Added Netscape color naming scheme
-
-0.22 15 Mar 2001
- - added example on how to add your own naming schema
- - schema files (X.pm, HTML.pm, Windows.pm) were stored in the
- wrong subdirectories
- - removed test.pl and double-testing
-
-0.21 12 Mar 2001
- - fixed an issue with Test::Harness expecting t/*.t tests
-
-0.20 11 Mar 2001
- - no longer a Tie::Hash
- - additional example in POD
- - added Test::Harness and a better test suite
- - commented-out 'use warnings' in modules
- - addition of tuple2hex function
- - changed the way files are included in the distribution
-
-0.10 19 Feb 2001
- - original (experimental) version released
-
+Revision history for Perl extension Graphics::ColorNames (with significant +updates noted by asterisks, '*'): + +2.11 Thu Jan 10 2008 + - updated version number for release + - minor changes of text format + - added fix for problems with Graphics::ColorNames::GrayScale + +2.10_05 Tue Jan 8 2008 + * checks if modules already loaded before re-loading them + (uses Module::Loaded for this) + - requires changed to load for dynamically loaded modules + - updated README + +2.10_04 Sun Jan 6 2008 + - reverted back to standard object-oriented style + - Tie::Sub is only loaded when a subroutine is used for scheme + +2.10_03 Sat Jan 5 2008 + - tests use Test::Exception to catch errors + - rewrite parts of documentation to emphasize object-oriented + interface rather than the tied interface + - implemented a proper DESTROY method + - misc code cleanup and reorganization + +2.10_02 Fri Jan 4 2008 + * added support for Color::Library dictionaries + - minor changes to error messages + - underscores in color names ignored + - auto-loading color names in object-oriented interface, e.g. + $obj->black() + - stubs for DESTROY and UNTIE methods + - 06-obj.t test more flexible + - pointless 01-ColourNames test removed + - more updates to documentation + +2.10_01 Thu Dec 20 2007 + * non-word characters (spaces, punctuation) now ignored in + color names + * smarter handling of comments in rgb.txt files + * significant rewrite to parts of the code, requires Tie::Sub + * rewritten how FIRSTKEY and NEXTKEY methods work + - better error handling + - minor updates to documentation + - typos in comments + - added better checking for minimum Perl version reqs + - added aliaes w/out punctuation in Netscape scheme + +2.04 Mon Dec 17 2007 + - fixed inconsistencies in Netscape color scheme + +2.03 Mon Dec 17 2007 + - fixed glitch with version test + - cleaned up format of text files + - removed unneeded dependency + +2.02 Sun Dec 16 2007 + - renamed developer-related test scripts + - removed 90-prereqs.t (it wasn't working properly sometimes) + - added DEVEL_TESTS environment variable as requirement for + developer tests + - README generated from POD using Pod::Readme + +2.01 Sun Dec 16 2007 + - Changed versions of specific color schemes to match main module + * Removed Graphics::ColourNames from the distribution + - updated documentation for Netscape.pm + +2.0_04 Tue Oct 24 2006 + - fixed Pod::Coverage tests (RT#20923) + - various optimizations + - changed to use inside-out object scheme + - no longer signing code (too many problems w/Module::Signature) + +2.0_03 Fri Apr 8 2005 + - fixed bug with reading scheme from FileHandle type + - fixed glitch in pod-coverage test + - corrected version in Graphics::ColourNames + - added tests to check versions in sync + +2.0_02 Thu Apr 7 2005 + - lesser-used routines made into autoloaded methods + - added Test::Portabiity::Files test + - minor updates for Netscape theme + - added support for :utility export tag + - added support for :all export tag + +2.0_01 Mon Apr 4 2005 + - removed DSLIP information from POD, since it has little meaning + - tweaked code + - color scheme can be a module name + - fixed bug in Pod::Coverage test, uses Test::Pod::Coverage + * major change in how schemes are stored, which affects priority + when CODE scheme types are used + - can load rgb.txt from GLOB, FileHandle or IO::File + - references can be specified as possible schemes in constructor + - added public load_scheme method + - various optimizations and tweaks + - IO::File is loaded only as needed + - rgb.txt file must be radable to be loaded + - tweaked tests + - RGB passthrough now consistently returns lowercase values + - minor optimization in FETCH for RGB passthrough + - added all_schemes function to query schemes + +1.06 Tue Mar 29 2005 + - cleaned up tests + - added DSLIP information to POD + - added Test::Pod tests + - added Pod::Coverage tests + - minor documentation changes + - uses Test::Prereq to test distro prereqs + - added SIGNATURE to distribution + +1.05 Fri Sep 3 2004 + - correction to Graphics::ColourNames + - correction to README + +1.04 Fri Sep 3 2004 + - updates to POD + - a filehandle for a rgb.txt file can be specified + +1.03 Thu Aug 26 2004 + - hooks to support CODE scheme types (as with module + Graphics::ColorNames::GrayScale 2.00) + - ColourNames.pm has same version of ColorNames.pm + +1.02 Tue Aug 24 2004 + - added Graphics::ColourNames alias + - minor changes to ColorNames.pm + +1.01 Wed Aug 18 2004 + - corrected typo in REQUIREMENTS (wrong Perl version) + - uses Module::Load for improved dynamic loading + - EXISTS works across multiple color schemes + - bug in FETCH that returned key has been fixed + +1.00 Sat Jul 31 2004 + - changed version to 1.00 as release appears to be stable + - corrected bad link in POD + +0.39_04 Mon Jul 26 2004 + - rebuilt distribution with proper META.yml + +0.39_03 22 Jul 2004 + - added required rgb.txt for tests to MANIFEST and distro + +0.39_02 22 Jul 2004 + * now requires Perl 5.6.0 + - uses IO::File + - option to parse an rgb.txt file + - removed TODO from distribution + - Netscape.pm, HTML.pm and Windows.pm warnings enabled + - additions and corrections in POD + +0.39_01 21 Jul 2004 + - added Build.PL to distribution + - added hex() and rgb() methods + - created object-oriented interface + - additions and corrections in POD + +0.32 5 Dec 2002 + - fixed inconsistencies with grey/gray spellings in X.pm + - added note in POD about using rt.cpan.org for bug reports + - minor changes in POD for Netscape.pm + - added TODO file + +0.31 23 Oct 2002 + - fixed mispelling of "fuchsia" in HTML.pm + +0.30 4 Oct 2001 + - fixed bug with non-existent color names + - corrected some typos in and updated the documentation + - added multiple color naming schemes + - when passed a value in the form of '#000000', returns that value + +0.24 28 Apr 2001 + - fixed colors in X.pm (such as some 'green') defined as 0x000000 + - removed duplicate grays (ie, 'gray0') from X.pm + - renamed test suite files to enforce testing order + - v0.23 mistakenly dated 17 Mar instead of 17 April + +0.23 17 Apr 2001 + - X-Windows color names now from rgb.txt (includes names with + spaces, such as 'alice blue' as well as 'aliceblue') + - Added Netscape color naming scheme + +0.22 15 Mar 2001 + - added example on how to add your own naming schema + - schema files (X.pm, HTML.pm, Windows.pm) were stored in the + wrong subdirectories + - removed test.pl and double-testing + +0.21 12 Mar 2001 + - fixed an issue with Test::Harness expecting t/*.t tests + +0.20 11 Mar 2001 + - no longer a Tie::Hash + - additional example in POD + - added Test::Harness and a better test suite + - commented-out 'use warnings' in modules + - addition of tuple2hex function + - changed the way files are included in the distribution + +0.10 19 Feb 2001 + - original (experimental) version released + + @@ -1,27 +1,26 @@ -Build.PL
-Changes
-Makefile.PL
-MANIFEST
-META.yml
-README
-t/00-Prereqs.t
-t/00-pod-coverage.t
-t/00-pod.t
-t/01-ColorNames.t
-t/01-ColourNames.t
-t/02-X.t
-t/03-HTML.t
-t/04-Windows.t
-t/05-Netscape.t
-t/06-obj.t
-t/07-file.t
-t/08-filehandle.t
-t/rgb.txt
-lib/Graphics/ColorNames.pm
-lib/Graphics/ColorNames/HTML.pm
-lib/Graphics/ColorNames/Netscape.pm
-lib/Graphics/ColorNames/Windows.pm
-lib/Graphics/ColorNames/X.pm
-lib/Graphics/ColourNames.pm
-
-SIGNATURE Added here by Module::Build
+Build.PL +Changes +Makefile.PL +MANIFEST +META.yml +README +t/01-ColorNames.t +t/01-version.t +t/02-X.t +t/03-HTML.t +t/04-Windows.t +t/05-Netscape.t +t/06-obj.t +t/07-file.t +t/08-filehandle.t +t/09-colorlibrary.t +t/10-sub.t +t/90-file-port.t +t/90-pod-coverage.t +t/90-pod.t +t/rgb.txt +lib/Graphics/ColorNames.pm +lib/Graphics/ColorNames/HTML.pm +lib/Graphics/ColorNames/Netscape.pm +lib/Graphics/ColorNames/Windows.pm +lib/Graphics/ColorNames/X.pm @@ -1,39 +1,50 @@ ---- #YAML:1.0
-name: Graphics-ColorNames
-version: 1.06
-author:
- - Robert Rothenberg <rrwo at cpan.org>
-abstract: defines RGB values for common color names
-license: perl
-requires:
- Carp: 0
- IO::File: 0
- Module::Load: 0.1
- base: 0
- perl: 5.6.0
-recommends:
- Pod::Coverage: 0
- Test::Pod: 1
- Test::Prereq: 0
-build_requires:
- Test::More: 0
-provides:
- Graphics::ColorNames:
- file: lib/Graphics/ColorNames.pm
- version: 1.06
- Graphics::ColorNames::HTML:
- file: lib/Graphics/ColorNames/HTML.pm
- version: 1.11
- Graphics::ColorNames::Netscape:
- file: lib/Graphics/ColorNames/Netscape.pm
- version: 1.05
- Graphics::ColorNames::Windows:
- file: lib/Graphics/ColorNames/Windows.pm
- version: 1.03
- Graphics::ColorNames::X:
- file: lib/Graphics/ColorNames/X.pm
- version: 1.06
- Graphics::ColourNames:
- file: lib/Graphics/ColourNames.pm
- version: 1.06
-generated_by: Module::Build version 0.2607
+--- +name: Graphics-ColorNames +version: 2.11 +author: + - 'Robert Rothenberg <rrwo at cpan.org>' +abstract: defines RGB values for common color names +license: perl +resources: + license: http://dev.perl.org/licenses/ +requires: + Carp: 0 + DirHandle: 0 + Exporter: 0 + File::Spec: 0 + IO::File: 0 + Module::Load: 0.10 + Module::Loaded: 0 + base: 0 + perl: 5.006 +build_requires: + FileHandle: 0 + Test::Exception: 0 + Test::More: 0 +recommends: + Color::Library: 0.02 + Pod::Readme: 0.09 + Test::Pod: 1 + Test::Pod::Coverage: 0 + Test::Portability::Files: 0 + Tie::Sub: 0 +provides: + Graphics::ColorNames: + file: lib/Graphics/ColorNames.pm + version: 2.11 + Graphics::ColorNames::HTML: + file: lib/Graphics/ColorNames/HTML.pm + version: 2.11 + Graphics::ColorNames::Netscape: + file: lib/Graphics/ColorNames/Netscape.pm + version: 2.11 + Graphics::ColorNames::Windows: + file: lib/Graphics/ColorNames/Windows.pm + version: 2.11 + Graphics::ColorNames::X: + file: lib/Graphics/ColorNames/X.pm + version: 2.11 +generated_by: Module::Build version 0.2808 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.2.html + version: 1.2 diff --git a/Makefile.PL b/Makefile.PL index 90699e1..aa7951c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,17 +1,24 @@ -# Note: this file was auto-generated by Module::Build::Compat version 0.03
-use ExtUtils::MakeMaker;
-WriteMakefile
-(
- 'NAME' => 'Graphics::ColorNames',
- 'VERSION_FROM' => 'lib/Graphics/ColorNames.pm',
- 'PREREQ_PM' => {
- 'Carp' => '0',
- 'IO::File' => '0',
- 'Module::Load' => '0.1',
- 'Test::More' => '0',
- 'base' => '0'
- },
- 'INSTALLDIRS' => 'site',
- 'PL_FILES' => {}
- )
-;
+# Note: this file was auto-generated by Module::Build::Compat version 0.03 +use ExtUtils::MakeMaker; +WriteMakefile +( + 'PL_FILES' => {}, + 'INSTALLDIRS' => 'site', + 'NAME' => 'Graphics::ColorNames', + 'EXE_FILES' => [], + 'VERSION_FROM' => 'lib/Graphics/ColorNames.pm', + 'PREREQ_PM' => { + 'base' => 0, + 'Test::Exception' => 0, + 'IO::File' => 0, + 'File::Spec' => 0, + 'FileHandle' => 0, + 'Exporter' => 0, + 'Carp' => 0, + 'Test::More' => 0, + 'Module::Loaded' => 0, + 'Module::Load' => '0.10', + 'DirHandle' => 0 + } + ) +; @@ -1,72 +1,135 @@ -NAME
- Graphics::ColorNames - defines RGB values for common color names
-
-REQUIREMENTS
- `Graphics::ColorNames' should work on Perl 5.6.0.
-
- It requires the following non-standard modules:
-
- Module::Load
-
- Installation
-
- Installation is pretty standard:
-
- perl Makefile.PL
- make
- make test
- make install
-
- (On Windows platforms you should use nmake instead.)
-
- Using Build.PL (if you have Module::Build installed):
-
- perl Build.PL
- perl Build
- perl Build test
- perl Build install
-
-SYNOPSIS
- use Graphics::ColorNames qw( hex2tuple tuple2hex );
-
- tie %NameTable, 'Graphics::ColorNames', 'X';
-
- my $rgbhex1 = $NameTable{'green'}; # returns '00ff00'
- my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00'
- my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0)
-
- my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
- my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc'
-
-DESCRIPTION
- This module defines RGB values for common color names. The intention is
- to (1) provide a common module that authors can use with other modules
- to specify colors; and (2) free module authors from having to "re-invent
- the wheel" whenever they decide to give the users the option of
- specifying a color by name rather than RGB value.
-
- A more detailed description with documentation can be found in the
- module's POD.
-
-HISTORY
- Revision history since the last release:
-
- 1.06 Tue Mar 29 2005
- - cleaned up tests
- - added DSLIP information to POD
- - added Test::Pod tests
- - added Pod::Coverage tests
- - minor documentation changes
- - uses Test::Prereq to test distro prereqs
- - added SIGNATURE to distribution
-
- A more detailed revision history is available in the Changes file.
-
-AUTHOR
- Robert Rothenberg <rrwo at cpan.org>
-
-LICENSE
- Copyright (c) 2001-2005 Robert Rothenberg. All rights
- reserved. This program is free software; you can redistribute it
- and/or modify it under the same terms as Perl itself.
-
+NAME + Graphics::ColorNames - defines RGB values for common color names + +REQUIREMENTS + `Graphics::ColorNames' should work on Perl 5.6.0. It requires the + following non-core (depending on your Perl version) modules: + + Module::Load + Module::Loaded + + The following modules are not required for using most features but are + recommended: + + Color::Library + Tie::Sub + + Installation requires the following testing modules: + + Test::Exception + Test::More + + If the `DEVEL_TESTS' environment variable is set, the tests will also + use the following modules for running developer tests, if they are + installed: + + Test::Pod + Test::Pod::Coverage + Test::Portability::Files + + The developer tests are for quality-control purposes. + +INSTALLATION + Installation can be done using the traditional Makefile.PL or the newer + Build.PL methods. + + Using Makefile.PL: + + perl Makefile.PL + make test + make install + + (On Windows platforms you should use `nmake' instead.) + + Using Build.PL (if you have Module::Build installed): + + perl Build.PL + perl Build test + perl Build install + +SYNOPSIS + use Graphics::ColorNames 2.10; + + $po = new Graphics::ColorNames(qw( X )); + + $rgb = $po->hex('green'); # returns '00ff00' + $rgb = $po->hex('green', '0x'); # returns '0x00ff00' + $rgb = $po->hex('green', '#'); # returns '#00ff00' + + $rgb = $po->rgb('green'); # returns '0,255,0' + @rgb = $po->rgb('green'); # returns (0, 255, 0) + + $rgb = $po->green; # same as $po->hex('green'); + + tie %ph, 'Graphics::ColorNames', (qw( X )); + + $rgb = $ph{green}; # same as $po->hex('green'); + +DESCRIPTION + This module provides a common interface for obtaining the RGB values of + colors by standard names. The intention is to (1) provide a common + module that authors can use with other modules to specify colors by + name; and (2) free module authors from having to "re-invent the wheel" + whenever they decide to give the users the option of specifying a color + by name rather than RGB value. + + See the module POD for complete documentation. + +REVISION HISTORY + Changes since the last release: + + 2.11 Thu Jan 10 2008 + - updated version number for release + - minor changes of text format + - added fix for problems with Graphics::ColorNames::GrayScale + + 2.10_05 Tue Jan 8 2008 + * checks if modules already loaded before re-loading them + (uses Module::Loaded for this) + - requires changed to load for dynamically loaded modules + - updated README + + 2.10_04 Sun Jan 6 2008 + - reverted back to standard object-oriented style + - Tie::Sub is only loaded when a subroutine is used for scheme + + 2.10_03 Sat Jan 5 2008 + - tests use Test::Exception to catch errors + - rewrite parts of documentation to emphasize object-oriented + interface rather than the tied interface + - implemented a proper DESTROY method + - misc code cleanup and reorganization + + 2.10_02 Fri Jan 4 2008 + * added support for Color::Library dictionaries + - minor changes to error messages + - underscores in color names ignored + - auto-loading color names in object-oriented interface, e.g. + $obj->black() + - stubs for DESTROY and UNTIE methods + - 06-obj.t test more flexible + - pointless 01-ColourNames test removed + - more updates to documentation + + 2.10_01 Thu Dec 20 2007 + * non-word characters (spaces, punctuation) now ignored in + color names + * smarter handling of comments in rgb.txt files + * significant rewrite to parts of the code, requires Tie::Sub + * rewritten how FIRSTKEY and NEXTKEY methods work + - better error handling + - minor updates to documentation + - typos in comments + - added better checking for minimum Perl version reqs + - added aliaes w/out punctuation in Netscape scheme + + More details can be found in the Changes file. + +AUTHOR + Robert Rothenberg <rrwo at cpan.org> + +LICENSE + Copyright (c) 2001-2008 Robert Rothenberg. All rights reserved. This + program is free software; you can redistribute it and/or modify it under + the same terms as Perl itself. + diff --git a/SIGNATURE b/SIGNATURE deleted file mode 100644 index e79ce2c..0000000 --- a/SIGNATURE +++ /dev/null @@ -1,48 +0,0 @@ -This file contains message digests of all files listed in MANIFEST,
-signed via the Module::Signature module, version 0.44.
-
-To verify the content in this distribution, first make sure you have
-Module::Signature installed, then type:
-
- % cpansign -v
-
-It will check each file's integrity, as well as the signature's
-validity. If "==> Signature verified OK! <==" is not displayed,
-the distribution may already have been compromised, and you should
-not run its Makefile.PL or Build.PL.
-
------BEGIN PGP SIGNED MESSAGE-----
-Hash: SHA1
-
-SHA1 09d8e07ed2906851bc648c38764d954ae65ae9c0 Build.PL
-SHA1 f914d5d44538dff1eacc5b4be581387bd786e4df Changes
-SHA1 b5523653c65c2b15b0c10c7c3821b76c26db901e MANIFEST
-SHA1 22f4ac1e4f24793e3a54f575a623bf6dd4eb7a98 META.yml
-SHA1 0626b548af56d29d44faa6d7509e3ead5b7aa343 Makefile.PL
-SHA1 85eaead1e33535c579304ef2116aa9722c9b39f0 README
-SHA1 94fe6e319f6158139af6a7b4ba4a4cea3d697d14 lib/Graphics/ColorNames.pm
-SHA1 4db6a372a70f1a4b90a46e153330b7a570757023 lib/Graphics/ColorNames/HTML.pm
-SHA1 ea38a6c660621a7c57cb9f31bb44737cdfe3d7b2 lib/Graphics/ColorNames/Netscape.pm
-SHA1 161469f8bcfb14ef693bfd315c0e41b3721bd16b lib/Graphics/ColorNames/Windows.pm
-SHA1 dfdd478039e0f5d8f6351d8a1d90c53e16343de1 lib/Graphics/ColorNames/X.pm
-SHA1 d28b85622781d77fe5f23c4c2f3dfea82939ade5 lib/Graphics/ColourNames.pm
-SHA1 c7d63443ba312c659cf441d89231a065d9e6d716 t/00-Prereqs.t
-SHA1 bef0f210e3cd888a0fbc10c40ee90419b8d079e3 t/00-pod-coverage.t
-SHA1 a7be5b4aad4ce3f7a59d6e3cd654ee6c6e642344 t/00-pod.t
-SHA1 414dfe0a0c0cc08f5b1171e0a8d5d29872fedd91 t/01-ColorNames.t
-SHA1 80cd23ecd10a62e678d998fa0f884188c405edf1 t/01-ColourNames.t
-SHA1 e02321c84d2fc9cb23d5ef546e79659209cddbb0 t/02-X.t
-SHA1 375ff88426e0c83fc93c79b5b328c613d9824add t/03-HTML.t
-SHA1 0a7f6ff67e286cd5a7e6ad84986675fb8e346149 t/04-Windows.t
-SHA1 461c697b85a232a3237737abe4fd85a4ea70a586 t/05-Netscape.t
-SHA1 d510ca893737063097fd25242d8b3a940755c7bd t/06-obj.t
-SHA1 8d01b6fd40a4f3b5a084fef41d0212b70de36983 t/07-file.t
-SHA1 c1d92dcde46607a45b3b8aceed1aa4201340409b t/08-filehandle.t
-SHA1 d3e7e6d18177d7885cbd06d3f37b7a89f539c68d t/rgb.txt
------BEGIN PGP SIGNATURE-----
-Version: GnuPG v1.2.5 (MingW32)
-
-iD8DBQFCSd8RV485gMKcmRARArJgAJsGdC2oFLJSIOEEyov9S/DppEgApwCgjJlk
-BfnMi//CPmr0GmN+xJ1UUxo=
-=x/+X
------END PGP SIGNATURE-----
diff --git a/lib/Graphics/ColorNames.pm b/lib/Graphics/ColorNames.pm index ed44b2f..f50b93b 100644..100755 --- a/lib/Graphics/ColorNames.pm +++ b/lib/Graphics/ColorNames.pm @@ -1,523 +1,785 @@ -package Graphics::ColorNames;
-
-require 5.006;
-
-use strict;
-use warnings;
-
-use Carp;
-use IO::File;
-use Module::Load;
-
-our @ISA = qw( Exporter );
-
-our $VERSION = '1.06';
-# $VERSION = eval $VERSION;
-
-our @EXPORT = qw( );
-our @EXPORT_OK = qw( hex2tuple tuple2hex );
-
-sub _load_file {
- my $self = shift;
- my $file = shift;
-
- unless (ref($file)) {
- unless (-r $file) {
- croak "Cannot load scheme from file: \'$file\'";
- }
- }
-
- my $colors = { };
-
- my $fh = ref($file) ? $file : (new IO::File);
- unless (ref($file)) {
- open($fh, $file)
- or croak "Cannot open file: \'$file\'";
- }
-
- while (my $line = <$fh>) {
- unless ($line =~ /^[\!\#]/) {
- chomp($line);
- if ($line) {
- my ($red, $green, $blue, $name, $rgb);
- $red = eval substr($line, 0, 3);
- $green = eval substr($line, 4, 3);
- $blue = eval substr($line, 8, 3);
-
- $rgb = ($red << 16) | ($green << 8) | ($blue);
-
- $name = substr($line, 12);
- $name =~ s/^\s+//; # remove leading and trailing spaces
- $name =~ s/\s+$//;
-
- $colors->{lc($name)} = $rgb;
- }
- }
- }
- unless (ref($file)) {
- close $fh;
- }
-
- $self->{SCHEMES}->[ $self->{COUNT}++ ] = $colors;
-# push @{ $self->{SCHEMES} }, $colors;
-}
-
-sub _load_scheme
- {
- my $self = shift;
- my $scheme = shift;
-
- # Should this be switched to use Module::Pluggable? Hm....
-
- my $module = join('::', __PACKAGE__, $scheme);
- eval {
- load $module;
- };
- if ($@)
- {
- croak "Cannot load color naming scheme \`$scheme\'";
- }
- else
- {
- no strict 'refs';
- $self->{SCHEMES}->[ $self->{COUNT}++ ] = $module->NamesRgbTable();
- }
- }
-
-sub TIEHASH
- {
- my $class = shift;
-
- my $self = {
- SCHEMES => [ ], # a list of naming schemes, in priority search order
- COUNT => 0,
- };
-
- bless $self, $class;
-
- if (@_) {
- foreach my $scheme (@_) {
- if (-e $scheme) {
- $self->_load_file( $scheme );
- }
- else {
- $self->_load_scheme( $scheme );
- }
- }
- }
- else {
- $self->_load_scheme( 'X' );
- }
-
- return $self;
- }
-
-sub FETCH
- {
- my ($self, $key) = @_;
-
- my $value;
- if ($key =~ m/^\x23?[\da-f]{6}$/i)
- {
- $value = $key;
- $value =~ s/\x23//;
- }
- else
- {
- my $i = 0;
- while ( (!defined $value) and ($i < $self->{COUNT}) )
- {
- my $scheme = $self->{SCHEMES}->[$i++];
- my $type = ref($scheme);
- if ($type eq 'HASH') {
- $value = $scheme->{ lc($key) };
- }
- elsif ($type eq 'CODE') {
- $value = &$scheme(lc($key));
- }
- else {
- croak "Unsupported scheme type: ", $type;
- }
- }
- $value = sprintf( '%06x', $value ), if (defined $value);
- }
- return $value;
- }
-
-sub EXISTS
- {
- my ($self, $key) = @_;
- defined ($self->FETCH($key));
- }
-
-sub FIRSTKEY
- {
- my $self = shift;
- my $scheme = $self->{SCHEMES}->[0];
- if (ref($scheme) ne 'HASH') {
- croak "Scheme is not a hash";
- }
- each %{$self->{SCHEMES}->[0]};
- }
-
-sub NEXTKEY
- {
- my $self = shift;
- my $scheme = $self->{SCHEMES}->[0];
- if (ref($scheme) ne 'HASH') {
- croak "Scheme is not a hash";
- }
- each %{$self->{SCHEMES}->[0]};
- }
-
-sub hex {
- my $self = shift;
- my $name = shift;
- my $rgb = $self->FETCH($name);
- my $pre = shift;
- unless (defined $pre) { $pre = ""; }
- return ($pre.$rgb);
-}
-
-sub rgb {
- my $self = shift;
- my $name = shift;
- my @rgb = hex2tuple($self->FETCH($name));
- my $sep = shift || ',';
- return wantarray ? @rgb : join($sep,@rgb);
-}
-
-sub hex2tuple
-
-# Convert 6-digit hexidecimal code (used for HTML etc.) to an array of
-# RGB values
-
- {
- my $rgb = CORE::hex( shift );
- my ($red, $green, $blue);
- $blue = ($rgb & 0x0000ff);
- $green = ($rgb & 0x00ff00) >> 8;
- $red = ($rgb & 0xff0000) >> 16;
- return ($red, $green, $blue);
- }
-
-sub tuple2hex
-
-# Convert list of RGB values to 6-digit hexidecimal code (used for HTML, etc.)
- {
- my ($red, $green, $blue) = @_;
- my $rgb = sprintf "%.2x%.2x%.2x", $red, $green, $blue;
- return $rgb;
- }
-
-sub _readonly_error
- {
- croak "Cannot modify a read-only value";
- }
-
-BEGIN
- {
- no strict 'refs';
- *STORE = \ &_readonly_error;
- *DELETE = \ &_readonly_error;
- *CLEAR = \ &_readonly_error; # causes problems with 'undef'
-
- *new = \ &TIEHASH;
- }
-
-1;
-
-__END__
-
-=head1 NAME
-
-Graphics::ColorNames - defines RGB values for common color names
-
-=head1 REQUIREMENTS
-
-C<Graphics::ColorNames> should work on Perl 5.6.0. It requires the
-following non-standard modules:
-
- Module::Load
-
-=head2 Installation
-
-Installation is pretty standard:
-
- perl Makefile.PL
- make
- make test
- make install
-
-=head1 SYNOPSIS
-
- use Graphics::ColorNames qw( hex2tuple tuple2hex );
-
- tie %NameTable, 'Graphics::ColorNames', 'X';
-
- my $rgbhex1 = $NameTable{'green'}; # returns '00ff00'
- my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00'
- my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0)
-
- my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
- my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc'
-
-=head1 DESCRIPTION
-
-This module defines RGB values for common color names. The intention is to
-(1) provide a common module that authors can use with other modules to
-specify colors; and (2) free module authors from having to "re-invent the
-wheel" whenever they decide to give the users the option of specifying a
-color by name rather than RGB value.
-
-For example,
-
- use Graphics::ColorNames 'hex2tuple';
- tie %COLORS, 'Graphics::ColorNames';
-
- use GD;
-
- $img = new GD::Image(100, 100);
-
- $bgColor = $img->colorAllocate( hex2tuple( $COLORS{'CadetBlue3'} ) );
-
-Though a little 'bureaucratic', the meaning of this code is clearer:
-C<$bgColor> (or background color) is 'CadetBlue3' (which is easier to for one
-to understand than C<0x7A, 0xC5, 0xCD>). The variable is named for its
-function, not form (ie, C<$CadetBlue3>) so that if the author later changes
-the background color, the variable name need not be changed.
-
-As an added feature, a hexidecimal RGB value in the form of #RRGGBB or
-RRGGBB will return itself:
-
- my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
-
-=head2 Tied Interface
-
-The standard interface (prior to version 0.40) is through a tied hash:
-
- tie %NAMETABLE, 'Graphics::ColorNames', @SCHEME
-
-where C<%NAMETABLE> is the tied hash and C<@SCHEME> is a list of
-L<color schemes|/Color Schemes> or the path to or open filehandle for
-a F<rgb.txt> file.
-
-Multiple schemes can be used:
-
- tie %COLORS, 'Graphics::ColorNames', qw(HTML Windows Netscape);
-
-In this case, if the name is not a valid HTML color, the Windows
-name will be used; if it is not a valid Windows name, then the
-Netscape name will be used.
-
-RGB values can be retrieved with a case-insensitive hash key:
-
- $rgb = $colors{'AliceBlue'};
-
-The value returned is in the six-digit hexidecimal format used in HTML and
-CSS (without the initial '#'). To convert it to separate red, green, and
-blue values (between 0 and 255), use the L</hex2tuple> function.
-
-=head2 Object-Oriented Interface
-
-If you prefer, an object-oriented interface is available:
-
- $obj = Graphics::ColorNames->new('/etc/rgb.txt');
-
- $hex = $obj->hex('skyblue'); # returns "87ceeb"
-
- @rgb = $obj->rgb('skyblue'); # returns (0x87, 0xce, 0xeb)
-
-The interface is similar to the L<Color::Rgb> module:
-
-=over
-
-=item new
-
- $obj = Graphics::ColorNames->new( @SCHEMES );
-
-Creates the object, using the default L<color schemes|/Color Schemes>.
-If none are specified, it uses the C<X> scheme.
-
-=item hex
-
- $hex = $obj->hex($name, $prefix);
-
-Returns a 6-digit hexidecimal RGB code for the color. If an optional
-prefix is specified, it will prefix the code with that string. For
-example,
-
- $hex = $obj->hex('blue', '#'); # returns "#0000ff"
-
-=item rgb
-
- @rgb = $obj->rgb($name);
-
- $rgb = $obj->rgb($name, $separator);
-
-If called in a list context, returns a triplet.
-
-If called in a scalar context, returns a string separated by an
-optional separator (which defauls to a comma). For example,
-
- @rgb = $obj->rgb('blue'); # returns (0, 0, 255)
-
- $rgb = $obj->rgb('blue', ','); # returns "0,0,255"
-
-=back
-
-=head2 Utility Functions
-
-These functions are not exported by default, so much be specified to
-be used:
-
- use Graphics::ColorNames qw( hex2tuple tuple2hex );
-
-=over
-
-=item hex2tuple
-
- ($red, $green, $blue) = hex2tuple( $colors{'AliceBlue'});
-
-=item tuple2hex
-
- $rgb = tuple2hex( $red, $green, $blue );
-
-=back
-
-=head2 Color Schemes
-
-The following schemes are available by default:
-
-=over
-
-=item X
-
-About 750 color names used in X-Windows. I<This is the default naming
-scheme>, since it provides the most names.
-
-=item HTML
-
-16 common color names defined in the HTML 4.0 specification. These names
-are also used with CSS and SVG.
-
-=item Netscape
-
-100 color names names associated Netscape 1.1 (I cannot determine whether
-they were once usable in Netscape or were arbitrary names for RGB values--
-many of these names are not recognized by later versions of Netscape).
-
-This scheme may be deprecated in future versions, but available as a
-separate module.
-
-=item Windows
-
-16 commom color names used with Microsoft Windows and related products.
-These are actually the same colors as C<HTML>, although with different
-names.
-
-=back
-
-Rather than a color scheme, the path or open filehandle for a
-F<rgb.txt> file may be specified.
-
-Additional color schemes may be available on CPAN.
-
-=head2 Adding Naming Schemes
-
-You can add naming scheme files by creating a Perl module is the name
-C<Graphics::ColorNames::SCHEMENAME> which has a subroutine named
-C<NamesRgbTable> that returns a hash of color names and RGB values.
-
-The color names must be in all lower-case, and the RGB values must be
-24-bit numbers containing the red, green, and blue values in most- significant
-to least- significant byte order.
-
-An example naming schema is below:
-
- package Graphics::ColorNames::Metallic;
-
- sub NamesRgbTable() {
- use integer;
- return {
- copper => 0xb87333,
- gold => 0xcd7f32,
- silver => 0xe6e8fa,
- };
- }
-
-You would use the above schema as follows:
-
- tie %colors, 'Graphics::ColorNames', 'Metallic';
-
-An example of an additional module is Steve Pomeroy's
-L<Graphics::ColorNames::Mozilla> module.
-
-Since version 1.03, C<NamesRgbTable> may also return a code reference:
-
- package Graphics::ColorNames::Orange;
-
- sub NamesRgbTable() {
- return sub {
- my $name = shift;
- return 0xffa500;
- };
- }
-
-See L<Graphics::ColorNames::GrayScale> for an example.
-
-Note that extentions of the form "Graphics::ColourNames::*" are not
-supported.
-
-=head1 SEE ALSO
-
-L<Color::Rgb> has a similar function to this module, but parses an
-F<rgb.txt> file.
-
-L<Graphics::ColorObject> can convert between RGB and other color space
-types.
-
-=head1 DSLIP
-
- R - Released
- d - Developer
- p - Perl-only
- h - Hybrid interface
- p - Standard Perl
-
-See L<http://cpan.uwinnipeg.ca/htdocs/faqs/dslip.html>
-
-=head1 AUTHOR
-
-Robert Rothenberg <rrwo at cpan.org>
-
-=head2 Acknowledgements
-
-Alan D. Salewski <alans at cji.com> for feedback and the addition of
-C<tuple2hex>.
-
-Steve Pomeroy <xavier at cpan.org> for pointing out invalid color
-definitions in X color space.
-
-<chemboy at perlmonk.org> who pointed out a mispelling of "fuchsia" in
-the HTML color space L<http://rt.cpan.org/Ticket/Display.html?id=1704>.
-
-<magnus at mbox604.swipnet.se> who pointed out mispellings and naming
-inconsistencies.
-
-=head2 Suggestions and Bug Reporting
-
-Feedback is always welcome. Please use the CPAN Request Tracker at
-L<http://rt.cpan.org> to submit bug reports.
-
-If you create additional color schemes, please make them available
-separately in CPAN rather than submit them to me for inclusion into
-this module.
-
-=head1 LICENSE
-
-Copyright (c) 2001-2005 Robert Rothenberg. All rights reserved.
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-=cut
+package Graphics::ColorNames; +use 5.006; + +use base "Exporter"; + +use strict; +use warnings; + +# use AutoLoader; +use Carp; +use Module::Load 0.10; +use Module::Loaded; + +our $VERSION = '2.11'; +# $VERSION = eval $VERSION; + +our %EXPORT_TAGS = ( + 'all' => [ qw( hex2tuple tuple2hex all_schemes ) ], + 'utility' => [ qw( hex2tuple tuple2hex ) ], +); +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); +our @EXPORT = ( ); + +# We store Schemes in a hash as a quick-and-dirty way to filter +# duplicates (which sometimes occur when directories are repeated in +# @INC or via symlinks). The order does not matter. + +# If we use AutoLoader, these should be use vars() ? + +my %FoundSchemes = ( ); + +# Since 2.10_02, we've added autoloading color names to the object- +# oriented interface. + +our $AUTOLOAD; + +sub AUTOLOAD { + $AUTOLOAD =~ /^(.*:)*([\w\_]+)$/; + my $name = $2; + my $hex = (my $self = $_[0])->FETCH($name); + if (defined $hex) { + return $hex; + } + else { + croak "No method or color named $name"; + # $AutoLoader::AUTOLOAD = $AUTOLOAD; + # goto &AutoLoader::AUTOLOAD; + } +} + + +sub _load { + while(my $module = shift) { + unless (is_loaded($module)) { + load($module); + mark_as_loaded($module) unless (is_loaded($module)); + } + } +} + +# TODO - see if using Tie::Hash::Layered gives an improvement + +sub _load_scheme_from_module { + my $self = shift; + my $base = __PACKAGE__; + + my $module = join('::', $base, (my $scheme = shift)); + eval { _load($module); }; + if ($@) { + eval { _load($module = $scheme); }; + if ($@) { + croak "Cannot load color naming scheme \`$module\'"; + } + } + + { + no strict 'refs'; + if ($module =~ $base) { + $self->load_scheme($module->NamesRgbTable); + } + elsif ($module =~ /Color::Library::Dictionary/) { + $self->load_scheme($module->_load_color_list); + } + else { + croak "Unknown scheme type: $module"; + } + } +} + +sub TIEHASH { + my $class = shift || __PACKAGE__; + my $self = { + _schemes => [ ], + _iterator => 0, + }; + + bless $self, $class; + + if (@_) { + foreach my $scheme (@_) { + if (ref $scheme) { + $self->load_scheme( $scheme ); + } + elsif (-r $scheme) { + $self->_load_scheme_from_file( $scheme ); + } + else { + $self->_load_scheme_from_module( $scheme ); + } + } + } else { + $self->_load_scheme_from_module('X'); + } + + return $self; +} + +sub FETCH { + my $self = shift; + my $key = lc(shift||""); + + # If we're passing it an RGB value, return that value + + if ($key =~ m/^\x23?([\da-f]{6})$/) { + return $1; + } else { + + $key =~ s/[^a-z\d\%]//g; # ignore non-word characters + + my $val = undef; + my $i = 0; + while ((!defined $val) && ($i < @{$self->{_schemes}})) { + $val = $self->{_schemes}->[$i++]->{$key}; + } + + if (defined $val) { + return sprintf('%06x', $val ), ; + } else { + return; + } + } +} + +sub EXISTS { + my ($self, $key) = @_; + defined ($self->FETCH($key)); +} + +sub FIRSTKEY { + (my $self = shift)->{_iterator} = 0; + each %{$self->{_schemes}->[$self->{_iterator}]}; +} + +sub NEXTKEY { + my $self = shift; + my ($key, $val) = each %{$self->{_schemes}->[$self->{_iterator}]}; + unless (defined $key) { + ($key, $val) = each %{$self->{_schemes}->[++$self->{_iterator}]}; + } + return $key; +} + +sub load_scheme { + my $self = shift; + my $scheme = shift; + + if (ref($scheme) eq "HASH") { + push @{$self->{_schemes}}, $scheme; + } + elsif (ref($scheme) eq "CODE") { + _load("Tie::Sub"); + push @{$self->{_schemes}}, { }; + tie %{$self->{_schemes}->[-1]}, 'Tie::Sub', $scheme; + } + elsif (ref($scheme) eq "ARRAY") { + # assumes these are Color::Library::Dictionary 0.02 files + my $s = { }; + foreach my $rec (@$scheme) { + my $key = $rec->[0]; + my $name = $rec->[1]; + my $code = $rec->[5]; + $name =~ s/[\W\_]//g; # ignore non-word characters + $s->{$name} = $code unless (exists $s->{$name}); + if ($key =~ /^(.+\:.+)\.(\d+)$/) { + $s->{"$name$2"} = $code; + } + } + push @{$self->{_schemes}}, $s; + } + else { + # TODO - use Exception + undef $!; + eval { + if ((ref($scheme) eq 'GLOB') + || ref($scheme) eq "IO::File" || $scheme->isa('IO::File') + || ref($scheme) eq "FileHandle" || $scheme->isa('FileHandle')) { + $self->_load_scheme_from_file($scheme); + } + }; + if ($@) { + croak "Error $@ on scheme type ", ref($scheme); + } + elsif ($!) { + croak "$!"; + } + else { + # everything is ok? + } + } +} + +sub _find_schemes { + + my $path = shift; + + # BUG: deep-named schemes such as Graphics::ColorNames::Foo::Bar + # are not supported. + + if (-d $path) { + my $dh = DirHandle->new( $path ) + || croak "Unable to access directory $path"; + while (defined(my $fn = $dh->read)) { + if ((-r File::Spec->catdir($path, $fn)) && ($fn =~ /(.+)\.pm$/)) { + $FoundSchemes{$1}++; + } + } + } + } + +sub _readonly_error { + croak "Cannot modify a read-only value"; +} + +sub DESTROY { + my $self = shift; + delete $self->{_schemes}; + delete $self->{_iterator}; +} + +sub UNTIE { # stub to avoid AUTOLOAD +} + +BEGIN { + no strict 'refs'; + *STORE = \ &_readonly_error; + *DELETE = \ &_readonly_error; + *CLEAR = \ &_readonly_error; # causes problems with 'undef' + + *new = \ &TIEHASH; +} + + +1; + +## __END__ + +# Convert 6-digit hexidecimal code (used for HTML etc.) to an array of +# RGB values + +sub hex2tuple { + my $rgb = CORE::hex( shift ); + my ($red, $green, $blue); + $blue = ($rgb & 0x0000ff); + $green = ($rgb & 0x00ff00) >> 8; + $red = ($rgb & 0xff0000) >> 16; + return ($red, $green, $blue); +} + + +# Convert list of RGB values to 6-digit hexidecimal code (used for HTML, etc.) + +sub tuple2hex { + my ($red, $green, $blue) = @_; + my $rgb = sprintf "%.2x%.2x%.2x", $red, $green, $blue; + return $rgb; +} + +sub all_schemes { + unless (%FoundSchemes) { + + _load("DirHandle", "File::Spec"); + + foreach my $dir (@INC) { + _find_schemes( + File::Spec->catdir($dir, split(/::/, __PACKAGE__))); + } + } + return (keys %FoundSchemes); + } + +sub _load_scheme_from_file { + my $self = shift; + my $file = shift; + + unless (ref $file) { + unless (-r $file) { + croak "Cannot load scheme from file: \'$file\'"; + } + _load("IO::File"); + } + + my $fh = ref($file) ? $file : (IO::File->new); + unless (ref $file) { + open($fh, $file) + || croak "Cannot open file: \'$file\'"; + } + + my $scheme = { }; + + while (my $line = <$fh>) { + chomp($line); + $line =~ s/[\!\#].*$//; + if ($line ne "") { + my $name = lc(substr($line, 12)); + $name =~ s/[\W]//g; # remove anything that isn't a letter or number + + croak "Missing color name", + unless ($name ne ""); + + # TODO? Should we add an option to warn if overlapping names + # are defined? This seems to be too common to be useful. + + # unless (exists $scheme->{$name}) { + + $scheme->{$name} = 0; + foreach (0, 4, 8) { + $scheme->{$name} <<= 8; + $scheme->{$name} |= (eval substr($line, $_, 3)); + } + + # } + } + } + $self->load_scheme( $scheme ); + + unless (ref $file) { + close $fh; + } +} + + +sub hex { + my $self = shift; + my $rgb = $self->FETCH(my $name = shift); + my $pre = shift || ""; + return ($pre.$rgb); +} + +sub rgb { + my $self = shift; + my @rgb = hex2tuple($self->FETCH(my $name = shift)); + my $sep = shift || ','; # (*) + return wantarray ? @rgb : join($sep,@rgb); +# (*) A possible bug, if one uses "0" as a separator. But this is not likely +} + +__END__ + +=head1 NAME + +Graphics::ColorNames - defines RGB values for common color names + +=begin readme + +=head1 REQUIREMENTS + +C<Graphics::ColorNames> should work on Perl 5.6.0. It requires the +following non-core (depending on your Perl version) modules: + + Module::Load + Module::Loaded + +The following modules are not required for using most features but +are recommended: + + Color::Library + Tie::Sub + +L<Installation|/INSTALLATION> requires the following testing modules: + + Test::Exception + Test::More + +If the C<DEVEL_TESTS> environment variable is set, the tests will also +use the following modules for running developer tests, if they are +installed: + + Test::Pod + Test::Pod::Coverage + Test::Portability::Files + +The developer tests are for quality-control purposes. + +=head1 INSTALLATION + +Installation can be done using the traditional Makefile.PL or the newer +Build.PL methods. + +Using Makefile.PL: + + perl Makefile.PL + make test + make install + +(On Windows platforms you should use C<nmake> instead.) + +Using Build.PL (if you have L<Module::Build> installed): + + perl Build.PL + perl Build test + perl Build install + +=end readme + +=head1 SYNOPSIS + + use Graphics::ColorNames 2.10; + + $po = new Graphics::ColorNames(qw( X )); + + $rgb = $po->hex('green'); # returns '00ff00' + $rgb = $po->hex('green', '0x'); # returns '0x00ff00' + $rgb = $po->hex('green', '#'); # returns '#00ff00' + + $rgb = $po->rgb('green'); # returns '0,255,0' + @rgb = $po->rgb('green'); # returns (0, 255, 0) + + $rgb = $po->green; # same as $po->hex('green'); + + tie %ph, 'Graphics::ColorNames', (qw( X )); + + $rgb = $ph{green}; # same as $po->hex('green'); + +=head1 DESCRIPTION + +This module provides a common interface for obtaining the RGB values +of colors by standard names. The intention is to (1) provide a common +module that authors can use with other modules to specify colors by +name; and (2) free module authors from having to "re-invent the wheel" +whenever they decide to give the users the option of specifying a +color by name rather than RGB value. + +=begin readme + +See the module POD for complete documentation. + +=end readme + +=for readme stop + +For example, + + use Graphics::ColorNames 2.10; + + use GD; + + $pal = new Graphics::ColorNames; + + $img = new GD::Image(100, 100); + + $bgColor = $img->colorAllocate( $pal->rgb('CadetBlue3') ); + +Although this is a little "bureaucratic", the meaning of this code is clear: +C<$bgColor> (or background color) is 'CadetBlue3' (which is easier to for one +to understand than C<0x7A, 0xC5, 0xCD>). The variable is named for its +function, not form (ie, C<$CadetBlue3>) so that if the author later changes +the background color, the variable name need not be changed. + +You can also define L</Custom Color Schemes> for specialised palettes +for websites or institutional publications: + + $color = $pal->hex('MenuBackground'); + +As an added feature, a hexidecimal RGB value in the form of #RRGGBB, +0xRRGGBB or RRGGBB will return itself: + + $color = $pal->hex('#123abc'); # returns '123abc' + +=head2 Tied Interface + +The standard interface (prior to version 0.40) is through a tied hash: + + tie %pal, 'Graphics::ColorNames', @schemes; + +where C<%pal> is the tied hash and C<@schemes> is a list of +L<color schemes|/Color Schemes>. + +A valid color scheme may be the name of a color scheme (such as C<X> +or a full module name such as C<Graphics::ColorNames::X>), a reference +to a color scheme hash or subroutine, or to the path or open +filehandle for a F<rgb.txt> file. + +As of version 2.1002, one can also use L<Color::Library> dictionaries: + + tie %pal, 'Graphics::ColorNames', qw(Color::Library::Dictionary::HTML); + +This is an experimental feature which may change in later versions (see +L</SEE ALSO> for a discussion of the differences between modules). + +Multiple schemes can be used: + + tie %pal, 'Graphics::ColorNames', qw(HTML Netscape); + +In this case, if the name is not a valid HTML color, the Netscape name +will be used. + +One can load all available schemes in the Graphics::ColorNames namespace +(as of version 2.0): + + use Graphics::ColorNames 2.0, 'all_schemes'; + tie %NameTable, 'Graphics::ColorNames', all_schemes(); + +When multiple color schemes define the same name, then the earlier one +listed has priority (however, hash-based color schemes always have +priority over code-based color schemes). + +When no color scheme is specified, the X-Windows scheme is assumed. + +Color names are case insensitive, and spaces or punctuation +are ignored. So "Alice Blue" returns the same +value as "aliceblue", "ALICE-BLUE" and "a*lICEbl-ue". (If you are +using color names based on user input, you may want to add additional +validation of the color names.) + +The value returned is in the six-digit hexidecimal format used in HTML and +CSS (without the initial '#'). To convert it to separate red, green, and +blue values (between 0 and 255), use the L</hex2tuple> function. + +=head2 Object-Oriented Interface + +If you prefer, an object-oriented interface is available: + + use Graphics::ColorNames 0.40; + + $obj = Graphics::ColorNames->new('/etc/rgb.txt'); + + $hex = $obj->hex('skyblue'); # returns "87ceeb" + @rgb = $obj->rgb('skyblue'); # returns (0x87, 0xce, 0xeb) + +The interface is similar to the L<Color::Rgb> module: + +=over + +=item new + + $obj = Graphics::ColorNames->new( @SCHEMES ); + +Creates the object, using the default L<color schemes|/Color Schemes>. +If none are specified, it uses the C<X> scheme. + +=item load_scheme + + $obj->load_scheme( $scheme ); + +Loads a scheme dynamically. The scheme may be any hash or code reference. + +=item hex + + $hex = $obj->hex($name, $prefix); + +Returns a 6-digit hexidecimal RGB code for the color. If an optional +prefix is specified, it will prefix the code with that string. For +example, + + $hex = $obj->hex('blue', '#'); # returns "#0000ff" + +=item rgb + + @rgb = $obj->rgb($name); + + $rgb = $obj->rgb($name, $separator); + +If called in a list context, returns a triplet. + +If called in a scalar context, returns a string separated by an +optional separator (which defauls to a comma). For example, + + @rgb = $obj->rgb('blue'); # returns (0, 0, 255) + + $rgb = $obj->rgb('blue', ','); # returns "0,0,255" + +=back + +Since version 2.10_02, the interface will assume method names +are color names and return the hex value, + + $obj->black eq $obj->hex("black") + +Method names are case-insensitive, and underscores are ignored. + +=head2 Utility Functions + +These functions are not exported by default, so much be specified to +be used: + + use Graphics::ColorNames qw( all_schemes hex2tuple tuple2hex ); + +=over + +=item all_schemes + + @schemes = all_schemes(); + +Returns a list of all available color schemes installed on the machine +in the F<Graphics::ColorNames> namespace. + +The order has no significance. + +=item hex2tuple + + ($red, $green, $blue) = hex2tuple( $colors{'AliceBlue'}); + +=item tuple2hex + + $rgb = tuple2hex( $red, $green, $blue ); + +=back + +=head2 Color Schemes + +The following schemes are available by default: + +=over + +=item X + +About 750 color names used in X-Windows (although about 90+ of them are +duplicate names with spaces). + +=item HTML + +16 common color names defined in the HTML 4.0 specification. These +names are also used with older CSS and SVG specifications. (You may +want to see L<Graphics::ColorNames::SVG> for a complete list.) + +=item Netscape + +100 color names names associated Netscape 1.1 (I cannot determine whether +they were once usable in Netscape or were arbitrary names for RGB values-- +many of these names are not recognized by later versions of Netscape). + +This scheme may be deprecated in future versions, but available as a +separate module. + +=item Windows + +16 commom color names used with Microsoft Windows and related +products. These are actually the same colors as the L</HTML> scheme, +although with different names. + +=back + +Rather than a color scheme, the path or open filehandle for a +F<rgb.txt> file may be specified. + +Additional color schemes may be available on CPAN. + +=head2 Custom Color Schemes + +You can add naming scheme files by creating a Perl module is the name +C<Graphics::ColorNames::SCHEMENAME> which has a subroutine named +C<NamesRgbTable> that returns a hash of color names and RGB values. +(Schemes with a different base namespace will require the fill namespace +to be given.) + +The color names must be in all lower-case, and the RGB values must be +24-bit numbers containing the red, green, and blue values in most- significant +to least- significant byte order. + +An example naming schema is below: + + package Graphics::ColorNames::Metallic; + + sub NamesRgbTable() { + use integer; + return { + copper => 0xb87333, + gold => 0xcd7f32, + silver => 0xe6e8fa, + }; + } + +You would use the above schema as follows: + + tie %colors, 'Graphics::ColorNames', 'Metallic'; + +The behavior of specifying multiple keys with the same name is undefined +as to which one takes precedence. + +As of version 2.10, case, spaces and punctuation are ignored in color +names. So a name like "Willy's Favorite Shade-of-Blue" is treated the +same as "willysfavoroteshadeofblue". (If your scheme does not include +duplicate entrieswith spaces and punctuation, then the minimum +version of L<Graphics::ColorNames> should be 2.10 in your requirements.) + +An example of an additional module is the L<Graphics::ColorNames::Mozilla> +module by Steve Pomeroy. + +Since version 1.03, C<NamesRgbTable> may also return a code reference: + + package Graphics::ColorNames::Orange; + + sub NamesRgbTable() { + return sub { + my $name = shift; + return 0xffa500; + }; + } + +See L<Graphics::ColorNames::GrayScale> for an example. + +=head2 Graphics::ColourNames + +The alias "Graphics::ColourNames" (British spelling) is no longer available +as of version 2.01. + +It seems absurd to maintain it when all the modules does is provide an +alternative spelling for the module I<name> without doing anything about +the component colors of each scheme, and when most other modules +(and non-Perl software) does not bother with such things. + +=head1 SEE ALSO + +L<Color::Library> provides an extensive library of color schemes. A notable +difference is that it supports more complex schemes which contain additional +information about individual colors and map multiple colors to a single name. + +L<Color::Rgb> has a similar function to this module, but parses an +F<rgb.txt> file. + +L<Graphics::ColorObject> can convert between RGB and other color space +types. + +L<Acme::AutoColor> provides subroutines corresponding to color names. + +=begin readme + +=head1 REVISION HISTORY + +Changes since the last release: + +=for readme include file=Changes start=^2.11 stop=^2.04 type=text + +More details can be found in the F<Changes> file. + +=end readme + +=for readme continue + +=head1 AUTHOR + +Robert Rothenberg <rrwo at cpan.org> + +=for readme stop + +=head2 Acknowledgements + +Alan D. Salewski <alans at cji.com> for feedback and the addition of +C<tuple2hex>. + +Steve Pomeroy <xavier at cpan.org>, "chemboy" <chemboy at perlmonk.org> +and "magnus" <magnus at mbox604.swipnet.se> who pointed out issues +with various color schemes. + +=head2 Suggestions and Bug Reporting + +Feedback is always welcome. Please use the CPAN Request Tracker at +L<http://rt.cpan.org> to submit bug reports. + +There is a Sourceforge project for this package at +L<http://sourceforge.net/projects/colornames/>. + +If you create additional color schemes, please make them available +separately in CPAN rather than submit them to me for inclusion into +this module. + +=for readme continue + +=head1 LICENSE + +Copyright (c) 2001-2008 Robert Rothenberg. All rights reserved. +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=cut diff --git a/lib/Graphics/ColorNames/HTML.pm b/lib/Graphics/ColorNames/HTML.pm index bda5a37..05036ab 100644..100755 --- a/lib/Graphics/ColorNames/HTML.pm +++ b/lib/Graphics/ColorNames/HTML.pm @@ -25,7 +25,10 @@ proper spelling was added. =head1 SEE ALSO -C<Graphics::ColorNames>, HTML 4.0 Specificiation <http://www.w3.org> +L<Graphics::ColorNames>, HTML 4.0 Specificiation <http://www.w3.org> + +L<Graphics::ColorNames::SVG>, which uses color names based on the SVG +specification (which is more recent). =head1 AUTHOR @@ -33,18 +36,17 @@ Robert Rothenberg <rrwo at cpan.org> =head1 LICENSE -Copyright (c) 2001-2004 Robert Rothenberg. All rights reserved. +Copyright (c) 2001-2008 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut -require 5.006; - use strict; use warnings; -our $VERSION = '1.11'; +our $VERSION = '2.11'; +#$VERSION = eval $VERSION; sub NamesRgbTable() { use integer; diff --git a/lib/Graphics/ColorNames/Netscape.pm b/lib/Graphics/ColorNames/Netscape.pm index 6619a66..a694a83 100644..100755 --- a/lib/Graphics/ColorNames/Netscape.pm +++ b/lib/Graphics/ColorNames/Netscape.pm @@ -18,15 +18,22 @@ with Netscape 1.1 (I cannot determine whether they were once usable in Netscape or were arbitrary names for RGB values-- I<many of these names are not recognized by later versions of Netscape>). -=head2 Inconsistencies - -Note that the colors "gold", "lightblue" and "mediumblue" are the -same. This is because the reference Netscape page (below) shows those -RGB values. (As of December 2002, the page is still on-line.) +This scheme is deprecated, and will be removed from future versions of +L<Graphics::ColorNames> but available as a separate module from CPAN. =head1 SEE ALSO -L<Graphics::ColorNames>, L<http://home1.netscape.com/home/bg/colorindex.html> +L<Graphics::ColorNames> + +L<Graphics::ColorNames::Mozilla> + +L<Graphics::ColorNames::IE> + +L<Graphics::ColorNames::SVG> + +The color names come from L<http://wp.netscape.com/home/bg/colorindex.html>. +Corrections to errors in the Netscape spec are due to +L<http://www.he.net/info/color/>. =head1 AUTHOR @@ -34,22 +41,24 @@ Robert Rothenberg <rrwo at cpan.org> =head2 Acknowledgements -<magnus at mbox604.swipnet.se> who pointed out Inconsistencies +"Magnus", who pointed out inconsistencies. + +Gary Vollink, who suggested color schemes for later Netscape versions, +and pointed out that the original Netscape page had moved. =head1 LICENSE -Copyright (c) 2001-2004 Robert Rothenberg. All rights reserved. +Copyright (c) 2001-2008 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut -require 5.006; - use strict; use warnings; -our $VERSION = '1.05'; +our $VERSION = '2.11'; +#$VERSION = eval $VERSION; # See http://home1.netscape.com/home/bg/colorindex.html @@ -65,7 +74,7 @@ sub NamesRgbTable() { "yellow" =>0xffff00, "black" =>0x000000, "aquamarine" =>0x70db93, - "baker\'schocolate" =>0x5c3317, + "bakerschocolate" =>0x5c3317, "blueviolet" =>0x9f5f9f, "brass" =>0xb5a642, "brightgold" =>0xd9d919, @@ -94,7 +103,7 @@ sub NamesRgbTable() { "firebrick" =>0x8e2323, "flesh" =>0xf5ccb0, "forestgreen" =>0x238e23, - "gold" =>0xcd7f32, + "gold" =>0xcd7f32, # "goldenrod" =>0xdbdb70, "grey" =>0x545454, "greencopper" =>0x856363, @@ -102,7 +111,7 @@ sub NamesRgbTable() { "huntergreen" =>0x8e2323, "indianred" =>0xf5ccb0, "khaki" =>0x238e23, - "lightblue" =>0xcd7f32, + "lightblue" =>0xcdd9d9, # "lightgrey" =>0xdbdb70, "lightsteelblue" =>0x545454, "lightwood" =>0x856363, @@ -110,7 +119,7 @@ sub NamesRgbTable() { "mandarianorange" =>0x8e2323, "maroon" =>0xf5ccb0, "mediumaquamarine" =>0x238e23, - "mediumblue" =>0xcd7f32, + "mediumblue" =>0x3232cd, # "mediumforestgreen" =>0xdbdb70, "mediumgoldenrod" =>0xeaeaae, "mediumorchid" =>0x9370db, @@ -138,7 +147,7 @@ sub NamesRgbTable() { "salmon" =>0x6f4242, "scarlet" =>0x8c1717, "seagreen" =>0x238e68, - "semi-sweetchocolate" =>0x6b4226, + "semisweetchocolate" =>0x6b4226, "sienna" =>0x8e6b23, "silver" =>0xe6e8fa, "skyblue" =>0x3299cc, @@ -159,6 +168,8 @@ sub NamesRgbTable() { }; } + 1; __END__ + diff --git a/lib/Graphics/ColorNames/Windows.pm b/lib/Graphics/ColorNames/Windows.pm index 0905386..ef39abc 100644..100755 --- a/lib/Graphics/ColorNames/Windows.pm +++ b/lib/Graphics/ColorNames/Windows.pm @@ -26,19 +26,18 @@ Robert Rothenberg <rrwo at cpan.org> =head1 LICENSE -Copyright (c) 2001-2004 Robert Rothenberg. All rights reserved. +Copyright (c) 2001-2008 Robert Rothenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut -require 5.006; - use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '2.11'; +#$VERSION = eval $VERSION; sub NamesRgbTable() { use integer; diff --git a/lib/Graphics/ColorNames/X.pm b/lib/Graphics/ColorNames/X.pm index 19220df..481f329 100644..100755 --- a/lib/Graphics/ColorNames/X.pm +++ b/lib/Graphics/ColorNames/X.pm @@ -1,820 +1,727 @@ -package Graphics::ColorNames::X;
-
-=head1 NAME
-
-Graphics::ColorNames::X - X-Windows color names and equivalent RGB values
-
-=head1 SYNOPSIS
-
- require Graphics::ColorNames::X;
-
- $NameTable = Graphics::ColorNames::X->NamesRgbTable();
- $RgbBlack = $NameTable->{black};
-
-=head1 DESCRIPTION
-
-This module defines color names and their associated RGB values used in
-X-Windows (from the X-Windows C<rgb.txt> file).
-
-=head1 SEE ALSO
-
-L<Graphics::ColorNames>, rgb.txt
-
-=head1 AUTHOR
-
-Robert Rothenberg <rrwo at cpan.org>
-
-=head2 Acknowledgements
-
-Steve Pomeroy <steve_x at earthling.net> -- fixed the broken color definitions
-
-=head1 LICENSE
-
-Copyright (c) 2001-2004 Robert Rothenberg. All rights reserved.
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-=cut
-
-require 5.006;
-
-use strict;
-use warnings;
-
-our $VERSION = '1.06';
-
-# Original name and colors (v1.01 and earlier) from Kevin J. Walsh,
-# http://eies.njit.edu/~walsh/rgb.html
-
-# Afterwards, XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp
-# Verified with Xorg: rgb.txt,v 1.3 2000/08/17 19:54:00 cpqbld Exp
-
-sub NamesRgbTable() {
- use integer;
- return {
- "snow" => 0xfffafa,
- "ghost white" => 0xf8f8ff,
- "ghostwhite" => 0xf8f8ff,
- "white smoke" => 0xf5f5f5,
- "whitesmoke" => 0xf5f5f5,
- "gainsboro" => 0xdcdcdc,
- "floral white" => 0xfffaf0,
- "floralwhite" => 0xfffaf0,
- "old lace" => 0xfdf5e6,
- "oldlace" => 0xfdf5e6,
- "linen" => 0xfaf0e6,
- "antique white" => 0xfaebd7,
- "antiquewhite" => 0xfaebd7,
- "papaya whip" => 0xffefd5,
- "papayawhip" => 0xffefd5,
- "blanched almond" => 0xffebcd,
- "blanchedalmond" => 0xffebcd,
- "bisque" => 0xffe4c4,
- "peach puff" => 0xffdab9,
- "peachpuff" => 0xffdab9,
- "navajo white" => 0xffdead,
- "navajowhite" => 0xffdead,
- "moccasin" => 0xffe4b5,
- "cornsilk" => 0xfff8dc,
- "ivory" => 0xfffff0,
- "lemon chiffon" => 0xfffacd,
- "lemonchiffon" => 0xfffacd,
- "seashell" => 0xfff5ee,
- "honeydew" => 0xf0fff0,
- "mint cream" => 0xf5fffa,
- "mintcream" => 0xf5fffa,
- "azure" => 0xf0ffff,
- "alice blue" => 0xf0f8ff,
- "aliceblue" => 0xf0f8ff,
- "lavender" => 0xe6e6fa,
- "lavender blush" => 0xfff0f5,
- "lavenderblush" => 0xfff0f5,
- "misty rose" => 0xffe4e1,
- "mistyrose" => 0xffe4e1,
- "white" => 0xffffff,
- "black" => 0x000000,
- "dark slate gray" => 0x2f4f4f,
- "darkslategray" => 0x2f4f4f,
- "dark slate grey" => 0x2f4f4f,
- "darkslategrey" => 0x2f4f4f,
- "dim gray" => 0x696969,
- "dimgray" => 0x696969,
- "dim grey" => 0x696969,
- "dimgrey" => 0x696969,
- "slate gray" => 0x708090,
- "slategray" => 0x708090,
- "slate grey" => 0x708090,
- "slategrey" => 0x708090,
- "light slate gray" => 0x778899,
- "lightslategray" => 0x778899,
- "light slate grey" => 0x778899,
- "lightslategrey" => 0x778899,
- "gray" => 0xbebebe,
- "grey" => 0xbebebe,
- "light grey" => 0xd3d3d3,
- "lightgrey" => 0xd3d3d3,
- "light gray" => 0xd3d3d3,
- "lightgray" => 0xd3d3d3,
- "midnight blue" => 0x191970,
- "midnightblue" => 0x191970,
- "navy" => 0x000080,
- "navy blue" => 0x000080,
- "navyblue" => 0x000080,
- "cornflower blue" => 0x6495ed,
- "cornflowerblue" => 0x6495ed,
- "dark slate blue" => 0x483d8b,
- "darkslateblue" => 0x483d8b,
- "slate blue" => 0x6a5acd,
- "slateblue" => 0x6a5acd,
- "medium slate blue" => 0x7b68ee,
- "mediumslateblue" => 0x7b68ee,
- "light slate blue" => 0x8470ff,
- "lightslateblue" => 0x8470ff,
- "medium blue" => 0x0000cd,
- "mediumblue" => 0x0000cd,
- "royal blue" => 0x4169e1,
- "royalblue" => 0x4169e1,
- "blue" => 0x0000ff,
- "dodger blue" => 0x1e90ff,
- "dodgerblue" => 0x1e90ff,
- "deep sky blue" => 0x00bfff,
- "deepskyblue" => 0x00bfff,
- "sky blue" => 0x87ceeb,
- "skyblue" => 0x87ceeb,
- "light sky blue" => 0x87cefa,
- "lightskyblue" => 0x87cefa,
- "steel blue" => 0x4682b4,
- "steelblue" => 0x4682b4,
- "light steel blue" => 0xb0c4de,
- "lightsteelblue" => 0xb0c4de,
- "light blue" => 0xadd8e6,
- "lightblue" => 0xadd8e6,
- "powder blue" => 0xb0e0e6,
- "powderblue" => 0xb0e0e6,
- "pale turquoise" => 0xafeeee,
- "paleturquoise" => 0xafeeee,
- "dark turquoise" => 0x00ced1,
- "darkturquoise" => 0x00ced1,
- "medium turquoise" => 0x48d1cc,
- "mediumturquoise" => 0x48d1cc,
- "turquoise" => 0x40e0d0,
- "cyan" => 0x00ffff,
- "light cyan" => 0xe0ffff,
- "lightcyan" => 0xe0ffff,
- "cadet blue" => 0x5f9ea0,
- "cadetblue" => 0x5f9ea0,
- "medium aquamarine" => 0x66cdaa,
- "mediumaquamarine" => 0x66cdaa,
- "aquamarine" => 0x7fffd4,
- "dark green" => 0x006400,
- "darkgreen" => 0x006400,
- "dark olive green" => 0x556b2f,
- "darkolivegreen" => 0x556b2f,
- "dark sea green" => 0x8fbc8f,
- "darkseagreen" => 0x8fbc8f,
- "sea green" => 0x2e8b57,
- "seagreen" => 0x2e8b57,
- "medium sea green" => 0x3cb371,
- "mediumseagreen" => 0x3cb371,
- "light sea green" => 0x20b2aa,
- "lightseagreen" => 0x20b2aa,
- "pale green" => 0x98fb98,
- "palegreen" => 0x98fb98,
- "spring green" => 0x00ff7f,
- "springgreen" => 0x00ff7f,
- "lawn green" => 0x7cfc00,
- "lawngreen" => 0x7cfc00,
- "green" => 0x00ff00,
- "chartreuse" => 0x7fff00,
- "medium spring green" => 0x00fa9a,
- "mediumspringgreen" => 0x00fa9a,
- "green yellow" => 0xadff2f,
- "greenyellow" => 0xadff2f,
- "lime green" => 0x32cd32,
- "limegreen" => 0x32cd32,
- "yellow green" => 0x9acd32,
- "yellowgreen" => 0x9acd32,
- "forest green" => 0x228b22,
- "forestgreen" => 0x228b22,
- "olive drab" => 0x6b8e23,
- "olivedrab" => 0x6b8e23,
- "dark khaki" => 0xbdb76b,
- "darkkhaki" => 0xbdb76b,
- "khaki" => 0xf0e68c,
- "pale goldenrod" => 0xeee8aa,
- "palegoldenrod" => 0xeee8aa,
- "light goldenrod yellow"=> 0xfafad2,
- "lightgoldenrodyellow" => 0xfafad2,
- "light yellow" => 0xffffe0,
- "lightyellow" => 0xffffe0,
- "yellow" => 0xffff00,
- "gold" => 0xffd700,
- "light goldenrod" => 0xeedd82,
- "lightgoldenrod" => 0xeedd82,
- "goldenrod" => 0xdaa520,
- "dark goldenrod" => 0xb8860b,
- "darkgoldenrod" => 0xb8860b,
- "rosy brown" => 0xbc8f8f,
- "rosybrown" => 0xbc8f8f,
- "indian red" => 0xcd5c5c,
- "indianred" => 0xcd5c5c,
- "saddle brown" => 0x8b4513,
- "saddlebrown" => 0x8b4513,
- "sienna" => 0xa0522d,
- "peru" => 0xcd853f,
- "burlywood" => 0xdeb887,
- "beige" => 0xf5f5dc,
- "wheat" => 0xf5deb3,
- "sandy brown" => 0xf4a460,
- "sandybrown" => 0xf4a460,
- "tan" => 0xd2b48c,
- "chocolate" => 0xd2691e,
- "firebrick" => 0xb22222,
- "brown" => 0xa52a2a,
- "dark salmon" => 0xe9967a,
- "darksalmon" => 0xe9967a,
- "salmon" => 0xfa8072,
- "light salmon" => 0xffa07a,
- "lightsalmon" => 0xffa07a,
- "orange" => 0xffa500,
- "dark orange" => 0xff8c00,
- "darkorange" => 0xff8c00,
- "coral" => 0xff7f50,
- "light coral" => 0xf08080,
- "lightcoral" => 0xf08080,
- "tomato" => 0xff6347,
- "orange red" => 0xff4500,
- "orangered" => 0xff4500,
- "red" => 0xff0000,
- "hot pink" => 0xff69b4,
- "hotpink" => 0xff69b4,
- "deep pink" => 0xff1493,
- "deeppink" => 0xff1493,
- "pink" => 0xffc0cb,
- "light pink" => 0xffb6c1,
- "lightpink" => 0xffb6c1,
- "pale violet red" => 0xdb7093,
- "palevioletred" => 0xdb7093,
- "maroon" => 0xb03060,
- "medium violet red" => 0xc71585,
- "mediumvioletred" => 0xc71585,
- "violet red" => 0xd02090,
- "violetred" => 0xd02090,
- "magenta" => 0xff00ff,
- "violet" => 0xee82ee,
- "plum" => 0xdda0dd,
- "orchid" => 0xda70d6,
- "medium orchid" => 0xba55d3,
- "mediumorchid" => 0xba55d3,
- "dark orchid" => 0x9932cc,
- "darkorchid" => 0x9932cc,
- "dark violet" => 0x9400d3,
- "darkviolet" => 0x9400d3,
- "blue violet" => 0x8a2be2,
- "blueviolet" => 0x8a2be2,
- "purple" => 0xa020f0,
- "medium purple" => 0x9370db,
- "mediumpurple" => 0x9370db,
- "thistle" => 0xd8bfd8,
- "snow1" => 0xfffafa,
- "snow2" => 0xeee9e9,
- "snow3" => 0xcdc9c9,
- "snow4" => 0x8b8989,
- "seashell1" => 0xfff5ee,
- "seashell2" => 0xeee5de,
- "seashell3" => 0xcdc5bf,
- "seashell4" => 0x8b8682,
- "antiquewhite1" => 0xffefdb,
- "antiquewhite2" => 0xeedfcc,
- "antiquewhite3" => 0xcdc0b0,
- "antiquewhite4" => 0x8b8378,
- "bisque1" => 0xffe4c4,
- "bisque2" => 0xeed5b7,
- "bisque3" => 0xcdb79e,
- "bisque4" => 0x8b7d6b,
- "peachpuff1" => 0xffdab9,
- "peachpuff2" => 0xeecbad,
- "peachpuff3" => 0xcdaf95,
- "peachpuff4" => 0x8b7765,
- "navajowhite1" => 0xffdead,
- "navajowhite2" => 0xeecfa1,
- "navajowhite3" => 0xcdb38b,
- "navajowhite4" => 0x8b795e,
- "lemonchiffon1" => 0xfffacd,
- "lemonchiffon2" => 0xeee9bf,
- "lemonchiffon3" => 0xcdc9a5,
- "lemonchiffon4" => 0x8b8970,
- "cornsilk1" => 0xfff8dc,
- "cornsilk2" => 0xeee8cd,
- "cornsilk3" => 0xcdc8b1,
- "cornsilk4" => 0x8b8878,
- "ivory1" => 0xfffff0,
- "ivory2" => 0xeeeee0,
- "ivory3" => 0xcdcdc1,
- "ivory4" => 0x8b8b83,
- "honeydew1" => 0xf0fff0,
- "honeydew2" => 0xe0eee0,
- "honeydew3" => 0xc1cdc1,
- "honeydew4" => 0x838b83,
- "lavenderblush1" => 0xfff0f5,
- "lavenderblush2" => 0xeee0e5,
- "lavenderblush3" => 0xcdc1c5,
- "lavenderblush4" => 0x8b8386,
- "mistyrose1" => 0xffe4e1,
- "mistyrose2" => 0xeed5d2,
- "mistyrose3" => 0xcdb7b5,
- "mistyrose4" => 0x8b7d7b,
- "azure1" => 0xf0ffff,
- "azure2" => 0xe0eeee,
- "azure3" => 0xc1cdcd,
- "azure4" => 0x838b8b,
- "slateblue1" => 0x836fff,
- "slateblue2" => 0x7a67ee,
- "slateblue3" => 0x6959cd,
- "slateblue4" => 0x473c8b,
- "royalblue1" => 0x4876ff,
- "royalblue2" => 0x436eee,
- "royalblue3" => 0x3a5fcd,
- "royalblue4" => 0x27408b,
- "blue1" => 0x0000ff,
- "blue2" => 0x0000ee,
- "blue3" => 0x0000cd,
- "blue4" => 0x00008b,
- "dodgerblue1" => 0x1e90ff,
- "dodgerblue2" => 0x1c86ee,
- "dodgerblue3" => 0x1874cd,
- "dodgerblue4" => 0x104e8b,
- "steelblue1" => 0x63b8ff,
- "steelblue2" => 0x5cacee,
- "steelblue3" => 0x4f94cd,
- "steelblue4" => 0x36648b,
- "deepskyblue1" => 0x00bfff,
- "deepskyblue2" => 0x00b2ee,
- "deepskyblue3" => 0x009acd,
- "deepskyblue4" => 0x00688b,
- "skyblue1" => 0x87ceff,
- "skyblue2" => 0x7ec0ee,
- "skyblue3" => 0x6ca6cd,
- "skyblue4" => 0x4a708b,
- "lightskyblue1" => 0xb0e2ff,
- "lightskyblue2" => 0xa4d3ee,
- "lightskyblue3" => 0x8db6cd,
- "lightskyblue4" => 0x607b8b,
- "slategray1" => 0xc6e2ff,
- "slategray2" => 0xb9d3ee,
- "slategray3" => 0x9fb6cd,
- "slategray4" => 0x6c7b8b,
- "slategrey1" => 0xc6e2ff,
- "slategrey2" => 0xb9d3ee,
- "slategrey3" => 0x9fb6cd,
- "slategrey4" => 0x6c7b8b,
- "lightsteelblue1" => 0xcae1ff,
- "lightsteelblue2" => 0xbcd2ee,
- "lightsteelblue3" => 0xa2b5cd,
- "lightsteelblue4" => 0x6e7b8b,
- "lightblue1" => 0xbfefff,
- "lightblue2" => 0xb2dfee,
- "lightblue3" => 0x9ac0cd,
- "lightblue4" => 0x68838b,
- "lightcyan1" => 0xe0ffff,
- "lightcyan2" => 0xd1eeee,
- "lightcyan3" => 0xb4cdcd,
- "lightcyan4" => 0x7a8b8b,
- "paleturquoise1" => 0xbbffff,
- "paleturquoise2" => 0xaeeeee,
- "paleturquoise3" => 0x96cdcd,
- "paleturquoise4" => 0x668b8b,
- "cadetblue1" => 0x98f5ff,
- "cadetblue2" => 0x8ee5ee,
- "cadetblue3" => 0x7ac5cd,
- "cadetblue4" => 0x53868b,
- "turquoise1" => 0x00f5ff,
- "turquoise2" => 0x00e5ee,
- "turquoise3" => 0x00c5cd,
- "turquoise4" => 0x00868b,
- "cyan1" => 0x00ffff,
- "cyan2" => 0x00eeee,
- "cyan3" => 0x00cdcd,
- "cyan4" => 0x008b8b,
- "darkslategray1" => 0x97ffff,
- "darkslategray2" => 0x8deeee,
- "darkslategray3" => 0x79cdcd,
- "darkslategray4" => 0x528b8b,
- "darkslategrey1" => 0x97ffff,
- "darkslategrey2" => 0x8deeee,
- "darkslategrey3" => 0x79cdcd,
- "darkslategrey4" => 0x528b8b,
- "aquamarine1" => 0x7fffd4,
- "aquamarine2" => 0x76eec6,
- "aquamarine3" => 0x66cdaa,
- "aquamarine4" => 0x458b74,
- "darkseagreen1" => 0xc1ffc1,
- "darkseagreen2" => 0xb4eeb4,
- "darkseagreen3" => 0x9bcd9b,
- "darkseagreen4" => 0x698b69,
- "seagreen1" => 0x54ff9f,
- "seagreen2" => 0x4eee94,
- "seagreen3" => 0x43cd80,
- "seagreen4" => 0x2e8b57,
- "palegreen1" => 0x9aff9a,
- "palegreen2" => 0x90ee90,
- "palegreen3" => 0x7ccd7c,
- "palegreen4" => 0x548b54,
- "springgreen1" => 0x00ff7f,
- "springgreen2" => 0x00ee76,
- "springgreen3" => 0x00cd66,
- "springgreen4" => 0x008b45,
- "green1" => 0x00ff00,
- "green2" => 0x00ee00,
- "green3" => 0x00cd00,
- "green4" => 0x008b00,
- "chartreuse1" => 0x7fff00,
- "chartreuse2" => 0x76ee00,
- "chartreuse3" => 0x66cd00,
- "chartreuse4" => 0x458b00,
- "olivedrab1" => 0xc0ff3e,
- "olivedrab2" => 0xb3ee3a,
- "olivedrab3" => 0x9acd32,
- "olivedrab4" => 0x698b22,
- "darkolivegreen1" => 0xcaff70,
- "darkolivegreen2" => 0xbcee68,
- "darkolivegreen3" => 0xa2cd5a,
- "darkolivegreen4" => 0x6e8b3d,
- "khaki1" => 0xfff68f,
- "khaki2" => 0xeee685,
- "khaki3" => 0xcdc673,
- "khaki4" => 0x8b864e,
- "lightgoldenrod1" => 0xffec8b,
- "lightgoldenrod2" => 0xeedc82,
- "lightgoldenrod3" => 0xcdbe70,
- "lightgoldenrod4" => 0x8b814c,
- "lightyellow1" => 0xffffe0,
- "lightyellow2" => 0xeeeed1,
- "lightyellow3" => 0xcdcdb4,
- "lightyellow4" => 0x8b8b7a,
- "yellow1" => 0xffff00,
- "yellow2" => 0xeeee00,
- "yellow3" => 0xcdcd00,
- "yellow4" => 0x8b8b00,
- "gold1" => 0xffd700,
- "gold2" => 0xeec900,
- "gold3" => 0xcdad00,
- "gold4" => 0x8b7500,
- "goldenrod1" => 0xffc125,
- "goldenrod2" => 0xeeb422,
- "goldenrod3" => 0xcd9b1d,
- "goldenrod4" => 0x8b6914,
- "darkgoldenrod1" => 0xffb90f,
- "darkgoldenrod2" => 0xeead0e,
- "darkgoldenrod3" => 0xcd950c,
- "darkgoldenrod4" => 0x8b6508,
- "rosybrown1" => 0xffc1c1,
- "rosybrown2" => 0xeeb4b4,
- "rosybrown3" => 0xcd9b9b,
- "rosybrown4" => 0x8b6969,
- "indianred1" => 0xff6a6a,
- "indianred2" => 0xee6363,
- "indianred3" => 0xcd5555,
- "indianred4" => 0x8b3a3a,
- "sienna1" => 0xff8247,
- "sienna2" => 0xee7942,
- "sienna3" => 0xcd6839,
- "sienna4" => 0x8b4726,
- "burlywood1" => 0xffd39b,
- "burlywood2" => 0xeec591,
- "burlywood3" => 0xcdaa7d,
- "burlywood4" => 0x8b7355,
- "wheat1" => 0xffe7ba,
- "wheat2" => 0xeed8ae,
- "wheat3" => 0xcdba96,
- "wheat4" => 0x8b7e66,
- "tan1" => 0xffa54f,
- "tan2" => 0xee9a49,
- "tan3" => 0xcd853f,
- "tan4" => 0x8b5a2b,
- "chocolate1" => 0xff7f24,
- "chocolate2" => 0xee7621,
- "chocolate3" => 0xcd661d,
- "chocolate4" => 0x8b4513,
- "firebrick1" => 0xff3030,
- "firebrick2" => 0xee2c2c,
- "firebrick3" => 0xcd2626,
- "firebrick4" => 0x8b1a1a,
- "brown1" => 0xff4040,
- "brown2" => 0xee3b3b,
- "brown3" => 0xcd3333,
- "brown4" => 0x8b2323,
- "salmon1" => 0xff8c69,
- "salmon2" => 0xee8262,
- "salmon3" => 0xcd7054,
- "salmon4" => 0x8b4c39,
- "lightsalmon1" => 0xffa07a,
- "lightsalmon2" => 0xee9572,
- "lightsalmon3" => 0xcd8162,
- "lightsalmon4" => 0x8b5742,
- "orange1" => 0xffa500,
- "orange2" => 0xee9a00,
- "orange3" => 0xcd8500,
- "orange4" => 0x8b5a00,
- "darkorange1" => 0xff7f00,
- "darkorange2" => 0xee7600,
- "darkorange3" => 0xcd6600,
- "darkorange4" => 0x8b4500,
- "coral1" => 0xff7256,
- "coral2" => 0xee6a50,
- "coral3" => 0xcd5b45,
- "coral4" => 0x8b3e2f,
- "tomato1" => 0xff6347,
- "tomato2" => 0xee5c42,
- "tomato3" => 0xcd4f39,
- "tomato4" => 0x8b3626,
- "orangered1" => 0xff4500,
- "orangered2" => 0xee4000,
- "orangered3" => 0xcd3700,
- "orangered4" => 0x8b2500,
- "red1" => 0xff0000,
- "red2" => 0xee0000,
- "red3" => 0xcd0000,
- "red4" => 0x8b0000,
- "deeppink1" => 0xff1493,
- "deeppink2" => 0xee1289,
- "deeppink3" => 0xcd1076,
- "deeppink4" => 0x8b0a50,
- "hotpink1" => 0xff6eb4,
- "hotpink2" => 0xee6aa7,
- "hotpink3" => 0xcd6090,
- "hotpink4" => 0x8b3a62,
- "pink1" => 0xffb5c5,
- "pink2" => 0xeea9b8,
- "pink3" => 0xcd919e,
- "pink4" => 0x8b636c,
- "lightpink1" => 0xffaeb9,
- "lightpink2" => 0xeea2ad,
- "lightpink3" => 0xcd8c95,
- "lightpink4" => 0x8b5f65,
- "palevioletred1" => 0xff82ab,
- "palevioletred2" => 0xee799f,
- "palevioletred3" => 0xcd6889,
- "palevioletred4" => 0x8b475d,
- "maroon1" => 0xff34b3,
- "maroon2" => 0xee30a7,
- "maroon3" => 0xcd2990,
- "maroon4" => 0x8b1c62,
- "violetred1" => 0xff3e96,
- "violetred2" => 0xee3a8c,
- "violetred3" => 0xcd3278,
- "violetred4" => 0x8b2252,
- "magenta1" => 0xff00ff,
- "magenta2" => 0xee00ee,
- "magenta3" => 0xcd00cd,
- "magenta4" => 0x8b008b,
- "orchid1" => 0xff83fa,
- "orchid2" => 0xee7ae9,
- "orchid3" => 0xcd69c9,
- "orchid4" => 0x8b4789,
- "plum1" => 0xffbbff,
- "plum2" => 0xeeaeee,
- "plum3" => 0xcd96cd,
- "plum4" => 0x8b668b,
- "mediumorchid1" => 0xe066ff,
- "mediumorchid2" => 0xd15fee,
- "mediumorchid3" => 0xb452cd,
- "mediumorchid4" => 0x7a378b,
- "darkorchid1" => 0xbf3eff,
- "darkorchid2" => 0xb23aee,
- "darkorchid3" => 0x9a32cd,
- "darkorchid4" => 0x68228b,
- "purple1" => 0x9b30ff,
- "purple2" => 0x912cee,
- "purple3" => 0x7d26cd,
- "purple4" => 0x551a8b,
- "mediumpurple1" => 0xab82ff,
- "mediumpurple2" => 0x9f79ee,
- "mediumpurple3" => 0x8968cd,
- "mediumpurple4" => 0x5d478b,
- "thistle1" => 0xffe1ff,
- "thistle2" => 0xeed2ee,
- "thistle3" => 0xcdb5cd,
- "thistle4" => 0x8b7b8b,
- "gray0" => 0x000000,
- "gray1" => 0x030303,
- "gray2" => 0x050505,
- "gray3" => 0x080808,
- "gray4" => 0x0a0a0a,
- "gray5" => 0x0d0d0d,
- "gray6" => 0x0f0f0f,
- "gray7" => 0x121212,
- "gray8" => 0x141414,
- "gray9" => 0x171717,
- "gray10" => 0x1a1a1a,
- "gray11" => 0x1c1c1c,
- "gray12" => 0x1f1f1f,
- "gray13" => 0x212121,
- "gray14" => 0x242424,
- "gray15" => 0x262626,
- "gray16" => 0x292929,
- "gray17" => 0x2b2b2b,
- "gray18" => 0x2e2e2e,
- "gray19" => 0x303030,
- "gray20" => 0x333333,
- "gray21" => 0x363636,
- "gray22" => 0x383838,
- "gray23" => 0x3b3b3b,
- "gray24" => 0x3d3d3d,
- "gray25" => 0x404040,
- "gray26" => 0x424242,
- "gray27" => 0x454545,
- "gray28" => 0x474747,
- "gray29" => 0x4a4a4a,
- "gray30" => 0x4d4d4d,
- "gray31" => 0x4f4f4f,
- "gray32" => 0x525252,
- "gray33" => 0x545454,
- "gray34" => 0x575757,
- "gray35" => 0x595959,
- "gray36" => 0x5c5c5c,
- "gray37" => 0x5e5e5e,
- "gray38" => 0x616161,
- "gray39" => 0x636363,
- "gray40" => 0x666666,
- "gray41" => 0x696969,
- "gray42" => 0x6b6b6b,
- "gray43" => 0x6e6e6e,
- "gray44" => 0x707070,
- "gray45" => 0x737373,
- "gray46" => 0x757575,
- "gray47" => 0x787878,
- "gray48" => 0x7a7a7a,
- "gray49" => 0x7d7d7d,
- "gray50" => 0x7f7f7f,
- "gray51" => 0x828282,
- "gray52" => 0x858585,
- "gray53" => 0x878787,
- "gray54" => 0x8a8a8a,
- "gray55" => 0x8c8c8c,
- "gray56" => 0x8f8f8f,
- "gray57" => 0x919191,
- "gray58" => 0x949494,
- "gray59" => 0x969696,
- "gray60" => 0x999999,
- "gray61" => 0x9c9c9c,
- "gray62" => 0x9e9e9e,
- "gray63" => 0xa1a1a1,
- "gray64" => 0xa3a3a3,
- "gray65" => 0xa6a6a6,
- "gray66" => 0xa8a8a8,
- "gray67" => 0xababab,
- "gray68" => 0xadadad,
- "gray69" => 0xb0b0b0,
- "gray70" => 0xb3b3b3,
- "gray71" => 0xb5b5b5,
- "gray72" => 0xb8b8b8,
- "gray73" => 0xbababa,
- "gray74" => 0xbdbdbd,
- "gray75" => 0xbfbfbf,
- "gray76" => 0xc2c2c2,
- "gray77" => 0xc4c4c4,
- "gray78" => 0xc7c7c7,
- "gray79" => 0xc9c9c9,
- "gray80" => 0xcccccc,
- "gray81" => 0xcfcfcf,
- "gray82" => 0xd1d1d1,
- "gray83" => 0xd4d4d4,
- "gray84" => 0xd6d6d6,
- "gray85" => 0xd9d9d9,
- "gray86" => 0xdbdbdb,
- "gray87" => 0xdedede,
- "gray88" => 0xe0e0e0,
- "gray89" => 0xe3e3e3,
- "gray90" => 0xe5e5e5,
- "gray91" => 0xe8e8e8,
- "gray92" => 0xebebeb,
- "gray93" => 0xededed,
- "gray94" => 0xf0f0f0,
- "gray95" => 0xf2f2f2,
- "gray96" => 0xf5f5f5,
- "gray97" => 0xf7f7f7,
- "gray98" => 0xfafafa,
- "gray99" => 0xfcfcfc,
- "gray100" => 0xffffff,
- "grey0" => 0x000000,
- "grey1" => 0x030303,
- "grey2" => 0x050505,
- "grey3" => 0x080808,
- "grey4" => 0x0a0a0a,
- "grey5" => 0x0d0d0d,
- "grey6" => 0x0f0f0f,
- "grey7" => 0x121212,
- "grey8" => 0x141414,
- "grey9" => 0x171717,
- "grey10" => 0x1a1a1a,
- "grey11" => 0x1c1c1c,
- "grey12" => 0x1f1f1f,
- "grey13" => 0x212121,
- "grey14" => 0x242424,
- "grey15" => 0x262626,
- "grey16" => 0x292929,
- "grey17" => 0x2b2b2b,
- "grey18" => 0x2e2e2e,
- "grey19" => 0x303030,
- "grey20" => 0x333333,
- "grey21" => 0x363636,
- "grey22" => 0x383838,
- "grey23" => 0x3b3b3b,
- "grey24" => 0x3d3d3d,
- "grey25" => 0x404040,
- "grey26" => 0x424242,
- "grey27" => 0x454545,
- "grey28" => 0x474747,
- "grey29" => 0x4a4a4a,
- "grey30" => 0x4d4d4d,
- "grey31" => 0x4f4f4f,
- "grey32" => 0x525252,
- "grey33" => 0x545454,
- "grey34" => 0x575757,
- "grey35" => 0x595959,
- "grey36" => 0x5c5c5c,
- "grey37" => 0x5e5e5e,
- "grey38" => 0x616161,
- "grey39" => 0x636363,
- "grey40" => 0x666666,
- "grey41" => 0x696969,
- "grey42" => 0x6b6b6b,
- "grey43" => 0x6e6e6e,
- "grey44" => 0x707070,
- "grey45" => 0x737373,
- "grey46" => 0x757575,
- "grey47" => 0x787878,
- "grey48" => 0x7a7a7a,
- "grey49" => 0x7d7d7d,
- "grey50" => 0x7f7f7f,
- "grey51" => 0x828282,
- "grey52" => 0x858585,
- "grey53" => 0x878787,
- "grey54" => 0x8a8a8a,
- "grey55" => 0x8c8c8c,
- "grey56" => 0x8f8f8f,
- "grey57" => 0x919191,
- "grey58" => 0x949494,
- "grey59" => 0x969696,
- "grey60" => 0x999999,
- "grey61" => 0x9c9c9c,
- "grey62" => 0x9e9e9e,
- "grey63" => 0xa1a1a1,
- "grey64" => 0xa3a3a3,
- "grey65" => 0xa6a6a6,
- "grey66" => 0xa8a8a8,
- "grey67" => 0xababab,
- "grey68" => 0xadadad,
- "grey69" => 0xb0b0b0,
- "grey70" => 0xb3b3b3,
- "grey71" => 0xb5b5b5,
- "grey72" => 0xb8b8b8,
- "grey73" => 0xbababa,
- "grey74" => 0xbdbdbd,
- "grey75" => 0xbfbfbf,
- "grey76" => 0xc2c2c2,
- "grey77" => 0xc4c4c4,
- "grey78" => 0xc7c7c7,
- "grey79" => 0xc9c9c9,
- "grey80" => 0xcccccc,
- "grey81" => 0xcfcfcf,
- "grey82" => 0xd1d1d1,
- "grey83" => 0xd4d4d4,
- "grey84" => 0xd6d6d6,
- "grey85" => 0xd9d9d9,
- "grey86" => 0xdbdbdb,
- "grey87" => 0xdedede,
- "grey88" => 0xe0e0e0,
- "grey89" => 0xe3e3e3,
- "grey90" => 0xe5e5e5,
- "grey91" => 0xe8e8e8,
- "grey92" => 0xebebeb,
- "grey93" => 0xededed,
- "grey94" => 0xf0f0f0,
- "grey95" => 0xf2f2f2,
- "grey96" => 0xf5f5f5,
- "grey97" => 0xf7f7f7,
- "grey98" => 0xfafafa,
- "grey99" => 0xfcfcfc,
- "grey100" => 0xffffff,
- "dark grey" => 0xa9a9a9,
- "darkgrey" => 0xa9a9a9,
- "dark gray" => 0xa9a9a9,
- "darkgray" => 0xa9a9a9,
- "dark blue" => 0x00008b,
- "darkblue" => 0x00008b,
- "dark cyan" => 0x008b8b,
- "darkcyan" => 0x008b8b,
- "dark magenta" => 0x8b008b,
- "darkmagenta" => 0x8b008b,
- "dark red" => 0x8b0000,
- "darkred" => 0x8b0000,
- "light green" => 0x90ee90,
- "lightgreen" => 0x90ee90,
- };
-}
-
-1;
-
-__END__
+package Graphics::ColorNames::X; + +=head1 NAME + +Graphics::ColorNames::X - X-Windows color names and equivalent RGB values + +=head1 SYNOPSIS + + require Graphics::ColorNames::X; + + $NameTable = Graphics::ColorNames::X->NamesRgbTable(); + $RgbBlack = $NameTable->{black}; + +=head1 DESCRIPTION + +This module defines color names and their associated RGB values used in +X-Windows (from the X-Windows C<rgb.txt> file). + +=head1 SEE ALSO + +L<Graphics::ColorNames>, rgb.txt + +=head1 AUTHOR + +Robert Rothenberg <rrwo at cpan.org> + +=head2 Acknowledgements + +Steve Pomeroy <steve_x at earthling.net> -- fixed the broken color definitions + +=head1 LICENSE + +Copyright (c) 2001-2008 Robert Rothenberg. All rights reserved. +This program is free software; you can redistribute it and/or +modify it under the same terms as Perl itself. + +=cut + +use strict; +use warnings; + +our $VERSION = '2.11'; +#$VERSION = eval $VERSION; + +# Original name and colors (v1.01 and earlier) from Kevin J. Walsh, +# http://eies.njit.edu/~walsh/rgb.html + +# Afterwards, XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp +# Verified with Xorg: rgb.txt,v 1.3 2000/08/17 19:54:00 cpqbld Exp + +# Duplicate namesiwth spaces were removed in v2.10. + +sub NamesRgbTable() { + use integer; + return { + "snow" => 0xfffafa, + "ghostwhite" => 0xf8f8ff, + "whitesmoke" => 0xf5f5f5, + "gainsboro" => 0xdcdcdc, + "floralwhite" => 0xfffaf0, + "oldlace" => 0xfdf5e6, + "linen" => 0xfaf0e6, + "antiquewhite" => 0xfaebd7, + "papayawhip" => 0xffefd5, + "blanchedalmond" => 0xffebcd, + "bisque" => 0xffe4c4, + "peachpuff" => 0xffdab9, + "navajowhite" => 0xffdead, + "moccasin" => 0xffe4b5, + "cornsilk" => 0xfff8dc, + "ivory" => 0xfffff0, + "lemonchiffon" => 0xfffacd, + "seashell" => 0xfff5ee, + "honeydew" => 0xf0fff0, + "mintcream" => 0xf5fffa, + "azure" => 0xf0ffff, + "aliceblue" => 0xf0f8ff, + "lavender" => 0xe6e6fa, + "lavenderblush" => 0xfff0f5, + "mistyrose" => 0xffe4e1, + "white" => 0xffffff, + "black" => 0x000000, + "darkslategray" => 0x2f4f4f, + "darkslategrey" => 0x2f4f4f, + "dimgray" => 0x696969, + "dimgrey" => 0x696969, + "slategray" => 0x708090, + "slategrey" => 0x708090, + "lightslategray" => 0x778899, + "lightslategrey" => 0x778899, + "gray" => 0xbebebe, + "grey" => 0xbebebe, + "lightgrey" => 0xd3d3d3, + "lightgray" => 0xd3d3d3, + "midnightblue" => 0x191970, + "navy" => 0x000080, + "navyblue" => 0x000080, + "cornflowerblue" => 0x6495ed, + "darkslateblue" => 0x483d8b, + "slateblue" => 0x6a5acd, + "mediumslateblue" => 0x7b68ee, + "lightslateblue" => 0x8470ff, + "mediumblue" => 0x0000cd, + "royalblue" => 0x4169e1, + "blue" => 0x0000ff, + "dodgerblue" => 0x1e90ff, + "deepskyblue" => 0x00bfff, + "skyblue" => 0x87ceeb, + "lightskyblue" => 0x87cefa, + "steelblue" => 0x4682b4, + "lightsteelblue" => 0xb0c4de, + "lightblue" => 0xadd8e6, + "powderblue" => 0xb0e0e6, + "paleturquoise" => 0xafeeee, + "darkturquoise" => 0x00ced1, + "mediumturquoise" => 0x48d1cc, + "turquoise" => 0x40e0d0, + "cyan" => 0x00ffff, + "lightcyan" => 0xe0ffff, + "cadetblue" => 0x5f9ea0, + "mediumaquamarine" => 0x66cdaa, + "aquamarine" => 0x7fffd4, + "darkgreen" => 0x006400, + "darkolivegreen" => 0x556b2f, + "darkseagreen" => 0x8fbc8f, + "seagreen" => 0x2e8b57, + "mediumseagreen" => 0x3cb371, + "lightseagreen" => 0x20b2aa, + "palegreen" => 0x98fb98, + "springgreen" => 0x00ff7f, + "lawngreen" => 0x7cfc00, + "green" => 0x00ff00, + "chartreuse" => 0x7fff00, + "mediumspringgreen" => 0x00fa9a, + "greenyellow" => 0xadff2f, + "limegreen" => 0x32cd32, + "yellowgreen" => 0x9acd32, + "forestgreen" => 0x228b22, + "olivedrab" => 0x6b8e23, + "darkkhaki" => 0xbdb76b, + "khaki" => 0xf0e68c, + "palegoldenrod" => 0xeee8aa, + "lightgoldenrodyellow" => 0xfafad2, + "lightyellow" => 0xffffe0, + "yellow" => 0xffff00, + "gold" => 0xffd700, + "lightgoldenrod" => 0xeedd82, + "goldenrod" => 0xdaa520, + "darkgoldenrod" => 0xb8860b, + "rosybrown" => 0xbc8f8f, + "indianred" => 0xcd5c5c, + "saddlebrown" => 0x8b4513, + "sienna" => 0xa0522d, + "peru" => 0xcd853f, + "burlywood" => 0xdeb887, + "beige" => 0xf5f5dc, + "wheat" => 0xf5deb3, + "sandybrown" => 0xf4a460, + "tan" => 0xd2b48c, + "chocolate" => 0xd2691e, + "firebrick" => 0xb22222, + "brown" => 0xa52a2a, + "darksalmon" => 0xe9967a, + "salmon" => 0xfa8072, + "lightsalmon" => 0xffa07a, + "orange" => 0xffa500, + "darkorange" => 0xff8c00, + "coral" => 0xff7f50, + "lightcoral" => 0xf08080, + "tomato" => 0xff6347, + "orangered" => 0xff4500, + "red" => 0xff0000, + "hotpink" => 0xff69b4, + "deeppink" => 0xff1493, + "pink" => 0xffc0cb, + "lightpink" => 0xffb6c1, + "palevioletred" => 0xdb7093, + "maroon" => 0xb03060, + "mediumvioletred" => 0xc71585, + "violetred" => 0xd02090, + "magenta" => 0xff00ff, + "violet" => 0xee82ee, + "plum" => 0xdda0dd, + "orchid" => 0xda70d6, + "mediumorchid" => 0xba55d3, + "darkorchid" => 0x9932cc, + "darkviolet" => 0x9400d3, + "blueviolet" => 0x8a2be2, + "purple" => 0xa020f0, + "mediumpurple" => 0x9370db, + "thistle" => 0xd8bfd8, + "snow1" => 0xfffafa, + "snow2" => 0xeee9e9, + "snow3" => 0xcdc9c9, + "snow4" => 0x8b8989, + "seashell1" => 0xfff5ee, + "seashell2" => 0xeee5de, + "seashell3" => 0xcdc5bf, + "seashell4" => 0x8b8682, + "antiquewhite1" => 0xffefdb, + "antiquewhite2" => 0xeedfcc, + "antiquewhite3" => 0xcdc0b0, + "antiquewhite4" => 0x8b8378, + "bisque1" => 0xffe4c4, + "bisque2" => 0xeed5b7, + "bisque3" => 0xcdb79e, + "bisque4" => 0x8b7d6b, + "peachpuff1" => 0xffdab9, + "peachpuff2" => 0xeecbad, + "peachpuff3" => 0xcdaf95, + "peachpuff4" => 0x8b7765, + "navajowhite1" => 0xffdead, + "navajowhite2" => 0xeecfa1, + "navajowhite3" => 0xcdb38b, + "navajowhite4" => 0x8b795e, + "lemonchiffon1" => 0xfffacd, + "lemonchiffon2" => 0xeee9bf, + "lemonchiffon3" => 0xcdc9a5, + "lemonchiffon4" => 0x8b8970, + "cornsilk1" => 0xfff8dc, + "cornsilk2" => 0xeee8cd, + "cornsilk3" => 0xcdc8b1, + "cornsilk4" => 0x8b8878, + "ivory1" => 0xfffff0, + "ivory2" => 0xeeeee0, + "ivory3" => 0xcdcdc1, + "ivory4" => 0x8b8b83, + "honeydew1" => 0xf0fff0, + "honeydew2" => 0xe0eee0, + "honeydew3" => 0xc1cdc1, + "honeydew4" => 0x838b83, + "lavenderblush1" => 0xfff0f5, + "lavenderblush2" => 0xeee0e5, + "lavenderblush3" => 0xcdc1c5, + "lavenderblush4" => 0x8b8386, + "mistyrose1" => 0xffe4e1, + "mistyrose2" => 0xeed5d2, + "mistyrose3" => 0xcdb7b5, + "mistyrose4" => 0x8b7d7b, + "azure1" => 0xf0ffff, + "azure2" => 0xe0eeee, + "azure3" => 0xc1cdcd, + "azure4" => 0x838b8b, + "slateblue1" => 0x836fff, + "slateblue2" => 0x7a67ee, + "slateblue3" => 0x6959cd, + "slateblue4" => 0x473c8b, + "royalblue1" => 0x4876ff, + "royalblue2" => 0x436eee, + "royalblue3" => 0x3a5fcd, + "royalblue4" => 0x27408b, + "blue1" => 0x0000ff, + "blue2" => 0x0000ee, + "blue3" => 0x0000cd, + "blue4" => 0x00008b, + "dodgerblue1" => 0x1e90ff, + "dodgerblue2" => 0x1c86ee, + "dodgerblue3" => 0x1874cd, + "dodgerblue4" => 0x104e8b, + "steelblue1" => 0x63b8ff, + "steelblue2" => 0x5cacee, + "steelblue3" => 0x4f94cd, + "steelblue4" => 0x36648b, + "deepskyblue1" => 0x00bfff, + "deepskyblue2" => 0x00b2ee, + "deepskyblue3" => 0x009acd, + "deepskyblue4" => 0x00688b, + "skyblue1" => 0x87ceff, + "skyblue2" => 0x7ec0ee, + "skyblue3" => 0x6ca6cd, + "skyblue4" => 0x4a708b, + "lightskyblue1" => 0xb0e2ff, + "lightskyblue2" => 0xa4d3ee, + "lightskyblue3" => 0x8db6cd, + "lightskyblue4" => 0x607b8b, + "slategray1" => 0xc6e2ff, + "slategray2" => 0xb9d3ee, + "slategray3" => 0x9fb6cd, + "slategray4" => 0x6c7b8b, + "slategrey1" => 0xc6e2ff, + "slategrey2" => 0xb9d3ee, + "slategrey3" => 0x9fb6cd, + "slategrey4" => 0x6c7b8b, + "lightsteelblue1" => 0xcae1ff, + "lightsteelblue2" => 0xbcd2ee, + "lightsteelblue3" => 0xa2b5cd, + "lightsteelblue4" => 0x6e7b8b, + "lightblue1" => 0xbfefff, + "lightblue2" => 0xb2dfee, + "lightblue3" => 0x9ac0cd, + "lightblue4" => 0x68838b, + "lightcyan1" => 0xe0ffff, + "lightcyan2" => 0xd1eeee, + "lightcyan3" => 0xb4cdcd, + "lightcyan4" => 0x7a8b8b, + "paleturquoise1" => 0xbbffff, + "paleturquoise2" => 0xaeeeee, + "paleturquoise3" => 0x96cdcd, + "paleturquoise4" => 0x668b8b, + "cadetblue1" => 0x98f5ff, + "cadetblue2" => 0x8ee5ee, + "cadetblue3" => 0x7ac5cd, + "cadetblue4" => 0x53868b, + "turquoise1" => 0x00f5ff, + "turquoise2" => 0x00e5ee, + "turquoise3" => 0x00c5cd, + "turquoise4" => 0x00868b, + "cyan1" => 0x00ffff, + "cyan2" => 0x00eeee, + "cyan3" => 0x00cdcd, + "cyan4" => 0x008b8b, + "darkslategray1" => 0x97ffff, + "darkslategray2" => 0x8deeee, + "darkslategray3" => 0x79cdcd, + "darkslategray4" => 0x528b8b, + "darkslategrey1" => 0x97ffff, + "darkslategrey2" => 0x8deeee, + "darkslategrey3" => 0x79cdcd, + "darkslategrey4" => 0x528b8b, + "aquamarine1" => 0x7fffd4, + "aquamarine2" => 0x76eec6, + "aquamarine3" => 0x66cdaa, + "aquamarine4" => 0x458b74, + "darkseagreen1" => 0xc1ffc1, + "darkseagreen2" => 0xb4eeb4, + "darkseagreen3" => 0x9bcd9b, + "darkseagreen4" => 0x698b69, + "seagreen1" => 0x54ff9f, + "seagreen2" => 0x4eee94, + "seagreen3" => 0x43cd80, + "seagreen4" => 0x2e8b57, + "palegreen1" => 0x9aff9a, + "palegreen2" => 0x90ee90, + "palegreen3" => 0x7ccd7c, + "palegreen4" => 0x548b54, + "springgreen1" => 0x00ff7f, + "springgreen2" => 0x00ee76, + "springgreen3" => 0x00cd66, + "springgreen4" => 0x008b45, + "green1" => 0x00ff00, + "green2" => 0x00ee00, + "green3" => 0x00cd00, + "green4" => 0x008b00, + "chartreuse1" => 0x7fff00, + "chartreuse2" => 0x76ee00, + "chartreuse3" => 0x66cd00, + "chartreuse4" => 0x458b00, + "olivedrab1" => 0xc0ff3e, + "olivedrab2" => 0xb3ee3a, + "olivedrab3" => 0x9acd32, + "olivedrab4" => 0x698b22, + "darkolivegreen1" => 0xcaff70, + "darkolivegreen2" => 0xbcee68, + "darkolivegreen3" => 0xa2cd5a, + "darkolivegreen4" => 0x6e8b3d, + "khaki1" => 0xfff68f, + "khaki2" => 0xeee685, + "khaki3" => 0xcdc673, + "khaki4" => 0x8b864e, + "lightgoldenrod1" => 0xffec8b, + "lightgoldenrod2" => 0xeedc82, + "lightgoldenrod3" => 0xcdbe70, + "lightgoldenrod4" => 0x8b814c, + "lightyellow1" => 0xffffe0, + "lightyellow2" => 0xeeeed1, + "lightyellow3" => 0xcdcdb4, + "lightyellow4" => 0x8b8b7a, + "yellow1" => 0xffff00, + "yellow2" => 0xeeee00, + "yellow3" => 0xcdcd00, + "yellow4" => 0x8b8b00, + "gold1" => 0xffd700, + "gold2" => 0xeec900, + "gold3" => 0xcdad00, + "gold4" => 0x8b7500, + "goldenrod1" => 0xffc125, + "goldenrod2" => 0xeeb422, + "goldenrod3" => 0xcd9b1d, + "goldenrod4" => 0x8b6914, + "darkgoldenrod1" => 0xffb90f, + "darkgoldenrod2" => 0xeead0e, + "darkgoldenrod3" => 0xcd950c, + "darkgoldenrod4" => 0x8b6508, + "rosybrown1" => 0xffc1c1, + "rosybrown2" => 0xeeb4b4, + "rosybrown3" => 0xcd9b9b, + "rosybrown4" => 0x8b6969, + "indianred1" => 0xff6a6a, + "indianred2" => 0xee6363, + "indianred3" => 0xcd5555, + "indianred4" => 0x8b3a3a, + "sienna1" => 0xff8247, + "sienna2" => 0xee7942, + "sienna3" => 0xcd6839, + "sienna4" => 0x8b4726, + "burlywood1" => 0xffd39b, + "burlywood2" => 0xeec591, + "burlywood3" => 0xcdaa7d, + "burlywood4" => 0x8b7355, + "wheat1" => 0xffe7ba, + "wheat2" => 0xeed8ae, + "wheat3" => 0xcdba96, + "wheat4" => 0x8b7e66, + "tan1" => 0xffa54f, + "tan2" => 0xee9a49, + "tan3" => 0xcd853f, + "tan4" => 0x8b5a2b, + "chocolate1" => 0xff7f24, + "chocolate2" => 0xee7621, + "chocolate3" => 0xcd661d, + "chocolate4" => 0x8b4513, + "firebrick1" => 0xff3030, + "firebrick2" => 0xee2c2c, + "firebrick3" => 0xcd2626, + "firebrick4" => 0x8b1a1a, + "brown1" => 0xff4040, + "brown2" => 0xee3b3b, + "brown3" => 0xcd3333, + "brown4" => 0x8b2323, + "salmon1" => 0xff8c69, + "salmon2" => 0xee8262, + "salmon3" => 0xcd7054, + "salmon4" => 0x8b4c39, + "lightsalmon1" => 0xffa07a, + "lightsalmon2" => 0xee9572, + "lightsalmon3" => 0xcd8162, + "lightsalmon4" => 0x8b5742, + "orange1" => 0xffa500, + "orange2" => 0xee9a00, + "orange3" => 0xcd8500, + "orange4" => 0x8b5a00, + "darkorange1" => 0xff7f00, + "darkorange2" => 0xee7600, + "darkorange3" => 0xcd6600, + "darkorange4" => 0x8b4500, + "coral1" => 0xff7256, + "coral2" => 0xee6a50, + "coral3" => 0xcd5b45, + "coral4" => 0x8b3e2f, + "tomato1" => 0xff6347, + "tomato2" => 0xee5c42, + "tomato3" => 0xcd4f39, + "tomato4" => 0x8b3626, + "orangered1" => 0xff4500, + "orangered2" => 0xee4000, + "orangered3" => 0xcd3700, + "orangered4" => 0x8b2500, + "red1" => 0xff0000, + "red2" => 0xee0000, + "red3" => 0xcd0000, + "red4" => 0x8b0000, + "deeppink1" => 0xff1493, + "deeppink2" => 0xee1289, + "deeppink3" => 0xcd1076, + "deeppink4" => 0x8b0a50, + "hotpink1" => 0xff6eb4, + "hotpink2" => 0xee6aa7, + "hotpink3" => 0xcd6090, + "hotpink4" => 0x8b3a62, + "pink1" => 0xffb5c5, + "pink2" => 0xeea9b8, + "pink3" => 0xcd919e, + "pink4" => 0x8b636c, + "lightpink1" => 0xffaeb9, + "lightpink2" => 0xeea2ad, + "lightpink3" => 0xcd8c95, + "lightpink4" => 0x8b5f65, + "palevioletred1" => 0xff82ab, + "palevioletred2" => 0xee799f, + "palevioletred3" => 0xcd6889, + "palevioletred4" => 0x8b475d, + "maroon1" => 0xff34b3, + "maroon2" => 0xee30a7, + "maroon3" => 0xcd2990, + "maroon4" => 0x8b1c62, + "violetred1" => 0xff3e96, + "violetred2" => 0xee3a8c, + "violetred3" => 0xcd3278, + "violetred4" => 0x8b2252, + "magenta1" => 0xff00ff, + "magenta2" => 0xee00ee, + "magenta3" => 0xcd00cd, + "magenta4" => 0x8b008b, + "orchid1" => 0xff83fa, + "orchid2" => 0xee7ae9, + "orchid3" => 0xcd69c9, + "orchid4" => 0x8b4789, + "plum1" => 0xffbbff, + "plum2" => 0xeeaeee, + "plum3" => 0xcd96cd, + "plum4" => 0x8b668b, + "mediumorchid1" => 0xe066ff, + "mediumorchid2" => 0xd15fee, + "mediumorchid3" => 0xb452cd, + "mediumorchid4" => 0x7a378b, + "darkorchid1" => 0xbf3eff, + "darkorchid2" => 0xb23aee, + "darkorchid3" => 0x9a32cd, + "darkorchid4" => 0x68228b, + "purple1" => 0x9b30ff, + "purple2" => 0x912cee, + "purple3" => 0x7d26cd, + "purple4" => 0x551a8b, + "mediumpurple1" => 0xab82ff, + "mediumpurple2" => 0x9f79ee, + "mediumpurple3" => 0x8968cd, + "mediumpurple4" => 0x5d478b, + "thistle1" => 0xffe1ff, + "thistle2" => 0xeed2ee, + "thistle3" => 0xcdb5cd, + "thistle4" => 0x8b7b8b, + "gray0" => 0x000000, + "gray1" => 0x030303, + "gray2" => 0x050505, + "gray3" => 0x080808, + "gray4" => 0x0a0a0a, + "gray5" => 0x0d0d0d, + "gray6" => 0x0f0f0f, + "gray7" => 0x121212, + "gray8" => 0x141414, + "gray9" => 0x171717, + "gray10" => 0x1a1a1a, + "gray11" => 0x1c1c1c, + "gray12" => 0x1f1f1f, + "gray13" => 0x212121, + "gray14" => 0x242424, + "gray15" => 0x262626, + "gray16" => 0x292929, + "gray17" => 0x2b2b2b, + "gray18" => 0x2e2e2e, + "gray19" => 0x303030, + "gray20" => 0x333333, + "gray21" => 0x363636, + "gray22" => 0x383838, + "gray23" => 0x3b3b3b, + "gray24" => 0x3d3d3d, + "gray25" => 0x404040, + "gray26" => 0x424242, + "gray27" => 0x454545, + "gray28" => 0x474747, + "gray29" => 0x4a4a4a, + "gray30" => 0x4d4d4d, + "gray31" => 0x4f4f4f, + "gray32" => 0x525252, + "gray33" => 0x545454, + "gray34" => 0x575757, + "gray35" => 0x595959, + "gray36" => 0x5c5c5c, + "gray37" => 0x5e5e5e, + "gray38" => 0x616161, + "gray39" => 0x636363, + "gray40" => 0x666666, + "gray41" => 0x696969, + "gray42" => 0x6b6b6b, + "gray43" => 0x6e6e6e, + "gray44" => 0x707070, + "gray45" => 0x737373, + "gray46" => 0x757575, + "gray47" => 0x787878, + "gray48" => 0x7a7a7a, + "gray49" => 0x7d7d7d, + "gray50" => 0x7f7f7f, + "gray51" => 0x828282, + "gray52" => 0x858585, + "gray53" => 0x878787, + "gray54" => 0x8a8a8a, + "gray55" => 0x8c8c8c, + "gray56" => 0x8f8f8f, + "gray57" => 0x919191, + "gray58" => 0x949494, + "gray59" => 0x969696, + "gray60" => 0x999999, + "gray61" => 0x9c9c9c, + "gray62" => 0x9e9e9e, + "gray63" => 0xa1a1a1, + "gray64" => 0xa3a3a3, + "gray65" => 0xa6a6a6, + "gray66" => 0xa8a8a8, + "gray67" => 0xababab, + "gray68" => 0xadadad, + "gray69" => 0xb0b0b0, + "gray70" => 0xb3b3b3, + "gray71" => 0xb5b5b5, + "gray72" => 0xb8b8b8, + "gray73" => 0xbababa, + "gray74" => 0xbdbdbd, + "gray75" => 0xbfbfbf, + "gray76" => 0xc2c2c2, + "gray77" => 0xc4c4c4, + "gray78" => 0xc7c7c7, + "gray79" => 0xc9c9c9, + "gray80" => 0xcccccc, + "gray81" => 0xcfcfcf, + "gray82" => 0xd1d1d1, + "gray83" => 0xd4d4d4, + "gray84" => 0xd6d6d6, + "gray85" => 0xd9d9d9, + "gray86" => 0xdbdbdb, + "gray87" => 0xdedede, + "gray88" => 0xe0e0e0, + "gray89" => 0xe3e3e3, + "gray90" => 0xe5e5e5, + "gray91" => 0xe8e8e8, + "gray92" => 0xebebeb, + "gray93" => 0xededed, + "gray94" => 0xf0f0f0, + "gray95" => 0xf2f2f2, + "gray96" => 0xf5f5f5, + "gray97" => 0xf7f7f7, + "gray98" => 0xfafafa, + "gray99" => 0xfcfcfc, + "gray100" => 0xffffff, + "grey0" => 0x000000, + "grey1" => 0x030303, + "grey2" => 0x050505, + "grey3" => 0x080808, + "grey4" => 0x0a0a0a, + "grey5" => 0x0d0d0d, + "grey6" => 0x0f0f0f, + "grey7" => 0x121212, + "grey8" => 0x141414, + "grey9" => 0x171717, + "grey10" => 0x1a1a1a, + "grey11" => 0x1c1c1c, + "grey12" => 0x1f1f1f, + "grey13" => 0x212121, + "grey14" => 0x242424, + "grey15" => 0x262626, + "grey16" => 0x292929, + "grey17" => 0x2b2b2b, + "grey18" => 0x2e2e2e, + "grey19" => 0x303030, + "grey20" => 0x333333, + "grey21" => 0x363636, + "grey22" => 0x383838, + "grey23" => 0x3b3b3b, + "grey24" => 0x3d3d3d, + "grey25" => 0x404040, + "grey26" => 0x424242, + "grey27" => 0x454545, + "grey28" => 0x474747, + "grey29" => 0x4a4a4a, + "grey30" => 0x4d4d4d, + "grey31" => 0x4f4f4f, + "grey32" => 0x525252, + "grey33" => 0x545454, + "grey34" => 0x575757, + "grey35" => 0x595959, + "grey36" => 0x5c5c5c, + "grey37" => 0x5e5e5e, + "grey38" => 0x616161, + "grey39" => 0x636363, + "grey40" => 0x666666, + "grey41" => 0x696969, + "grey42" => 0x6b6b6b, + "grey43" => 0x6e6e6e, + "grey44" => 0x707070, + "grey45" => 0x737373, + "grey46" => 0x757575, + "grey47" => 0x787878, + "grey48" => 0x7a7a7a, + "grey49" => 0x7d7d7d, + "grey50" => 0x7f7f7f, + "grey51" => 0x828282, + "grey52" => 0x858585, + "grey53" => 0x878787, + "grey54" => 0x8a8a8a, + "grey55" => 0x8c8c8c, + "grey56" => 0x8f8f8f, + "grey57" => 0x919191, + "grey58" => 0x949494, + "grey59" => 0x969696, + "grey60" => 0x999999, + "grey61" => 0x9c9c9c, + "grey62" => 0x9e9e9e, + "grey63" => 0xa1a1a1, + "grey64" => 0xa3a3a3, + "grey65" => 0xa6a6a6, + "grey66" => 0xa8a8a8, + "grey67" => 0xababab, + "grey68" => 0xadadad, + "grey69" => 0xb0b0b0, + "grey70" => 0xb3b3b3, + "grey71" => 0xb5b5b5, + "grey72" => 0xb8b8b8, + "grey73" => 0xbababa, + "grey74" => 0xbdbdbd, + "grey75" => 0xbfbfbf, + "grey76" => 0xc2c2c2, + "grey77" => 0xc4c4c4, + "grey78" => 0xc7c7c7, + "grey79" => 0xc9c9c9, + "grey80" => 0xcccccc, + "grey81" => 0xcfcfcf, + "grey82" => 0xd1d1d1, + "grey83" => 0xd4d4d4, + "grey84" => 0xd6d6d6, + "grey85" => 0xd9d9d9, + "grey86" => 0xdbdbdb, + "grey87" => 0xdedede, + "grey88" => 0xe0e0e0, + "grey89" => 0xe3e3e3, + "grey90" => 0xe5e5e5, + "grey91" => 0xe8e8e8, + "grey92" => 0xebebeb, + "grey93" => 0xededed, + "grey94" => 0xf0f0f0, + "grey95" => 0xf2f2f2, + "grey96" => 0xf5f5f5, + "grey97" => 0xf7f7f7, + "grey98" => 0xfafafa, + "grey99" => 0xfcfcfc, + "grey100" => 0xffffff, + "darkgrey" => 0xa9a9a9, + "darkgray" => 0xa9a9a9, + "darkblue" => 0x00008b, + "darkcyan" => 0x008b8b, + "darkmagenta" => 0x8b008b, + "darkred" => 0x8b0000, + "lightgreen" => 0x90ee90, + }; +} + +1; + +__END__ + diff --git a/lib/Graphics/ColourNames.pm b/lib/Graphics/ColourNames.pm deleted file mode 100644 index df5b43b..0000000 --- a/lib/Graphics/ColourNames.pm +++ /dev/null @@ -1,65 +0,0 @@ -package Graphics::ColourNames;
-
-require 5.006;
-
-use strict;
-use warnings;
-
-require Graphics::ColorNames;
-
-use base 'Graphics::ColorNames';
-
-our $VERSION = '1.06';
-
-our @EXPORT = qw( );
-our @EXPORT_OK = qw( hex2tuple tuple2hex );
-
-sub hex2tuple {
- goto &Graphics::ColorNames::hex2tuple;
-}
-
-sub tuple2hex {
- goto &Graphics::ColorNames::tuple2hex;
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
-Graphics::ColourNames - alias for Graphics::ColorNames
-
-=head1 SYNOPSIS
-
- use Graphics::ColourNames qw( hex2tuple tuple2hex );
-
- tie %NameTable, 'Graphics::ColourNames', 'X';
-
- my $rgbhex1 = $NameTable{'green'}; # returns '00ff00'
- my $rgbhex2 = tuple2hex( 0, 255, 0 ); # returns '00ff00'
- my @rgbtup = hex2tuple( $rgbhex ); # returns (0, 255, 0)
-
- my $rgbhex3 = $NameTable{'#123abc'}; # returns '123abc'
- my $rgbhex4 = $NameTable{'123abc'}; # returns '123abc'
-
-=head1 DESCRIPTION
-
-This module is an alias for L<Graphics::ColorNames>, using the British
-style of spelling.
-
-It does not alter the spelling of individual colour names in colour
-schemas.
-
-=head1 AUTHOR
-
-Robert Rothenberg <rrwo at cpan.org>
-
-=head1 LICENSE
-
-Copyright (c) 2004-2005 Robert Rothenberg. All rights reserved.
-This program is free software; you can redistribute it and/or
-modify it under the same terms as Perl itself.
-
-=cut
-
diff --git a/t/00-Prereqs.t b/t/00-Prereqs.t deleted file mode 100644 index bdd8324..0000000 --- a/t/00-Prereqs.t +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/perl
-
-use strict;
-use Test::More;
-
-eval "use Test::Prereq";
-plan skip_all => "Test::Prereq required to test dependencies" if $@;
-prereq_ok();
diff --git a/t/00-pod-coverage.t b/t/00-pod-coverage.t deleted file mode 100644 index 47cf647..0000000 --- a/t/00-pod-coverage.t +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/perl
-
-use strict;
-use Test::More tests => 6;
-
-eval "use Pod::Coverage";
-
-plan skip_all => "Pod::Coverage required" if $@;
-
-ok( Pod::Coverage->new( package => 'Graphics::ColorNames' ) );
-ok( Pod::Coverage->new( package => 'Graphics::ColourNames' ) );
-ok( Pod::Coverage->new( package => 'Graphics::ColorNames::X' ) );
-ok( Pod::Coverage->new( package => 'Graphics::ColorNames::HTML' ) );
-ok( Pod::Coverage->new( package => 'Graphics::ColorNames::Windows' ) );
-ok( Pod::Coverage->new( package => 'Graphics::ColorNames::Netscape' ) );
diff --git a/t/01-ColorNames.t b/t/01-ColorNames.t index dfa4f7c..5d5bad5 100644 --- a/t/01-ColorNames.t +++ b/t/01-ColorNames.t @@ -2,9 +2,19 @@ use strict;
-use Test::More tests => 44;
-
-use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+use Test::More tests => 54;
+use Test::Exception;
+
+use_ok('Graphics::ColorNames', '2.10', qw( hex2tuple tuple2hex all_schemes ));
+
+{
+ my %schemes = map { $_=>1, } all_schemes();
+ ok((keys %schemes) >= 4); # Windows, Netscape, HTML, and X
+ ok($schemes{X});
+ ok($schemes{HTML});
+ ok($schemes{Windows});
+ ok($schemes{Netscape});
+}
tie my %colors, 'Graphics::ColorNames';
ok(tied %colors);
@@ -12,7 +22,7 @@ ok(tied %colors); my $count = 0;
foreach my $name (keys %colors)
{
- my @RGB = hex2tuple( $colors{$name} );
+ my @RGB = hex2tuple($colors{$name});
$count++, if (tuple2hex(@RGB) eq $colors{$name} );
}
ok($count == keys %colors);
@@ -32,19 +42,24 @@ foreach my $name (keys %colors) }
ok($count == keys %colors);
+$count = 0;
+foreach my $name (keys %colors)
+ {
+ my $rgb = $colors{$name};
+ $count++, if (defined $colors{$rgb});
+ $count++, if (defined $colors{"\x23".$rgb});
+ }
+ok($count == (2*(keys %colors)));
+
# Test CLEAR, DELETE and STORE as returning errors
-eval { undef %colors };
-ok(defined($!));
+dies_ok { undef %colors } "undef %colors";
-eval { %colors = (); };
-ok(defined($!));
+dies_ok { %colors = (); } "%colors = ()";
-eval { $colors{MyCustomColor} = 'FFFFFF'; };
-ok(defined($!));
+dies_ok { $colors{MyCustomColor} = 'FFFFFF'; } "STORE";
-eval { delete($colors{MyCustomColor}); };
-ok(defined($!));
+dies_ok { delete($colors{MyCustomColor}); } "DELETE";
# Test RGB values being passed through
@@ -52,27 +67,39 @@ foreach my $rgb (qw( 000000 000001 000010 000100 001000 010000 100000
111111 123abc abc123 123ABC ABC123 abcdef ABCDEF
)) {
- ok($colors{ "\x23" . $rgb } eq $rgb);
- ok($colors{ $rgb } eq $rgb);
+ ok($colors{ "\x23" . $rgb } eq lc($rgb));
+ ok($colors{ $rgb } eq lc($rgb));
}
-# Test using multiple schemes
+# Test using multiple schemes, with issues in overlapping
tie my %colors2, 'Graphics::ColorNames', qw( X Netscape );
-ok(!exists $colors{Silver}); # Silver doesn't exist in X
-ok(defined $colors2{Silver}); # It does in Netscape
+ok(!exists $colors{Silver}); # Silver doesn't exist in X
+ok(defined $colors2{Silver}); # It does in Netscape
# Test precedence
+ok($colors{DarkGreen} eq '006400'); # DarkGreen in X
+ok($colors2{DarkGreen} eq '006400'); # DarkGreen in X
+ok($colors2{DarkGreen} ne '2f4f2f'); # DarkGreen in Netscape
+
tie my %colors3, 'Graphics::ColorNames', qw( Netscape X );
-ok($colors{Brown}, 'a52a2a'); # Brown in X
-ok($colors2{Brown}, 'a52a2a'); # Brown in X (don't try Netscape)
-ok($colors3{Brown}, 'a62a2a'); # Brown in Netscape (don't try X)
+ok($colors{Brown} eq 'a52a2a'); # Brown in X
+ok($colors2{Brown} eq 'a52a2a'); # Brown in X (don't try Netscape)
+ok($colors3{Brown} eq 'a62a2a'); # Brown in Netscape (don't try X)
# Test handling of non-existent color names
ok(!defined $colors{NonExistentColorName});
ok(!exists $colors{NonExistentColorName});
+# Test dynamic loading of scheme
+
+my $colorobj = tied(%colors);
+$colorobj->load_scheme({ nonexistentcolorname => 0x123456 } );
+ok($colors{NonExistentColorName} eq '123456');
+
+
+
diff --git a/t/01-ColourNames.t b/t/01-ColourNames.t deleted file mode 100644 index bef6b02..0000000 --- a/t/01-ColourNames.t +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/perl
-
-use strict;
-use Test::More tests => 44;
-
-use_ok( 'Graphics::ColourNames', 1.06, qw( hex2tuple tuple2hex ));
-
-tie my %colors, 'Graphics::ColourNames';
-ok(1);
-
-my $count = 0;
-foreach my $name (keys %colors)
- {
- my @RGB = hex2tuple( $colors{$name} );
- $count++, if (tuple2hex(@RGB) eq $colors{$name} );
- }
-ok($count == keys %colors);
-
-$count = 0;
-foreach my $name (keys %colors)
- {
- $count++, if ($colors{lc($name)} eq $colors{uc($name)});
- }
-ok($count == keys %colors);
-
-
-$count = 0;
-foreach my $name (keys %colors)
- {
- $count++, if (exists($colors{$name}))
- }
-ok($count == keys %colors);
-
-# Test CLEAR, DELETE and STORE as returning errors
-
-eval { undef %colors };
-ok(defined($!));
-
-eval { %colors = (); };
-ok(defined($!));
-
-eval { $colors{MyCustomColour} = 'FFFFFF'; };
-ok(defined($!));
-
-eval { delete($colors{MyCustomColour}); };
-ok(defined($!));
-
-# Test RGB values being passed through
-
-foreach my $rgb (qw(
- 000000 000001 000010 000100 001000 010000 100000
- 111111 123abc abc123 123ABC ABC123 abcdef ABCDEF
- )) {
- ok($colors{ "\x23" . $rgb } eq $rgb);
- ok($colors{ $rgb } eq $rgb);
-}
-
-# Test using multiple schemes
-
-tie my %colors2, 'Graphics::ColourNames', qw( X Netscape );
-
-ok(!exists $colors{Silver}); # Silver doesn't exist in X
-ok(defined $colors2{Silver}); # It does in Netscape
-
-# Test precedence
-
-tie my %colors3, 'Graphics::ColourNames', qw( Netscape X );
-
-ok($colors{Brown}, 'a52a2a'); # Brown in X
-ok($colors2{Brown}, 'a52a2a'); # Brown in X (don't try Netscape)
-ok($colors3{Brown}, 'a62a2a'); # Brown in Netscape (don't try X)
-
-# Test handling of non-existent color names
-
-ok(!defined $colors{NonExistentColourName});
-ok(!exists $colors{NonExistentColourName});
-
diff --git a/t/01-version.t b/t/01-version.t new file mode 100644 index 0000000..ac2a11c --- /dev/null +++ b/t/01-version.t @@ -0,0 +1,13 @@ +#!/usr/bin/perl + +use strict; +use Test::More tests => 5; + +use_ok("Graphics::ColorNames"); + +my @Modules = (qw( X HTML Windows Netscape)); + +foreach my $mod (@Modules) { + use_ok("Graphics::ColorNames::$mod", $Graphics::ColorNames::VERSION); +} + @@ -2,14 +2,14 @@ use strict;
-use Test::More tests => 4;
+use Test::More tests => 19;
-use_ok('Graphics::ColorNames', 0.32, qw( hex2tuple tuple2hex ));
+use_ok('Graphics::ColorNames', 2.1002, qw( hex2tuple tuple2hex ));
tie my %colors, 'Graphics::ColorNames', 'X';
ok(tied %colors);
-ok(keys %colors == 760); #
+ok(keys %colors == 665); #
my $count = 0;
foreach my $name (keys %colors)
@@ -18,3 +18,11 @@ foreach my $name (keys %colors) $count++, if (tuple2hex(@RGB) eq $colors{$name} );
}
ok($count == keys %colors);
+
+foreach my $ad (qw( royal dodger slate sky steel )) {
+ foreach my $col (qw( blue )) {
+ ok(exists $colors{"$ad$col"});
+ ok($colors{"$ad$col"} eq $colors{"$ad $col"}, "$ad $col");
+ ok($colors{"$ad-$col"} eq $colors{"$ad $col"}, "$ad $col");
+ }
+}
diff --git a/t/05-Netscape.t b/t/05-Netscape.t index d3f7922..b08ebd9 100644 --- a/t/05-Netscape.t +++ b/t/05-Netscape.t @@ -2,9 +2,9 @@ use strict;
-use Test::More tests => 7;
+use Test::More tests => 9;
-use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+use_ok('Graphics::ColorNames', 2.10, qw( hex2tuple tuple2hex ));
tie my %colors, 'Graphics::ColorNames', 'Netscape';
ok(tied %colors);
@@ -22,8 +22,11 @@ ok($count == keys %colors); # Problem is with Netscape's color definitions
{
- local $TODO = "Problem with Netscape color definitions";
+ # local $TODO = "Problem with Netscape color definitions";
ok($colors{gold} ne $colors{mediumblue});
ok($colors{lightblue} ne $colors{mediumblue});
ok($colors{lightblue} ne $colors{gold});
}
+
+ok($colors{"semisweetchocolate"} eq $colors{"semi-sweetchocolate"});
+ok($colors{"baker\'schocolate"} eq $colors{"bakerschocolate"});
@@ -8,17 +8,35 @@ use constant TEST_CASES => { "green" => 0x00ff00,
"blue" => 0x0000ff,
"white" => 0xffffff,
+ # some arbitrary colors added for testing the autoloaded color names
+ "lavenderblush" => 0xfff0f5,
+ "lavender_blush" => 0xfff0f5,
+ "LavenderBlush" => 0xfff0f5,
+ "LAVENDERBLUSH" => 0xfff0f5,
};
-use Test::More tests => 3 + (9 * 5);
+use Test::More;
+use Test::Exception;
-use_ok('Graphics::ColorNames', 1.06, (qw(tuple2hex)));
+my $tests = TEST_CASES;
+
+plan tests => 4 + (11 * (keys %$tests));
+
+use_ok('Graphics::ColorNames', 2.1003, (qw(tuple2hex)));
my $rgb = Graphics::ColorNames->new(qw( X ));
ok(defined $rgb);
ok($rgb->isa('Graphics::ColorNames'));
-my $tests = TEST_CASES;
+{
+ # This causes errors
+
+ # local $TODO = "AutoLoading non-existent color method";
+ dies_ok {
+ $rgb->SomeNonExistentColor();
+ } "SomeNonExistentColor should have failed";
+
+}
foreach my $name (keys %$tests) {
@@ -35,6 +53,12 @@ foreach my $name (keys %$tests) { $c = $rgb->hex($name);
ok( $c =~ /^[0-9a-f]{6}$/i );
+ ok($rgb->$name eq $c);
+ {
+ local $TODO = "Handle the can() method";
+ ok($rgb->can($name));
+ }
+
my $d = $rgb->rgb($name, ',');
ok( $d =~ /^\d{1,3}(\,\d{1,3}){2}$/ );
@@ -45,3 +69,4 @@ foreach my $name (keys %$tests) { ok( tuple2hex(@v) eq $c );
}
+
diff --git a/t/07-file.t b/t/07-file.t index 075403a..1bd448c 100644 --- a/t/07-file.t +++ b/t/07-file.t @@ -4,7 +4,7 @@ use strict; use Test::More tests => 10;
-use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+use_ok('Graphics::ColorNames', 1.10, qw( hex2tuple tuple2hex ));
tie my %colors, 'Graphics::ColorNames', './t/rgb.txt';
ok(tied %colors);
diff --git a/t/08-filehandle.t b/t/08-filehandle.t index ce3aec7..fae6f9e 100644 --- a/t/08-filehandle.t +++ b/t/08-filehandle.t @@ -1,28 +1,81 @@ #!/usr/bin/perl
use strict;
-use Test::More tests => 10;
+use Test::More tests => 28;
+use FileHandle;
use IO::File;
-my $fh = new IO::File;
-open($fh, './t/rgb.txt');
+use_ok('Graphics::ColorNames', 1.10, qw( hex2tuple tuple2hex ));
-use_ok('Graphics::ColorNames', 1.06, qw( hex2tuple tuple2hex ));
+{
+ my $fh = new IO::File;
+ open($fh, './t/rgb.txt');
-tie my %colors, 'Graphics::ColorNames', $fh;
-ok(tied %colors);
-ok(keys %colors == 6); #
+ tie my %colors, 'Graphics::ColorNames', $fh;
+ ok(tied %colors);
-my $count = 0;
-foreach my $name (keys %colors)
+ ok(keys %colors == 6); #
+
+ my $count = 0;
+ foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ ok($count == keys %colors);
+
+ foreach my $name (qw( one two three four five six)) {
+ ok(exists $colors{$name});
+ }
+
+ close $fh;
+}
+
+{
+ my $fh = new FileHandle;
+ open($fh, './t/rgb.txt');
+
+ tie my %colors, 'Graphics::ColorNames', $fh;
+ ok(tied %colors);
+
+ ok(keys %colors == 6); #
+
+ my $count = 0;
+ foreach my $name (keys %colors)
{
my @RGB = hex2tuple( $colors{$name} );
$count++, if (tuple2hex(@RGB) eq $colors{$name} );
}
-ok($count == keys %colors);
+ ok($count == keys %colors);
+
+ foreach my $name (qw( one two three four five six)) {
+ ok(exists $colors{$name});
+ }
+
+ close $fh;
+}
+
+{
+ open(my $fh, './t/rgb.txt');
+
+ tie my %colors, 'Graphics::ColorNames', $fh;
+ ok(tied %colors);
+
+ ok(keys %colors == 6); #
+
+ my $count = 0;
+ foreach my $name (keys %colors)
+ {
+ my @RGB = hex2tuple( $colors{$name} );
+ $count++, if (tuple2hex(@RGB) eq $colors{$name} );
+ }
+ ok($count == keys %colors);
+
+ foreach my $name (qw( one two three four five six)) {
+ ok(exists $colors{$name});
+ }
-foreach my $name (qw( one two three four five six)) {
- ok(exists $colors{$name});
+ close $fh;
}
diff --git a/t/09-colorlibrary.t b/t/09-colorlibrary.t new file mode 100644 index 0000000..5370c1a --- /dev/null +++ b/t/09-colorlibrary.t @@ -0,0 +1,37 @@ +#!/usr/bin/perl
+
+use strict;
+use Test::More;
+
+eval "use Color::Library 0.02";
+
+plan skip_all => "Color::Library 0.02 required" if $@;
+
+use constant TEST_CASES => {
+ "croceus" => 0xf4c2c2,
+ "croceus28" => 0xf4c2c2,
+ "croceus53" => 0xd99058,
+# "black" => 0x000000,
+# "aqua" => 0x00ffff,
+# "maroon" => 0x800000,
+# "lime" => 0x00ff00,
+};
+
+my $tests = TEST_CASES;
+
+plan tests => 3 + (keys %$tests);
+
+use_ok("Graphics::ColorNames", "2.10002");
+
+use_ok("Color::Library::Dictionary::NBS_ISCC::B");
+
+{
+ my $obj = Graphics::ColorNames->new( 'Color::Library::Dictionary::NBS_ISCC::B' );
+ ok ($obj->isa("Graphics::ColorNames"));
+
+ foreach my $name (keys %$tests) {
+ ok($obj->hex($name) eq sprintf('%06x',$tests->{$name}),
+ "failed test for color $name");
+ }
+
+}
diff --git a/t/10-sub.t b/t/10-sub.t new file mode 100644 index 0000000..97714b0 --- /dev/null +++ b/t/10-sub.t @@ -0,0 +1,32 @@ +#!/usr/bin/perl
+
+use strict;
+
+use Test::More;
+
+eval "use Tie::Sub";
+
+plan skip_all => "Tie::Sub required" if $@;
+
+plan tests => 4;
+
+use_ok('Graphics::ColorNames', '2.10', qw( all_schemes ));
+
+tie my %colors, 'Graphics::ColorNames';
+
+# Test handling of non-existent color names
+
+ok(!defined $colors{NonExistentColorName});
+ok(!exists $colors{NonExistentColorName});
+
+# Test dynamic loading of scheme
+
+my $colorobj = tied(%colors);
+$colorobj->load_scheme( sub {
+ return 0x123456;
+ }
+);
+ok($colors{NonExistentColorName} eq '123456');
+
+
+
diff --git a/t/90-file-port.t b/t/90-file-port.t new file mode 100644 index 0000000..36a8fe4 --- /dev/null +++ b/t/90-file-port.t @@ -0,0 +1,13 @@ +#!/usr/bin/perl
+
+use Test::More;
+
+plan skip_all => "Enable DEVEL_TESTS environent variable"
+ unless ($ENV{DEVEL_TESTS});
+
+eval "use Test::Portability::Files";
+
+plan skip_all => "Test::Portability::Files required for testing filenames portability" if $@;
+
+
+run_tests();
diff --git a/t/90-pod-coverage.t b/t/90-pod-coverage.t new file mode 100644 index 0000000..f533eea --- /dev/null +++ b/t/90-pod-coverage.t @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; +use Test::More; + +plan skip_all => "Enable DEVEL_TESTS environent variable" + unless ($ENV{DEVEL_TESTS}); + +if (eval "use Test::Pod::Coverage tests => 1") { +} +else { + plan skip_all => "Test::Pod::Coverage required" if $@; +} + +pod_coverage_ok("Graphics::ColorNames"); + + @@ -3,6 +3,9 @@ use strict;
use Test::More;
+plan skip_all => "Enable DEVEL_TESTS environent variable"
+ unless ($ENV{DEVEL_TESTS});
+
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required" if $@;
|