MGH_COLOR
Name
MGH_COLOR
Purpose
This function accepts one or more colour specifiers in string form
and returns an array containing corresponding RGB colour values.
The colour data are specified in a file, mgh_color.dat, which
must be in the same directory as the source file.
Note that much of the functionality of this routine is now provided
by the !color system variable, introduced in IDL 8.0.
Category
Graphics, Color Specification.
Calling Sequence
result = mgh_color(name)
Positional Parameters
name (input, string)
Colour specifier. Each elements may be in one of two forms:
- If the string begins with "(" and ends with ")" then the
characters between are assumed to contain an RGB-coded
colour value in numeric form, eg. "(255,0,255)" or "(255 0
255)". The conversion is done using a READS statement and if
an IO error occurs the corresponding value in the output is
left at 0.
- Otherwise the specifier is matched against a list of
pre-defined colour names. If no match is found then black
[0,0,0] is returned.
Keyword Parameters
DECOMPOSED (input, switch)
Set this keyword to return a scalar or n-element long-word
vector in which RGB values are stored in the least-significant
three bytes. (This is the form required by direct-graphics
devices when the DECOMPOSED keyword is set.) The default is to
return a [3] or [3,n] byte array, as required by the Object
Graphics system.
NAMES (input, switch)
Set this keyword to return a list of the colour names recognised
by the function. The "name" argument is then ignored.
REREAD (input, switch)
Set this keyword to cause the colour-data file to be
reread. Normally it is only read the first time the function is
run. This keyword is useful when testing changes to the
colour-data file.
###########################################################################
Copyright (c) 1998-2014 NIWA:
http://www.niwa.co.nz/
Licensed under the MIT open source license:
http://www.opensource.org/licenses/mit-license.php
###########################################################################
Modification History
Mark Hadfield, 1998-03:
Written, inspired by David Fanning's GETCOLOR.
Mark Hadfield, 2000-07:
Updated for IDL2 syntax
Mark Hadfield, 2001-10:
- Added DECOMPOSED keyword.
- Colour names & associated values are now read from a file.
Mark Hadfield, 2001-11:
Added support for numeric specifiers.
Mark Hadfield, 2004-03:
Now uses David Fanning's PROGRAMROOTDIR function to find the data
file.
Mark Hadfield, 2007-11:
Sometime in the last few years, this function has stopped using
PROGRAMROOTDIR.
Mark Hadfield, 2013-07:
Reformatted.
Mark Hadfield, 2014-06:
Determination of data file name simplified.