Color

Certain actions and properties make use of color values. Most programmers use the pre-defined color constants to specify a desired color.

You may specify a color in the following places:

Available color constants

The following color constants are available so you can easily specify system colors:

CONST WHITE

&Hffffffff

CONST BLACK

&Hff000000

CONST GRAY_50

&Hff808080

CONST GREY_50

&Hff808080

CONST DARK_GRAY

&Hff555555

CONST LIGHT_GRAY

&Hffaaaaaa

CONST DARK_GREY

&Hff555555

CONST LIGHT_GREY

&Hffaaaaaa

CONST DARK_GREEN

&Hff00aa00

CONST LIGHT_GREEN

&Hff55ff55

CONST DARK_BLUE

&Hff0000aa

CONST LIGHT_BLUE

&Hff5555ff

CONST DARK_CYAN

&Hff00aaaa

CONST LIGHT_CYAN

&Hff55ffff

CONST DARK_PURPLE

&Hffaa00aa

CONST LIGHT_PURPLE

&Hffff55ff

CONST DARK_ORANGE

&Hffaa5500

CONST LIGHT_ORANGE

&Hffff5555

CONST YELLOW

&Hffffff55

CONST RED

&Hffaa0000

Custom Colors

You may specify a color that is not one of the pre-defined constant values. Colors consist of four byte values (numbers 0-255) which have been combined into a long number:

Opacity (0-255) x &H1000000 +
Red (0-255) x &H10000 +
Green (0-255) x &H100 +
Blue (0-255)

For example, the constant LIGHT_GREEN breaks down into the following parts:

&HFF x &H1000000 + (100% opaque)
&H55 x &H10000 + (33% red)
&HFF x &H100 + (100% green)
&H55 (33% blue)

Opacity

You may wonder what the opacity or opaqueness of a color means.
Opacity determines how much this color will obscure what's beneath it.

Here we see six horizontal rectangles with different colors and opacities. They have been drawn over four vertical rectangles.

The horizontal rectangles that are 100% opaque totally cover what is underneath. Those that are 50% opaque allow some color from below to show through.

Drawing with 0% opacity is effectively not drawing at all.

To create a new color based on one of the existing color constants, but using a lower opacity, use bitwise arithmetic; for example:

CONST RED_TRANSPARENT = RED BITAND &H7FFFFFFF