Colors and Fonts in GD::Graph
All GD::Graph color routines that take
colorname
as a parameter expect a string
with the name of a valid color. GD::Graph comes bundled with the
GD::Graph::colour[5] package, which provides some methods for organizing and
manipulating color name strings. GD::Graph has 29 predefined color
name strings (see Table 4-1). The module is
normally used simply to provide access to the standard color names,
but it also provides methods for converting between color
representations. You can define additional strings in an external file
by using the read_rgb( )
method.
Color name string | Red | Green | Blue | Hex representation |
| 255 | 255 | 255 |
|
| 255 | 255 | 0 |
|
| 255 | 215 | 0 |
|
0 | 255 | 255 |
| |
| 255 | 183 | 193 |
|
| 191 | 191 | 191 |
|
| 255 | 183 | 0 |
|
| 210 | 180 | 140 |
|
| 0 | 255 | 0 |
|
| 191 | 191 | 0 |
|
| 255 | 127 | 0 |
|
| 255 | 105 | 180 |
|
| 0 | 191 | 0 |
|
| 127 | 127 | 255 |
|
| 127 | 127 | 127 |
|
| 127 | 127 | 0 |
|
| 0 | 127 | 0 |
|
| 255 | 0 | 255 |
|
| 165 | 42 | 42 |
|
| 63 | 63 | 63 |
|
| 191 | 0 | 191 |
|
| 255 | 0 | 0 |
|
| 191 | 0 | 0 |
|
| 127 | 0 | 127 |
|
| 127 | 0 | 0 |
|
| 0 | 0 | 255 |
|
| 0 | 0 | 191 |
|
| 0 | 0 | 127 |
|
| 0 | 0 | 0 |
|
Call the use method with the :colours
tag to import the functions
_rgb( )
, _hue( )
, and _luminance( )
. The :lists
tag imports only colour_list( )
and sorted_colour_list( )
, and the :files
tag imports the read_rgb( )
function.
The various methods are as follows.
[5] GD::Graph’s author, Martien Verbruggen, lives in Australia,
hence the Australian spelling of “colour.” Note that the GD::Graph
methods that deal with colors (set_text_clr( )
, for example) have
abbreviated the word to alleviate the need for multiple method
names.
Get Perl Graphics Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.