LCL, Graphics.pp: added IncColor() counterpart to the existing DecColor() function, patch by Don Siders, issue #40682

(cherry picked from commit c9a4f79b92)
This commit is contained in:
Maxim Ganetsky 2024-01-05 18:55:58 +03:00
parent 9590c4978c
commit 56721fe772

View File

@ -1939,6 +1939,7 @@ function StringToColorDef(const S: shortstring; const DefaultValue: TColor): TCo
procedure GetColorValues(Proc: TGetColorStringProc);
function InvertColor(AColor: TColor): TColor;
function DecColor(AColor: TColor; AQuantity: Byte): TColor;
function IncColor(AColor: TColor; AQuantity: Byte): TColor;
function IsSysColor(AColor: TColorRef): Boolean;
function Blue(rgb: TColorRef): BYTE; // does not work on system color
@ -2725,6 +2726,18 @@ begin
Result := RGBToColor(R, G, B);
end;
// Increases the component RGB values in a color by the specified amount
function IncColor(AColor: TColor; AQuantity: Byte): TColor;
var
R, G, B : Byte;
begin
RedGreenBlue(ColorToRGB(AColor), R, G, B);
R := Min(255, Integer(R) + AQuantity);
G := Min(255, Integer(G) + AQuantity);
B := Min(255, Integer(B) + AQuantity);
Result := RGBToColor(R, G, B);
end;
function IsSysColor(AColor: TColorRef): Boolean;
begin
Result := (AColor and SYS_COLOR_BASE) <> 0;