From c9a4f79b92a8a5b424bbd187c9b39e9b73be4c6d Mon Sep 17 00:00:00 2001 From: Maxim Ganetsky Date: Fri, 5 Jan 2024 18:55:58 +0300 Subject: [PATCH] LCL, Graphics.pp: added IncColor() counterpart to the existing DecColor() function, patch by Don Siders, issue #40682 --- lcl/graphics.pp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lcl/graphics.pp b/lcl/graphics.pp index e30c28b00b..4ab7e89964 100644 --- a/lcl/graphics.pp +++ b/lcl/graphics.pp @@ -1925,6 +1925,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 @@ -2711,6 +2712,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;