Databases Reference
In-Depth Information
More desirable
Less desirable
n
a
u
u
FIGURE 5.24 Interval coloring scheme.
More importantly, notice that the colors must be in the order shown in Figure 5.25 for any transition
to occur at all. Thus, a green-yellow-red transition as described earlier would be impossible to
implement as the decimal constants go from 65280 (green) to 65535 (yellow) to 255 (red).
Every color the eye can discern is made up of the combination or absence of the colors red, green,
and blue. It is possible to construct a custom color in Excel VBA by directly manipulating the red,
green, and blue color components (often referred to as the RGB color components). Table 5.5 shows
the values of each RGB color component for the VB color constants. Notice that each color
component can have a value from 0-255, and therefore the gradient effect of each color component
on the overall composition color is in fact linear. When moving from one color to another color,
there is the potential to have up to three degrees of freedom in terms of manipulating the RGB
components. (Where a “degree of freedom” represents the total number of RGB color components
which must be varied to transition from one color to another color.)
Obviously, the greater the number of degrees of freedom, the more complex an operation is to
morph from one color to another. Accordingly, it would be wise to arrange the color shifts in such
a manner that the transitions from one color to another color occur with only one degree of freedom
differentiating one color to the next. This requires that the colors be arranged in a manner corre-
sponding to the order in which their wavelength occurs in the color spectrum, as opposed to the
order given in Table 5.5, which is from the Excel VB help documentation.
In Figure 5.26, it can readily be seen that following the order from one color to the next results
in a change to only one of the three RGB components. For example, going from red to yellow is
accomplished by changing the green value from 0 to 255. Using such a color shifting scheme makes
it very easy to gradually transition from one color to the next. What is needed now is a subroutine
that takes this a step further by creating an array that not only contains the RGB information but the
parameters required for a successful gradual transition from one color to the next. Table 5.6 shows
one method of representing the necessary information to implement such a transition.
Table 5.6 shows one method of representing this information. Column 1 shows the first array
dimension index. Column 2 contains the color name. Columns 3 to 5 contain the RGB color
component value for the current color. Column 6 contains an index to the RGB Component that
must be altered to transition to the next color in the table (where R
3). Column 7
contains the value the Red, Green, or Blue component must be changed to in order to transition
from the current color in the table to the next color in the table.
=
1, G
=
2, B
=
FIGURE 5.25 Visual Basic color code constants.
Search WWH ::




Custom Search