{繪制橢圓; 橢圓的參數和矩形是一樣的}procedure TForm1.Button1Click(Sender: TObject);
begin
btn := TButton(Sender);
Canvas.Ellipse(btn.Left, y1, btn.Left+btn.Width, y2);
end;
{根據矩形結構繪制橢圓}procedure TForm1.Button2Click(Sender: TObject);
var
R: TRect; {定義一個矩形結構}
begin
btn := TButton(Sender);
R := Rect(btn.Left, y1, btn.Left+btn.Width, y2);
Canvas.Ellipse(R);
end;
{繪制扇形}procedure TForm1.Button3Click(Sender: TObject);
begin
btn := TButton(Sender);
Canvas.PIE(
btn.Left, y1, {矩形區域左上角}
btn.Left + btn.Width, y2, {矩形區域右下角}
btn.Left + btn.Width, y1 + (y2-y1) div 2, {扇形起點}
btn.Left + btn.Width div 2, y1 {扇形終點}
);
end;
{繪制弦, 參數同上}procedure TForm1.Button4Click(Sender: TObject);
begin
btn := TButton(Sender);
Canvas.Chord(
btn.Left, y1,
btn.Left + btn.Width, y2,
btn.Left + btn.Width, y1 + (y2-y1) div 2,
btn.Left + btn.Width div 2, y1
);
end;
{繪制弧線, 參數同上}procedure TForm1.Button5Click(Sender: TObject);
begin
btn := TButton(Sender);
Canvas.Arc(
btn.Left, y1,
btn.Left + btn.Width, y2,
btn.Left + btn.Width, y1 + (y2-y1) div 2,
btn.Left + btn.Width div 2, y1
);
end;
end.
//效果圖: