五边形例子如下:
procedure TForm1.Button1Click(Sender: TObject);
var
x,y,i,r:Integer;
Sidaouble;
p:Array of TPoint;
N:Integer;
AddSidaouble;
begin
N:=5; //5边形
AddSida:=18; //保持水平
SetLength(P,N);
r:=100; //外接圆半径
x:=100; y:=100;
for i:=0 to N-1 do begin
Sida:=(AddSida+(360/N)*i)*PI/180;
p.X:=Round(x+r*cos(sida));
p.Y:=Round(y-r*sin(sida));
end;
with canvas do begin
MoveTo(p[0].X,p[0].Y);
for i:=1 to N-1 do
LineTo(p.X,p.Y);
LineTo(p[0].X,p[0].Y);
end;
SetLength(P,0);
end;
不难改写成五角星或其它多边形和圆形.