views:

244

answers:

2

i added below codes. But it generates to me 16 color. but i need 16 color between "red" and "khaki". i don't need gradient flow. My colors look like gradient flow. My colors must not closer to each other. Because i will use this codes return values in chart columns. they are too near each other.

  static class Program
    {

        [STAThread]
        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;
        }
    }
+2  A: 
Greg
i want to see other color. Such as Brown or pink
Phsika
So you want something more like http://www.colorschemer.com/online.html ?
Greg
+2  A: 

The revised text of question is pretty clear: you want 16 colors on a gradient "between" Red and Khaki where the visual difference between any two colors is visually more significant than the colors you chose are.

Perhaps a better title would be "What algorithm can I use to generate 16 visually distinctive colors between Red and Khaki?"

I don't think there is one. Red (255, 255, 0) and Khaki (255, 240, 230) just aren't that different: RGB difference = (0,15,-230)

If you divide it up in 16 equal steps like you do, the resultant colors are close enough together to look like a gradient as you said. If you were to use unequal steps, (perhaps a logarithmic scale), your results would be worse, at least at one end of your range.

I think you need to either a) choose different endpoints or b) choose discrete colors without trying to get them between your endpoints

Or you might want to look at this thread about choosing distinct colors.

JeffH