Databases Reference
In-Depth Information
FIGURE 5.27 A color morphing sample application.
A sample application has been set up to demonstrate how the CreateRGBColorArray
subroutine can be utilized to morph colors from one value to another value. It can be run by selecting
the following from the menu: A DA->Chapter 5 -> M orph. The sample application presents the GUI
shown in Figure 5.27, in which the user specifies an initial starting color and a final ending color.
Notice that the colors are presented in spectral order, and when the user selects an initial color, the
final colors are limited to those following the chosen initial color. (The user could, however, create
an application that would allow backward as well as forward morphing.)
When the test button is pushed, the program displays the current color in the box above the
test button and begins morphing this color from the initial color to the final color. As the color is
being transitioned, the RGB components are displayed in real time during the morphing process.
The following subroutine is utilized to accomplish the morphing task.
Private Sub Button_Test_Click()
Dim ct As Integer 'Color Transitions
Dim sl As Integer 'Shading Level
Dim slvalue As Integer
Dim RGBCode As Long
If ComboBoxIColor.Text = "" Or ComboBoxFColor.Text = "" Then
MsgBox "You Must Choose and Initial and Final Color!",
vbOKOnly + vbInformation, _
"Required Test Parameters Not Found!"
Exit Sub
End If
For ct = frm5Morph.ComboBoxIColor.ListIndex + 1 To
(frm5Morph.ComboBoxFColor.ListIndex _
+ frm5Morph.ComboBoxIColor.ListIndex + 1)
For sl = 0 To 255
If Colors(ct, 5) = 0 Then
'Shading Value Decreasing
slvalue = 255 - sl
Else
'Shading Value Increasing
slvalue = sl
End If
Select Case Colors(ct, 4)
Search WWH ::




Custom Search