My below Codes gives me error:"Index was outside the bounds of the array." My Algorithms create Colorset arrays that's arrays dimention '16', But i need Second one 'colorSetLegend' that's dimensions:32 if you look below Bold codes that returns me error.
Color[] colorSetLegend = new Color[32];
Color[] colorSet = { Color.Red, Color.Blue, Color.Green, Color.Yellow };
Color end = Color.White;
colorSet = ColorMaker.GenerateColor(colorSet, end);
for (int i = 0; i < colorSet.Length; )
{
for (int j = 0; j < colorSetLegend.Length; )
{
colorSetLegend[j] = colorSet[i];
colorSetLegend[j++] = Color.Black;
i++;
}
}
My Color generator below:
public class ColorMaker
{
public static Color[] GenerateColor(Color[] baseColorSet, Color end)
{
Color[] colorSet = new Color[16];
int j = 0;
foreach (Color start in baseColorSet)
{
for (int i = 0; i < 15; i += 4)
{
int r = Interpolate(start.R, end.R, 15, i),
g = Interpolate(start.G, end.G, 15, i),
b = Interpolate(start.B, end.B, 15, i);
colorSet[j] = Color.FromArgb(r, g, b);
j++;
}
}
return colorSet;
}
static int Interpolate(int start, int end, int steps, int count)
{
float s = start, e = end, final = s + (((e - s) / steps) * count);
return (int)final;
}
}