I'm trying to create a timer bar for a quiz game which during 10 seconds will shrink in size and fade from green to red.
Here's my existing code:
double timerWidth = 600;
double dblRed = 0;
double dblGreen = 255;
int intRed = 0;
int intGreen = 255;
for (int t = 1000; t != -1; t--) // gives player 10 seconds to select the right answer
{
string strTime = intTime.ToString();
lblTime.Text = strTime;
intTime--;
int intTimerWidth = Convert.ToInt32(timerWidth);
imgTimer.Size = new Size(intTimerWidth, 30);
dblRed = dblRed + 0.23;
dblGreen = dblGreen - 0.23;
intRed = Convert.ToInt32(dblRed);
intGreen = Convert.ToInt32(dblGreen);
imgTimer.BackColor = Color.FromArgb(intRed, intGreen, 0);
wait(1); // wait 0.001 seconds
timerWidth = timerWidth - 0.6;
if (intTime == 0)
{
checkAnswer(); // when 10 seconds has ellapsed, ellapsed, checks answer
}
}
It functions at current, but using RGB it fades from green to brown to red, which obviously isn't the desired effect. I'm hoping to go from green, to yellow, to orange and then to red which can be achieved through HSL but I can't figure out how to convert to that.
Hope I've asked this okay, I don't frequent these forums.
Thank you!