# Color to fade from bright red to dark red with RGB-function

Hi,
I think this a quite easy question for an expert, but I do not manage it:
In a database I have a field where items are in that are awaited for a certain date. If the items are not back by that date the row is paint in red. Now I want that the color is not only red but a certain tone of red depending on the days the item is not in time for ex. the item is in delay for 100 days, the row is dark red, for 50 days a lighter red and so on. I tried with: brush.color:= RGB(255,0,0) and that's OK only with red. How must I insert the RGB-values to have different shades of red ?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
255 is full brightness, 0 is nil. So use a value in between 0 and 255 for varying degrees of brightness. If you only use the first value, that is the red. Use a calculation to get degrees of redness for number of days.

Example:
if (DaysLate <= 0) then begin
Brush.Color := clWhite;
end else if (DaysLate <= 100) then begin
Brush.Color := RGB(Round(((100-DaysLate)/100) * 255), 0, 0);
end else begin
Brush.Color := clBlack;
end;

Which gives a white background if DaysLate is zero or less, varying degrees of red to black for 1 - 100 days late, and black for over 100 days late. Alter to suit your requirements.

Geoff M.
Commented:
Actually, maybe you mean white to red. In which case that should be:
if (DaysLate <= 0) then begin
Brush.Color := clWhite;
end else if (DaysLate <= 100) then begin
v := Round(((100-DaysLate)/100) * 255);
Brush.Color := RGB(255, v, v);
end else begin
Brush.Color := clRed;
end;

Geoff M.

Experts Exchange Solution brought to you by