CGCOLOR
The purpose of this function is to obtain drawing colors
by name and in a device/decomposition independent way.
The color names and values may be read in as a file, or 192 color
names and values are supplied with the program. These colors were
obtained from the file rgb.txt, found on most X-Window distributions,
and from colors in the `Brewer color tables <http://colorbrewer2.org/>`.
Representative colors were chosen from across the color spectrum.
If the color names '0', '1', '2', ..., '255' are used, they will
correspond to the colors in the current color table in effect at
the time the `cgColor` program is called.
Categories
Graphics
Examples
To get drawing colors in a device-decomposed independent way::
axisColor = cgColor("Green", !D.Table_Size-2)
backColor = cgColor("Charcoal", !D.Table_Size-3)
dataColor = cgColor("Yellow", !D.Table_Size-4)
Plot, Findgen(11), Color=axisColor, Background=backColor, /NoData
OPlot, Findgen(11), Color=dataColor
To set the viewport color in object graphics::
theView = Obj_New('IDLgrView', Color=cgColor('Charcoal', /Triple))
To change the viewport color later::
theView->SetProperty, Color=cgColor('Antique White', /Triple)
To load the drawing colors "red", "green", and "yellow" at indices 100-102, type this::
IDL> TVLCT, cgColor(["red", "green", "yellow"], /Triple), 100
To interactively choose a color, set the SELECTCOLOR keyword::
IDL> color = cgColor(/SelectColor)
The PickColorName program is a good way to learn the names of the colors available::
IDL> color = PickColorName() Author
FANNING SOFTWARE CONSULTING::
David W. Fanning
1645 Sheely Drive
Fort Collins, CO 80526 USA
Phone: 970-221-0438
E-mail: david@idlcoyote.com
Coyote's Guide to IDL Programming: http://www.idlcoyote.com
History
Change History::
Written by: David W. Fanning
Modified FSC_COLOR to create cgColor 9 February 2011. DWF.
Modified to allow a three-element color triple to be used in place of the color
name parameter. This allows one user-defined color to be used. 4 Dec 2011. DWF.
Modified to allow byte and 16-bit integer values to be used to specify colors
in the current color table. 5 Dec 2011. DWF.
Modified to allow the "opposite" pixel to be determined in the Z-graphics buffer. 24 Dec 2011. DWF.
Modified the code to handle long integers depending on the current color mode and the
number of values passed in. 10 January 2012. DWF.
Made sure the return values are BYTES not INTEGERS, in cases where this is expected. 10 Jan 2012. DWF.
Added "Background" as a color name. The opposite of "Opposite". 1 Feb 2012. DWF.
When returning a vector of color values, now making sure to return a byte array if
in indexed color mode. 27 Feb 2012. DWF.
Added Compile Opt id2 to all file modules. 22 July 2012. DWF.
Copyright
Copyright (c) 2009-2012, Fanning Software Consulting, Inc.