You specify a color by specifying a number that represents the color. You can specify the number explicitly or by using an expression that includes the RGB (r, g, b) function.
For the numbers and expressions that specify common colors, see Table 23-2.
The formula for combining color values into a number is:
red + 256*green + 256*256*blue
where the amount of each primary color (red, green, and blue) is specified as a value from 0 to 255.
The RGB function calculates the number from the amounts of red, green, and blue specified.
To create cyan, you use blue and green, but no red. If you wanted to create the most saturated (bright) cyan, you would use maximum amounts of blue and green in the formula, which is indicated by the number 255 for each. The following statements show the calculation:
red + 256*green + 256*256*blue
0 + 256*255 + 256*256*255
0 + 65280 + 16711680
16776960
The following expression specifies the brightest cyan:
RGB (0,255,255)
Notice that the expression specifies the maximum for green
and blue (255) and 0 for red. The expression returns the value 16776960.
To specify cyan, entering the expression RGB
(0
, 255
, 255
)
is the same as entering the number 16776960
.
Table 23-2 shows the numbers and expressions to enter for some common colors. The number and the expression return the same result; you can use either.
Copyright © 2004. Sybase Inc. All rights reserved. |