1
0
mirror of synced 2024-12-22 09:13:07 +01:00

Added: BlendColors function

This commit is contained in:
Mark van Renswoude 2004-11-23 12:56:44 +00:00
parent ab7d4298e3
commit 85ca72584c

View File

@ -47,6 +47,16 @@ uses
}
procedure AAOwned(const AOwner: TComponent);
{
:$ Blends the two colors using the specified alpha value
:: The alpha determines how much of the foreground color is applied to the
:: background color. The alpha value must be between 0 and 255 (where 0
:: indicates full transparency and 255 an opaque foreground).
}
function BlendColors(const ABackground, AForeground: TColor;
const AAlpha: Byte): TColor;
implementation
uses
@ -137,4 +147,24 @@ begin
AAControl(TControl(AOwner.Components[iControl]));
end;
function BlendColors;
var
cBack: Cardinal;
cFore: Cardinal;
bBack: Byte;
begin
cBack := ColorToRGB(ABackground);
cFore := ColorToRGB(AForeground);
bBack := 255 - AAlpha;
Result := RGB(((GetRValue(cBack) * bBack) +
(GetRValue(cFore) * AAlpha)) shr 8,
((GetGValue(cBack) * bBack) +
(GetGValue(cFore) * AAlpha)) shr 8,
((GetBValue(cBack) * bBack) +
(GetBValue(cFore) * AAlpha)) shr 8);
end;
end.