topGETCOLOR Graphics, Color
Return value
If no positional parameter is present, then the return value is either a 16-by-3
byte array containing the RGB values of all 16 colors or it is a 16-element
long integer array containing color values that can be decomposed into colors.
The 16-by-3 array is appropriate for loading color tables with the TVLCT command:
Device, Decomposed=0
colors = GetColor()
TVLCT, colors, 100
If function is called with just this single input parameter,
the return value is either a 1-by-3 array containing the RGB values of
that particular color, or a 24-bit integer that can be "decomposed" into
that particular color, depending upon the state of the TRUE keyword and
upon whether color decomposition is turned on or off. The state of color
decomposition can ONLY be determined if the program is being run in
IDL 5.2 or higher.
If index parameter is passed, then the return value of the function is the
index number and not the color triple. (If color decomposition is turned
on AND the user specifies an index parameter, the color is loaded in the
color table at the proper index, but a 24-bit value is returned to the
user in IDL 5.2 and higher.)
Parameters
thisColor
in
optional
index
in
optional
Keywords
TRUE
NAMES
LOAD
START
default: !D.TABLE_SIZE - 17
Examples
To load a yellow color in color index 100 and plot in yellow, type:
IDL> yellow = GETCOLOR('yellow', 100)
IDL> PLOT, data, COLOR=yellow
or,
IDL> PLOT, data, COLOR=GETCOLOR('yellow', 100)
To do the same thing on a 24-bit color system with decomposed color on, type:
IDL> PLOT, data, COLOR=GETCOLOR('yellow', /TRUE)
or in IDL 5.2 and higher,
IDL> DEVICE, Decomposed=1
IDL> PLOT, data, COLOR=GETCOLOR('yellow')
To load all 16 colors into the current color table, starting at
color index 200, type:
IDL> TVLCT, GETCOLOR(), 200
To add the color names to a list widget:
IDL> listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16)
To load all 16 colors and have the color indices returned in a structure:
IDL> DEVICE, Decomposed=0
IDL> colors = GetColor(/Load, Start=1)
IDL> HELP, colors, /Structure
PLOT, data, COLOR=colors.yellow
To get the direct color values as 24-bit integers in color structure fields:
IDL> DEVICE, Decomposed=1
IDL> colors = GetColor(/Load)
IDL> PLOT, data, COLOR=colors.yellow
Note that the START keyword value is ignored if on a 24-bit device,
so it is possible to write completely device-independent code by
writing code like this:
IDL> colors = GetColor(/Load)
IDL> PLOT, data, Color=colors.yellow; IDL> DEVICE, Decomposed=0
IDL> colors = GetColor(/Load, Start=1)
IDL> HELP, colors, /Structure
PLOT, data, COLOR=colors.yellow
To get the direct color values as 24-bit integers in color structure fields:
IDL> DEVICE, Decomposed=1
IDL> colors = GetColor(/Load)
IDL> PLOT, data, COLOR=colors.yellow
Note that the START keyword value is ignored if on a 24-bit device,
so it is possible to write completely device-independent code by
writing code like this:
IDL> colors = GetColor(/Load)
IDL> PLOT, data, Color=colors.yellow
Version history
Version
$Id: getcolor.pro 137 2006-07-12 09:33:44Z smasson $
History
Written by: David Fanning, 10 February 96.
Fixed a bug in which N_ELEMENTS was spelled wrong. 7 Dec 96. DWF
Added the McIDAS colors to the program. 24 Feb 99. DWF
Added the INDEX parameter to the program 8 Mar 99. DWF
Added the NAMES keyword at insistence of Martin Schultz. 10 Mar 99. DWF
Reorderd the colors so black is first and white is last. 7 June 99. DWF
Added automatic recognition of DECOMPOSED=1 state. 7 June 99. DWF
Added LOAD AND START keywords. 7 June 99. DWF.
Known issues
Restrictions
The TRUE keyword causes the START keyword to be ignored.
The NAMES keyword causes the COLOR, INDEX, START, and TRUE parameters to be
ignored.
The COLOR parameter is ignored if the LOAD keyword is used.
On systems where it is possible to tell the state of color decomposition
(i.e., IDL 5.2 and higher), a 24-bit value (or values) is automatically
returned if color decomposition is ON.