【发布时间】:2020-08-08 05:36:51
【问题描述】:
我有一个用于绘制样条曲线的组件,它是 TPoint 数组中 Spline 过程的参数。 现在,我想创建 n 个 TPoint 的动态数组,将其保存在 TList 中,并在调用后绘制样条线。
附:德尔福XE5
例子:
var
l: TList;
procedure CreateSpline;
var i, x: byte;
p: TPoint;
a: array of TPoint;
begin
l := TList.Create;
for x := 0 to 9 do // create 10 splines
begin
SetLength(a, Random(10) + 5); Each spline has 5<n<15 points
for i := 0 to High(a) do
begin
p.X := Random(200) - 100; // X coord
p.Y := Random(200) - 100; // Y coord
a[i] := p; // add point to array
end;
l.Add(a); // add array to TList
end;
end;
procedure DrawSpline;
var i: byte;
a: array of TPoint;
begin
for i := 0 to 9 do
begin
a := l[i];
xyPlot.Spline(a); // Draw the spline (xyPlot is the graphic component)
end;
end;
... 并且不工作。 :-(
【问题讨论】:
-
你应该使用
TList<TArray<TPoint>>而不是TList(使用Generics.Collections)。 -
谢谢,现在可以了。
标签: delphi