Graphics::ColorNames

Defines RGB values for common color names
Download

Graphics::ColorNames Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Robert Rothenberg
  • Publisher web site:
  • http://search.cpan.org/~rrwo/

Graphics::ColorNames Tags


Graphics::ColorNames Description

Defines RGB values for common color names Graphics::ColorNames is a Perl module that 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.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: $bgColor (or background color) is 'CadetBlue3' (which is easier to for one to understand than 0x7A, 0xC5, 0xCD). The variable is named for its function, not form (ie, $CadetBlue3) so that if the author later changes the background color, the variable name need not be changed.You can also define "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'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'); Requirements: · Perl


Graphics::ColorNames Related Software