Skip to content

Commit 0fef961

Browse files
committed
Utils: added function to change the brightness of a Color
1 parent b136ea4 commit 0fef961

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Source/Vcl.DbAwareLabeledUtils.pas

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function GetStyledColor(Color: TColor): TColor;
6161
function PadL(Const InString: String; Len: Integer; FChar: Char): String;
6262
function PadR(Const InString: String; Len: Integer; FChar: Char): String;
6363

64+
function LightenColor(Color: TColor; Percentage: Cardinal): TColor;
65+
6466
implementation
6567

6668
uses
@@ -69,6 +71,7 @@ implementation
6971
, Vcl.DbAwareLabeledConsts
7072
, Vcl.Controls
7173
, Vcl.Themes
74+
, Vcl.GraphUtil
7275
;
7376

7477
//sostituisce un carattere in un altro all'interno di una stringa (zero-based)
@@ -368,4 +371,15 @@ function PadR(Const InString: String; Len: Integer; FChar: Char): String;
368371
Result := InString + StringOfChar(FChar,Len-Length(InString));
369372
end;
370373

374+
function LightenColor(Color: TColor; Percentage: Cardinal): TColor;
375+
var
376+
rgb: LongInt;
377+
h, s, l: Word;
378+
begin
379+
rgb := ColorToRGB(Color);
380+
ColorRGBToHLS(rgb, h, l, s);
381+
l := (Cardinal(l) * Percentage) div 100;
382+
Result := TColor(ColorHLSToRGB(h, l, s));
383+
end;
384+
371385
end.

0 commit comments

Comments
 (0)