I want to generate a heat map in windows form. I have a set of points as the input. How to go about doing this in the simplest way? Thanks.
A solution going from red to yellow to green
static Color CreateHeatColor(int value, decimal max)
{
if (max == 0) max = 1M;
decimal pct = value/max;
Color color = new Color();
color.A = 255;
if (pct < 0.34M)
{
color.R = (byte) (128 + (127 * Math.Min(3 * pct, 1M)));
color.G = 0;
color.B = 0;
}
else if (pct < 0.67M)
{
color.R = 255;
color.G = (byte) (255 * Math.Min(3 * (pct - 0.333333M), 1M));
color.B = 0;
}
else
{
color.R = (byte)(255 * Math.Min(3 * (1M - pct), 1M));
color.G = 255;
color.B = 0;
}
return color;
}