Skip to content

Commit

Permalink
Removed IsFloat function
Browse files Browse the repository at this point in the history
  • Loading branch information
carloBarazzetta committed Dec 2, 2020
1 parent e26a12e commit abde8aa
Showing 1 changed file with 9 additions and 16 deletions.
25 changes: 9 additions & 16 deletions Svg/SVGColor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,11 @@ function IsDecimal(const S: string): Boolean;
Result := True;
end;

function IsFloat(const S: string): Boolean;
var
C: Integer;
begin
Result := False;
for C := 1 to Length(S) do
if not (((S[C] >= '0') and (S[C] <= '9')) or (S[C] = '.')) then
Exit;
Result := True;
end;

function DecodeSVGColorToInt(const S: string): Integer;
var
C: Integer;
Percent: Boolean;
ColorFloat: Extended;
Help: string;
LFormatSettings: TFormatSettings;
begin
Expand All @@ -126,13 +116,16 @@ function DecodeSVGColorToInt(const S: string): Integer;
if Percent then
C := Round(C * 2.55);
end
else if IsFloat(Help) then
else
begin
LFormatSettings.DecimalSeparator := '.';
if Percent then
C := Round(StrToFloat(Help, LFormatSettings)*2.55)
else
C := Round(StrToFloat(Help, LFormatSettings));
If TryStrToFloat(Help, ColorFloat, LFormatSettings) then
begin
if Percent then
C := Round(ColorFloat * 2.55)
else
C := Round(ColorFloat);
end;
end;
if C = SVG_INHERIT_COLOR then
Exit;
Expand Down

0 comments on commit abde8aa

Please sign in to comment.