mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 07:16:49 +02:00
TAChart: More speedup of TADrawerSVG.ColorToHex. Issue #40967. Patch by Alexey Torgashin.
This commit is contained in:
parent
71526ba83e
commit
3d6170cf9e
@ -128,8 +128,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function ColorToHex(AColor: TFPColor): String;
|
function ColorToHex(AColor: TFPColor): String;
|
||||||
|
const
|
||||||
|
SHexDigits: PChar = '0123456789ABCDEF'; // PChar for indices to begin with 0
|
||||||
var
|
var
|
||||||
r, g, b: String[2];
|
r, g, b: byte;
|
||||||
begin
|
begin
|
||||||
if AColor = colBlack then
|
if AColor = colBlack then
|
||||||
Result := 'black'
|
Result := 'black'
|
||||||
@ -137,14 +139,17 @@ begin
|
|||||||
Result := 'white'
|
Result := 'white'
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
r := IntToHex(AColor.Red shr 8, 2);
|
r:= AColor.Red shr 8;
|
||||||
g := IntToHex(AColor.Green shr 8, 2);
|
g:= AColor.Green shr 8;
|
||||||
b := IntToHex(AColor.Blue shr 8, 2);
|
b:= AColor.Blue shr 8;
|
||||||
SetLength(Result, 7);
|
SetLength(Result, 7);
|
||||||
Result[1]:= '#'; // #rrggbb
|
Result[1]:= '#'; // #rrggbb
|
||||||
Move(r[1], Result[2], 2);
|
Result[2]:= SHexDigits[Hi(r)];
|
||||||
Move(g[1], Result[4], 2);
|
Result[3]:= SHexDigits[Lo(r)];
|
||||||
Move(b[1], Result[6], 2);
|
Result[4]:= SHexDigits[Hi(g)];
|
||||||
|
Result[5]:= SHexDigits[Lo(g)];
|
||||||
|
Result[6]:= SHexDigits[Hi(b)];
|
||||||
|
Result[7]:= SHexDigits[Lo(b)];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user