VB - An example on how to draw very nice shades of random colours
Just copy and paste the code in an empty project, run it, and enjoy :)
VB Code:
Option Explicit
Private Type tRGB
R As Integer
G As Integer
B As Integer
End Type
Private Sub Form_Load()
Dim K As Single, Col1 As tRGB, Col2 As tRGB
Me.Show
Me.ScaleMode = vbTwips
Me.WindowState = 2
DoEvents
Randomize
Col1.R = (235 * Rnd) + 20
Col1.G = (235 * Rnd) + 20
Col1.B = (235 * Rnd) + 20
Col2.R = (235 * Rnd) + 20
Col2.G = (235 * Rnd) + 20
Col2.B = (235 * Rnd) + 20
Do
For K = 0 To Me.ScaleHeight Step Screen.TwipsPerPixelY
Me.Line (0, K)-(Me.ScaleWidth, K), Colr(Col1, Col2)
Pause 0.001
Next K
For K = Me.ScaleHeight To 0 Step -Screen.TwipsPerPixelY
Me.Line (0, K)-(Me.ScaleWidth, K), Colr(Col1, Col2)
Pause 0.001
Next K
Loop
End Sub
Private Sub Pause(ByVal Interval As Double)
Dim EndTime As Double
EndTime = Timer + Interval
Do
DoEvents
Loop Until Timer >= EndTime
End Sub
'For drawing smooth colors
Private Function Colr(ByRef xRGB As tRGB, ByRef ARGB As tRGB) As Long
If ARGB.R < xRGB.R Then
ARGB.R = ARGB.R + 1
ElseIf ARGB.R > xRGB.R Then
ARGB.R = ARGB.R - 1
Else
xRGB.R = (235 * Rnd) + 20
End If
If ARGB.G < xRGB.G Then
ARGB.G = ARGB.G + 1
ElseIf ARGB.G > xRGB.G Then
ARGB.G = ARGB.G - 1
Else
xRGB.G = (235 * Rnd) + 20
End If
If ARGB.B < xRGB.B Then
ARGB.B = ARGB.B + 1
ElseIf ARGB.B > xRGB.B Then
ARGB.B = ARGB.B - 1
Else
xRGB.B = (235 * Rnd) + 20
End If
Colr = RGB(ARGB.R, ARGB.G, ARGB.B)
End Function
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Unload Me
End
End Sub