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:
The following color constants are available so you can easily specify system 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) |
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: