Darken or Lighten TColor?
From :http://www.swissdelphicenter.ch/torry/showcode.php?id=1411
Author: TheB_6030 Homepage: http://nav.to/PenguinProductions/
// Takes a TColor and returns either the lighter or darker color, depending on
// the supplied integer (percentage of original to add or subtract)
// I don't know if this is 100% correct - I did it away from my computer.
function TMainForm.ChangeColor(InputColor: TColor; Lighten: Boolean; n: Extended): TColor;
var
r,g,b: extended;
begin
// Grab RGB values
r := GetRValue(InputColor);
g := GetGValue(InputColor);
b := GetBValue(InputColor);
// Do the operation
if Lighten = True then
begin
r := r+((r/255)*100);
g := g+((g/255)*100);
b := b+((b/255)*100);
end else
begin
r := r-((r/255)*100);
g := g-((g/255)*100);
b := b-((b/255)*100);
end;
// Check whether result is in range
if r > 255 then r := 255;
if r < 0 then r := 0;
if g > 255 then g := 255;
if g < 0 then g := 0;
if b > 255 then b := 255;
if b < 0 then b := 0;
// Send it out
Result := RGB(byte(Round(r)),byte(Round(g)),byte(Round(b)));
end;