NCL Website header
NCL Home > Documentation > Functions > Color routines

namedcolor2rgba

Returns the RGBA quadruplets of the given list of named colors.

Available in version 6.2.0 and later.

Prototype

	function namedcolor2rgba (
		colors [*] : string   
	)

Arguments

colors

A string array of named colors.

Return value

A float array of size n x 4 is returned, where n is the number of named colors input.

Description

This function returns the RGBA quadruplet of the given list of named colors. The 'A' component of the RGBA is set to 1.0 (fully opaque). If any of the input colors are invalid, missing values will be returned for that quadruplet.

Note: this function will be moved from "gsn_code.ncl" to "utilities.ncl" in NCL V6.4.0. This shouldn't have any affect on your scripts, since these two scripts are automatically loaded by NCL. To use this function with older versions of NCL, you must load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" at the top of your script.

See Also

draw_color_palette, namedcolor2rgb, span_named_colors, gsn_draw_named_colors, NhlNewColor, gsn_define_colormap

Examples

colors = (/"white", "black", "PeachPuff", "MintCream", "SlateBlue",  \
           "Khaki", "OliveDrab","BurlyWood", "LightSalmon", "Coral", \
           "HotPink", "LemonChiffon", "AliceBlue", "LightGrey",      \
           "MediumTurquoise", "DarkSeaGreen", "Peru", "Tomato",      \
           "Orchid","PapayaWhip","BadColor"/)

rgb = namedcolor2rgba(colors)
write_matrix(rgb,"4f5.2",0)

The output will be:

 1.00 1.00 1.00 1.00
 0.00 0.00 0.00 1.00
 1.00 0.85 0.73 1.00
 0.96 1.00 0.98 1.00
 0.42 0.35 0.80 1.00
 0.94 0.90 0.55 1.00
 0.42 0.56 0.14 1.00
 0.87 0.72 0.53 1.00
 1.00 0.63 0.48 1.00
 1.00 0.50 0.31 1.00
 1.00 0.41 0.71 1.00
 1.00 0.98 0.80 1.00
 0.94 0.97 1.00 1.00
 0.83 0.83 0.83 1.00
 0.28 0.82 0.80 1.00
 0.56 0.74 0.56 1.00
 0.80 0.52 0.25 1.00
 1.00 0.39 0.28 1.00
 0.85 0.44 0.84 1.00
 1.00 0.94 0.84 1.00
********************