NCL Website header
NCL Home > Documentation > HLUs > API


The Fortran name of this function is NhlFSetColor.

This function sets the RGB color value for a specified HLU color index.

C Synopsis

#include <ncarg/hlu/hlu.h>
#include <hfile for Workstation class object>

NhlErrorTypes NhlSetColor(
	        int	workid,
		int	ci,
		float	red,
		float	green,
		float	blue

Fortran Synopsis

      subroutine NhlFSetColor(workid, ci, red, green, blue, ierr)
      integer workid, ci, ierr
      real red, green blue


workid (input)
Integer identifier of an instance of a Workstation class object
ci (input)
Integer color index in the range 1 through 255 that is to be allocated.
red (input)
Value of the red component of the desired color in the range 0.0 to 1.0 inclusive.
green (input)
Value of the green component of the desired color in the range 0.0 to 1.0 inclusive.
blue (input)
Value of the blue component of the desired color in the range 0.0 to 1.0 inclusive.
ierr (output, Fortran only)
Error code.


Type name:		NhlTErrorTypes
typedef enum _NhlErrType{
	NhlFATAL	= -4,	/* "FATAL"	*/
	NhlWARNING	= -3,	/* "WARNING"	*/
	NhlINFO		= -2,	/* "INFO"	*/
	NhlNOERROR	= -1	/* "NOERROR"	*/
} NhlErrorTypes;


Use this function to allocate a specific HLU color index or redefine the color of a previously allocated index. The index must be in the range 1 through 255. Note that the HLU library does not require that allocated color indexes be contiguous. Thus, for example, using NhlSetColor, you could allocated indexes 10, 100, and 200 without allocating any of the indexes in between. If you set the color of some feature in a plot object using an unallocated color index, the Workstation will use the color assigned to the foreground color (HLU color index 1, NhlFOREGROUND).

Return Values

The NhlSetColor C function returns a value of type NhlErrorTypes, and the NhlFSetColor Fortran subroutine returns the error in ierr. The following table indicates what the various return Error Values mean:
Value	|			Meaning
NOERROR	|	function successful
INFO	|	minor recoverable error
WARNING	|	recoverable error
FATAL	|	function failed; continuing the program
	|       may result in core dump

See Also