skip to main content

Working With Controls : Creating a control : Color management : Using RGB

Using RGB
A more flexible and precise way to define colors is RGB.
The RGB color model is an additive color model in which red, green, and blue light are added together in various ways. The name of the model comes from the initials of the three additive primary colors, red, green, and blue.
RGB colors can be specified for all those properties that define either a foreground or a background color, such as FOREGROUND-COLOR and BACKGROUND-COLOR. Properties that can define both, such as COLOR, must use only the attributes explained above.
To specify an RGB color the word RGB must be put in front of the value
RGB color is a number that can be calculated using the following formula:
Red * 2^16 + Green * 2^8 + Blue * 2^0
Red, Green and Blue can range from 0 to 255.
When the RGB color is applied to a foreground element, transparency can be defined, too:
Alpha * 2^24 + Red * 2^16 + Green * 2^8 + Blue * 2^0
Alpha can range from 0 (opaque) to 127 (transparent).
In order to specify the RGB color using a variable, a signed numeric data item must be used, the RGB keyword must be omitted, and the color value must be calculated as follows:
( [ Alpha * 2^24 + ] Red * 2^16 + Green * 2^8 + Blue * 2^0 ) * -1
In practice, putting the RGB keyword before the color value or multiplying the value by -1 have the same effect.
When a color property set with RGB is queried, the INQUIRE statement returns the the decimal negative number representing the RGB color.
Note: Colors are set and queried in the same way regardless of their type. The runtime distinguishes the two kinds of colors by using positive values for attributes and negative values for RGB. Since zero is a non-negative value, you shouldn’t use the value zero along with the RGB syntax, use 1 instead and you will obtain the same color.

Copyright (c) 2017 Veryant
Contact us
Please share your comments on this manual or on any
Veryant product documentation with the email button at the top left