Recently I started a project where I needed to use colors to represent classes gradiated between two colors. While the colorblend and blend objects in .NET is great if you want to display color gradients, its not so usefull if you want to know what the color is at 70% between two colors. Thus the color at a percentage of a gradient color. The code to do this below where color1 and color2 is the start and end colors and color1Perc is the percentage betweeen the two colors (with 0 being equal to color1 and 100 equal to color2). Please note the error checking is very basic an may need improvement.
Public Function colorMix(ByVal color1 As Color, _
ByVal color2 As Color, ByVal color1Perc As Double) As Color
Dim r As Integer, g As Integer, b As Integer
Dim ra As Double, ga As Double, ba As Double
Dim col As Color
Try
color1Perc = (color1Perc) / 100
ra = CDbl(color1.R) + ((CDbl(color2.R) - CInt(color1.R)) _
* color1Perc)
r = CInt(Math.Min(ra, 255))
ga = CDbl(color1.G) + ((CDbl(color2.G) - CInt(color1.G)) _
* color1Perc)
g = CInt(Math.Min(ga, 255))
ba = CDbl(color1.B) + ((CDbl(color2.B) - CInt(color1.B)) _
* color1Perc)
b = CInt(Math.Min(ba, 255))
col = Color.FromArgb(CByte(r), CByte(g), CByte(b))
Catch ex As Exception
col = color1
End Try
Return col
End Function