-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvgIcon.Utils.pas
42 lines (34 loc) · 1.12 KB
/
svgIcon.Utils.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
unit svgIcon.Utils;
interface
uses
System.SysUtils,
Vcl.Graphics,
Vcl.GraphUtil;
function SvgWrap(aHeight,aWidth:integer;aContents:string;aRootColor:TColor=clNone):string;
function SvgRecolor(aContents:String;aColor:TColor=clNone):String; overload;
function SvgRecolor(aContents:String;aColor:String):String; overload;
implementation
function SvgRecolor(aContents:String;aColor:TColor=clNone):String;
var
sColor : string;
begin
sColor := '';
if aColor <> clNone then
sColor := ' fill="'+ColorToWebColorStr(aColor)+'"';
result := svgRecolor(aContents,sColor);
end;
function SvgRecolor(aContents:String;aColor:String):String; overload;
begin
Result := StringReplace(aContents,' fill="#212121"',aColor,[rfReplaceAll,rfIgnoreCase]);
end;
function SvgWrap(aHeight,aWidth:integer;aContents:string;aRootColor:TColor=clNone):string;
var
sColor : string;
begin
sColor := '';
if aRootColor <> clNone then
sColor := ' fill="'+ColorToWebColorStr(aRootColor)+'"';
result := '<svg viewBox="0 0 '+IntToStr(aHeight)+' '+IntToStr(aWidth)+'"'+sColor+' xmlns="http://www.w3.org/2000/svg">' +
aContents + '</svg>';
end;
end.