Public Function GetGradients(ByVal StartColor As Drawing.Color, ByVal EndColor As Drawing.Color, ByVal NumGradients As Integer) As Drawing.Color()
Dim clrRet(NumGradients - 1) As Drawing.Color
Dim i As Integer
For i = 1 To NumGradients + 2
If i > 1 And i < NumGradients + 2 Then
Dim ThisClr As New Drawing.Color()
Dim iR As Integer = 0
Dim iG As Integer = 0
Dim iB As Integer = 0
If StartColor.R < EndColor.R Then
iR = Math.Round(((CInt(EndColor.R) - CInt(StartColor.R)) / (NumGradients + 1)), 0) * i + CInt(StartColor.R)
Else
iR = Math.Round(((CInt(StartColor.R) - CInt(EndColor.R)) / (NumGradients + 1)), 0) * i + CInt(EndColor.R)
End If
If StartColor.G < EndColor.G Then
iG = Math.Round(((CInt(EndColor.G) - CInt(StartColor.G)) / (NumGradients + 1)), 0) * i + CInt(StartColor.G)
Else
iG = Math.Round(((CInt(StartColor.G) - CInt(EndColor.G)) / (NumGradients + 1)), 0) * i + CInt(EndColor.G)
End If
If StartColor.B < EndColor.B Then
iB = Math.Round(((CInt(EndColor.B) - CInt(StartColor.B)) / (NumGradients + 1)), 0) * i + CInt(StartColor.B)
Else
iB = Math.Round(((CInt(StartColor.B) - CInt(EndColor.B)) / (NumGradients + 1)), 0) * i + CInt(EndColor.B)
End If
clrRet(i - 2) = Drawing.Color.FromArgb(iR, iG, iB)
End If
Next
Return clrRet
End Function