private static void getRGBFromPercent(out int r, out int g, out int b, int percent, double light = 0)
{
if (light > 1) { light = 1; }
if (light < -1) { light = -1; }
r = 511 - percent * 255 / 50;
g = percent * 255 / 50;
b = 0;
if (r < 0) { r = 0; }
if (g < 0) { g = 0; }
if (r > 255) { r = 255; }
if (g > 255) { g = 255; }
if (light > 0)
{
r = (int)((255 - r) * light + r);
g = (int)((255 - g) * light + g);
b = (int)((255 - b) * light + b);
}
else
{
light += 1;
r = (int)(r * light);
g = (int)(g * light);
//b = (int)(b * light); // b == 0 anyway
}
}