Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2003-10-26
2
Medium Priority
?
472 Views
Last Modified: 2012-05-04
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 ?
0
Comment
Question by:SCHUCla74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 8

Expert Comment

by:gmayo
ID: 9622474
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.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 400 total points
ID: 9622475
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.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question