Color parameters

New to Analytica 5.0

Several built-in functions include parameters that expect a color, and you might want to create your own User-defined functions that expect colors as well. A color parameter is tagged with the Color qualifier in the function's parameter declaration. The caller can provide either a textual name of a color or a color integer.

Color names

When specifying a color by name, a textual name is provided. For example, CellFill('Green'). The following table shows the color names that are recognized.

 Name Color         
AliceBlue 
AntiqueWhite 
Aqua 
Aquamarine 
Azure 
Beige 
Bisque 
Black 
BlanchedAlmond 
Blue 
BlueViolet 
Brown 
BurlyWood 
CadetBlue 
Chartreuse 
Chocolate 
Coral 
CornflowerBlue 
Cornsilk 
Crimson 
Cyan 
DarkBlue 
DarkCyan 
DarkGoldenrod 
DarkGray 
DarkGreen 
DarkKhaki 
DarkMagenta 
DarkOliveGreen 
DarkOrange 
DarkOrchid 
DarkRed 
DarkSalmon 
DarkSeaGreen 
DarkSlateBlue 
DarkSlateGray 
DarkTurquoise 
DarkViolet 
DeepPink 
DeepSkyBlue 
DimGray 
DodgerBlue 
Firebrick 
FloralWhite 
ForestGreen 
Fuchsia 
Gainsboro 
GhostWhite 
Gold 
Goldenrod 
Gray 
Green 
GreenYellow 
Honeydew 
HotPink 
IndianRed 
Indigo 
Ivory 
Khaki 
Lavender 
LavenderBlush 
LawnGreen 
LemonChiffon 
LightBlue 
LightCoral 
LightCyan 
LightGray 
LightGreen 
LightPink 
LightSalmon 
LightSeaGreen 
LightSkyBlue 
LightSlateGray 
LightSteelBlue 
LightYellow 
Lime 
LimeGreen 
Linen 
Magenta 
Maroon 
MediumAquamarine 
MediumBlue 
MediumOrchid 
MediumPurple 
MediumSeaGreen 
MediumSlateBlue 
MediumSpringGreen 
MediumTurquoise 
MediumVioletRed 
MidnightBlue 
MintCream 
MistyRose 
Moccasin 
NavajoWhite 
Navy 
OldLace 
Olive 
OliveDrab 
Orange 
OrangeRed 
Orchid 
PaleGoldenrod 
PaleGreen 
PaleTurquoise 
PaleVioletRed 
PapayaWhip 
PeachPuff 
PeaGreen 
Peru 
Pink 
Plum 
PowderBlue 
Purple 
Red 
RedPeach 
RosyBrown 
RoyalBlue 
SaddleBrown 
Salmon 
SandyBrown 
SeaGreen 
SeaShell 
Sienna 
Silver 
SkyBlue 
SlateBlue 
SlateGray 
SmoothBlue 
Snow 
SpringGreen 
SteelBlue 
Tan 
Teal 
Thistle 
Tomato 
Turquoise 
Violet 
Wheat 
White 
WhiteSmoke 
Yellow 
YellowGreen 

Color integers

A color integer encodes the RGB (red, green and blue) channels, and optionally the Alpha channel, numerically. The value is encoded as:

0xff000000 * alpha + 0x00ff0000 * red + 0x0000ff00 * green + 0x000000ff * blue

where «alpha», «red», «green» and «blue» are each between 0 and 255 inclusively. Without the alpha, an RGB number is

0x00ff0000 * red + 0x0000ff00 * green + 0x000000ff * blue

Color integers are often written in hex, such as 0x4682b4 for 'SteelBlue, where the red is 0x46, the green is 0x82, and the blue is 0xb4.

An «alpha» of 255 (0xff) is totally opaque, and an «alpha» of 1 (0x01) is almost completely transparent. When the alpha is 0x00, built-in function understand this to be an RGB number with full opacity.

Color parameters

You might define your own user-defined functions that accept a color parameter. For example, the following UDF would return the Red color channel for a color:

Function GetRed( c : Color Atom ) := BitAnd([ BitShift(c,16), 0xff ])
GetRed( ['YellowGreen', 'Olive', 0x12345678] ) → [ 0x009a, 0x0080, 0x0034 ]
(Note: To see the result in Hex, set the number format to Hexadecimal)

Built-in functions that have color parameters

See Also

Comments


You are not allowed to post comments.