I am working my way through a book called Head First C#. It doesnt explain what the loop is saying in detail. It would be great if someone can explain the part I dont understand.
The way I am reading this is as long as c is less than 254 and visible c will increase by 1 each time the loop is gone through. What I dont understand is the (c, 255 – c, c)
private void button1_Click(object sender, EventArgs e)
{
while (Visible)
{
for (int c = 0; c < 254 && Visible; c++)
{
this.BackColor = Color.FromArgb(c, 255 - c, c);
Application.DoEvents();
System.Threading.Thread.Sleep(5);
}
}
}
The arguments to that function are
red, green, blue. The maximum value is 255 and the minimum value is 0. This function fades the color from full green into no green, full red-blue (magenta).The loop will continue until either the form is made invisible (assuming this event handler is on a form,
Visiblerefers tothis.Visibleand will be false if the form is hidden), or the maximum value is reached (c < 254will be false).Here’s a chart that shows the common colors based on their red, green, and blue values. In the chart, the format is
RRGGBB, whereRRis the red value,GGis the green value, andBBis the blue value. The numbers are in hex (runs from 0 to FF instead of 0 to 255).