Color Values in SenseTalk

A color can be represented in SenseTalk as a combination of component values in any of several different formats. The recognized formats are listed in the following table:

Color Format

Example Value




Red, green, and blue values from 0 to 255



Red, green, blue, and alpha values from 0 to 255



Red, green, and blue values in hexadecimal form as used in web pages


W, 0.241

White value from 0 (black) to 1 (white)k


WA, 0.241, 1.000

White and alpha values from 0 to 1


RGB, 0.5, 0, 0.25

Red, green, and blue values from 0 to 1


RGBA, 0.5, 0.0, 0.25, 1.0

Red, green, blue, and alpha values from 0 to 1


HSB, 0.917, 1.0, 0.5

Hue, saturation, and brightness values from 0 to 1


HSBA, 0.917, 1.0, 0.5, 1.0

Hue, saturation, brightness and alpha values from 0 to 1


CMYK, 0.143, 0.942, 0.225, 0.274

Cyan, magenta, yellow, and black values from 0 to 1


CMYKA, 0.143, 0.942, 0.225, 0.274, 1.000

Cyan, magenta, yellow, black, and alpha values from 0 to 1

In addition, a number of color names are recognized, as defined by the namedColors global property.

The default color format, known as the Basic format, is a list of three numbers with values in the range 0 to 255, indicating the amounts of red, green, and blue that compose the color. The Alpha format adds a fourth number, known as the alpha value, that represents the opacity of the value, for systems that can work with partially-transparent colors. An alpha value of zero represents clear.

The HTML format is a single value consisting of a pound sign (#) followed by two hexadecimal digits each for the red, green, and blue components of the color. Each of the other formats is a list beginning with a format code, followed by numeric values in the range 0.0 to 1.0 representing the amount of each component in a particular color model.

When evaluating a value as a color, SenseTalk can accept either a list of appropriate values, or a text list (a text string consisting of values separated by commas).

Related Global Properties

In addition to the commands and functions described below, there are two SenseTalk global properties you can use to govern certain aspects of working with color in scripts:

These global properties are defined on Global and Local Properties for Working with Values.

color, asColorFunction

What they Do

The color() function returns a color value from a string or list in one of the recognized color formats. Any of the 11 formats described for the colorFormat property are recognized, as either text lists (with items separated by commas) or as true lists of values. In addition, color names can be used, as defined by the namedColors global property.

When to Use Them

Use the color() function whenever a color is needed from a value that may not already be represented as a color. One common use of the color() function is to compare two colors that may be in different formats to see if they represent the same color.


put color("#00FFFF") is the color of "aqua" -- shows ‘true’

if color of stripe is color("red") then ...

Tech Talk

Syntax: color(stringOrList)
the color of stringOrList

The color function converts a value to its internal representation as a color. This can also be called using the synonymous asColor function, or the as color operator.


red(), green(), blue(), hue(), saturation(), brightness(), cyan(), magenta(), yellow(), black(), white(), and alpha() Functions

What they do

These functions each return one component value of a color interpreted using a particular color space. The value returned is always in the range from 0 (the color does not contain any of that component) to 1 (the color contains the maximum possible amount of that component).

When to Use Them

Use the red() , green(), and blue() functions to obtain the individual components of a color as represented using the red/green/blue color space. Use the hue() , saturation(), and brightness() functions to get the individual components of a color as represented using the hue, saturation, and brightness color space. Use the cyan() , magenta() , yellow(), and black() functions to obtain the individual components of a color as represented using the cyan/magenta/yellow/black color space that is commonly used when printing. Use the white() function to evaluate a color using a greyscale color space and return the level of white from 0 (black) to 1 (white). Use the alpha() function to return the opacity of a color value, from 0 (transparent) to 1 (opaque).


put the red of "purple" -- 0.5

put blue("#00FFFF") -- 1

put hue("purple") -- 0.833333

put yellow("#00FFFF") -- 0.133043

put white of "purple" -- 0.268208

Tech Talk

Syntax: red(stringOrList) , blue(stringOrList) , ...
the red of stringOrList , the blue of stringOrList , ...

Each of these functions evaluates stringOrList as a color and returns a value in the range 0 to 1 representing the amount of the requested color component that is present in that color in the appropriate color space. Note that the black() and white() functions are not opposites, as they evaluate the color in different color spaces.


color Function

the colorFormatGlobal Property

is a color operator

What it Does

The is a color operator is an extension to the standard is a operator that tests whether a given value can be interpreted as a color.

When to Use It

Use the is a color operator whenever your script needs to determine if a value is valid as a color.


put "#00FFFF"is a color -- shows ‘true’

if shade is a color then then ...

Tech Talk

Syntax: value is a color

If value is a string or list in one of the recognized color formats, or is one of the color names defined by the namedColors global property, the is a color operator will evaluate to “true”.

STColorVersion function

What it Does

Returns the version number of the STColor Xmodule.

When to Use It

You will rarely need the STColorVersion() function, but might use it if there is a need to check the version of the color module in use for compatibility reasons.


if the STColorVersion < 1.02 then ...

Tech Talk


the STColorVersion

The STColorVersion function returns a number.


This topic was last updated on June 21, 2019, at 02:49:49 PM.

Eggplant icon | Documentation Home | User Forums | Support | Copyright © 2020 Eggplant