• 发表于 3年前
• 阅读 9
• 收藏 0
• 评论 0

``````procedure TForm1.FormPaint(Sender: TObject);
var
i,j,num,X,Y: Integer;
begin
num := 60;
X := 300;
Y := 300;
ClientWidth := 2 * X;
ClientHeight := 2 * Y;

Canvas.Pen.Width := 1;
Canvas.Pen.Color := clWhite;
Canvas.Brush.Color := clNavy;
Canvas.FillRect(ClientRect);

for i := 0 to num do for j := 0 to 1 do
begin
Canvas.MoveTo(X, i*10);
if i < 30 then
if j = 0 then Canvas.LineTo(X-i*10, Y) else Canvas.LineTo(X+i*10, Y)
else
if j = 0 then Canvas.LineTo(X-(num-1-i)*10, Y) else Canvas.LineTo(X+(num-1-i)*10, Y);
end;
end;

``````

``````procedure TForm1.FormPaint(Sender: TObject);
var
i,j,num,n,X,Y: Integer;
angle: Single;
pts: array of array of TPoint;
begin
num := 20;
n := 6; { 改为 n := 11 就是成了下一个图形 }
angle := -2 * PI / n;
X := 210;
Y := 210;
ClientWidth := 2*X;
ClientHeight := 2*Y;

Canvas.Pen.Width := 1;
Canvas.Pen.Color := clWhite;
Canvas.Brush.Color := clNavy;
Canvas.FillRect(ClientRect);

SetLength(pts, n+1, num);
for i := 0 to n do
begin
for j := 0 to num-1 do
begin
pts[i,j] := Point(Trunc(j*10*Cos(angle*i)+X), Trunc(j*10*Sin(angle*i)+Y));
Canvas.MoveTo(pts[i,j].X, pts[i,j].Y);
if i = 0 then
Canvas.LineTo((num-j)*10+X, Y)
else
Canvas.LineTo(pts[i-1, num-1-j].X, pts[i-1, num-1-j].Y);
end;
end;
end;

``````

×