Как насчет чего-то вроде
VB.Net
Private Shared Function ColorGradientRedToBlue(ByVal index As Single) As Color
If index < 0 OrElse index > 1.0R Then
Throw New ArgumentException("index must be between 0 and 1")
End If
Return Color.FromArgb(CInt(((1.0R - index) * 255)), 0, CInt((index * 255)))
End Function
C #
static Color ColorGradientRedToBlue(float index)
{
if (index < 0 || index > 1.0)
throw new ArgumentException("index must be between 0 and 1");
return Color.FromArgb((int)((1.0 - index) * 255), 0 ,(int)(index * 255));
}