How can i generate 16 color. my starter color is \"Red\" and my terminal color \"khaki\". i have to insert 14 color. But it looks like gradient flow. Forexample color.Black
You should be able to interpolate? This example is winforms, but the maths is identical - simply that with ASP.NET you'd have to write the color in the hex form. You may also (with ASP.NET) need to find the RGB values separately - but for info, Khaki (in winforms) is {240,230,140} (red is obviously {255,0,0}).
using System.Drawing;
using System.Windows.Forms;
static class Program {
static void Main()
{
Form form = new Form();
Color start = Color.Red, end = Color.Khaki;
for (int i = 0; i < 16; i++)
{
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);
Button button = new Button();
button.Dock = DockStyle.Top;
button.BackColor = Color.FromArgb(r, g, b);
form.Controls.Add(button);
button.BringToFront();
}
Application.Run(form);
}
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;
}
}