Color picker does not give gradient appearance

Posted by ykaratoprak on Stack Overflow See other posts from Stack Overflow or by ykaratoprak
Published on 2009-06-12T13:35:22Z Indexed on 2010/04/10 19:23 UTC
Read the original article Hit count: 283

Filed under:
|
|
|

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;
        }
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET