Coyote Graphics Routines

Date: Fri Mar 27 12:14:20 2015

single page | use frames     summary     class     fields     routine details     file attributes


top cgDefaultColor


result = cgDefaultColor( [inputColour] [, /BACKGROUND] [, DEFAULT=DEFAULT] [, /MODE] [, /TRADITIONAL])

The purpose of this function is to choose a default color for Coyote Graphics routines.

Return value

Returns a scalar or vector (depends on the type of the input color) of color names (strings) to be used as the "color" in Coyote Graphics routines. If the MODE is 1 and the inputColor is of type LONG, then the return value is an array or scalar of type LONG.


inputColour in optional

The input color. May be undefined, a byte, integer, long, or string. If the device is in indexed color mode at the time the request is made, then all, byte, integer, and long values will be treated as indices into the current color table. The variable may be a vector.


BACKGROUND in optional type=boolean

If this keyword is set, the color is treated as a background color. Otherwise, it is treated as a drawing color.

DEFAULT in optional

A color of any type allowed as the inputColour. Used if the inputColour is undefined.

MODE in optional type=boolean

The color mode. A 0 mean indexed color mode. A 1 means decomposed color mode. If not supplied in the call, the color mode is determined at run-time with cgGetColorState. The color mode is *always* determined at run time if the current graphics device is the PostScript device.

TRADITIONAL in optional type=boolean default=0

Set this keyword if you are using the traditional color scheme of white foreground and black background. If this keyword is set, and the current graphics device is the PostScript device, the colors will be reversed, in the traditional IDL graphics way.


Use as a device independent way to get a color:

background = cgDefaultColor(bColor, /Background) color = cgDefaultColor(bColor) cgPlot, cgDemoData, Background=background, Color=color

Author information



David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: Coyote's Guide to IDL Programming:


Copyright (c) 2011, Fanning Software Consulting, Inc.


Change History:

Written, 24 December 2011. David W. Fanning. Modified to make sure a LONG integer in indexed color mode is in the range 0-255. 10 Jan 2012. DWF. Modified to make sure MODE is always determined at run-time for PostScript device. 14 Jan 2012. DWF. Allow other data types to be treated as color table index numbers, as long as they are in the range 0 to 255, and the MODE indicates indexed color. 7 March 2012. DWF. Modified so that the variable MODE will not change in the calling program program. 8 March 2012. DWF. Made FOR loop counter a LONG integer. 3 July 2012. DWF. More work on getting the MODE correct to handle LONG integers properly. Now, in PostScript, we get the current mode, except if we have been told what mode to be in. 21 July 2012. DWF. For numerical values less than 256, in indexed color state, I now return the values directly to the user. This should significantly speed up many Coyote Graphics processes. 14 December 2012. DWF. Modified to return byte and integer values as LONG decomposed integers, if decomposed mode is currently in effect. 14 December 2012. DWF. Now setting all background colors to WHITE, not BACKGROUND. 16 Dec 2012. DWF. Whoops! Forgot one of the background colors in the Traditional section. 11 Jan 2013. DWF. Made the counters in the loops long integers to accommodate large color vectors. 29 Apr 2013. Joe Sapp. Better error handling if/when long integers are used in indexed color mode. 17 Sept 2013. DWF.

File attributes

Modification date: Fri Mar 27 11:07:36 2015
Lines: 255
Docformat: rst rst