1,183
社区成员
发帖
与我相关
我的任务
分享
Canvas.Ellipse(100, 200 ,300 ,250);
var
points : array [0.. 360] of TPoint;
i: Integer;
X, Y, A, B: Integer;
begin
X:= Self.Width div 2;
Y:= Self.Height div 2;
A:= 100;
B:= 40;
for i:= 0 to 360 do begin
points[i].X:= Round(A * Cos(PI / 180 * i)) + X;
points[i].Y:= Round(B * Sin(PI / 180 * i)) + Y;
end;
Canvas.Polyline(points);
end;
uses Math;
procedure TForm1.Button1Click(Sender: TObject);
var
points : array [0.. 360] of TPoint;
i,j: Integer;
X, Y, A, B: Integer;
xlen,ylen,len,angle:Extended;
begin
X:= Self.Width div 2;
Y:= Self.Height div 2;
A:= 100;
B:= 40;
j:=0;
while j<360 do
begin
for i:= 0 to 360 do begin
xlen:=A * Cos(PI / 180 * i);
ylen:=B * Sin(PI / 180 * i);
len:=sqrt(xlen*xlen+ylen*ylen);
angle:=ArcSin(ylen/len)+ PI / 180 * j;
xlen:=len*Cos(angle);
ylen:=len*Sin(angle);
points[i].X:= Round(xlen) + X;
points[i].Y:= Round(ylen) + Y;
end;
Canvas.Polyline(points);
inc(j,45);//旋转递增角度
end;
end;