[Lazarus] Commment-2 about TAChart diff
Alexey
aaa5500 at ya.ru
Tue Jul 4 12:50:22 CEST 2017
+ else if (pos('#', AText) = 1) and (Length(AText) = 7) then begin
+ Delete(AText, 1, 1);
+ Result.Red := StrToInt('$' + copy(AText, 1, 2)) shl 8;
+ Result.Green := StrToInt('$' + copy(AText, 3, 2)) shl 8;
+ Result.Blue := StrToInt('$' + copy(AText, 5, 2)) shl 8;
+ end else
+
you convert #rrggbb, but don't convert #rgb (eg #123 means #112233).
example from ATSynEdit -
//allow only #rgb, #rrggbb
Len:= Length(s);
if (Len<>3) and (Len<>6) then exit;
for i:= 1 to Len do
if not IsCharHex(s[i]) then exit;
if Len=6 then
begin
N1:= StrToInt('$'+Copy(s, 1, 2));
N2:= StrToInt('$'+Copy(s, 3, 2));
N3:= StrToInt('$'+Copy(s, 5, 2));
end
else
begin
N1:= StrToInt('$'+s[1]+s[1]);
N2:= StrToInt('$'+s[2]+s[2]);
N3:= StrToInt('$'+s[3]+s[3]);
end;
Result:= RGBToColor(N1, N2, N3);
end;
my code also has checking for Hex, and yours dont have check for hex. so '#aazz33' will crash.
--
Regards,
Alexey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170704/f4be0356/attachment.html>
More information about the Lazarus
mailing list