画圆 ( 积分: 20 )

  • 主题发起人 主题发起人 无有人
  • 开始时间 开始时间

无有人

Unregistered / Unconfirmed
GUEST, unregistred user!
在Delphi中,可以通过指定圆心坐标和半径来画圆吗?若可以,具体怎么做?
 
在Delphi中,可以通过指定圆心坐标和半径来画圆吗?若可以,具体怎么做?
 
Draws the ellipse defined by a bounding rectangle on the canvas.

procedure Ellipse(X1, Y1, X2, Y2: Integer); overload;
procedure Ellipse(const Rect: TRect); overload;

Description

Call Ellipse to draw a circle or ellipse on the canvas. Specify the bounding rectangle either by giving

The top left point at pixel coordinates (X1, Y1) and the bottom right point at (X2, Y2).
A TRect value.

If the bounding rectangle is a square, a circle is drawn.

The ellipse is outlined using the value of Pen, and filled using the value of Brush.

将指定的圆心和半径换算成两个坐标就行了。
 
procedure TForm1.Button1Click(Sender: TObject);
begin
Ellipse(Form1.Canvas.Handle, 0, 0, 100, 100);
end;
这个表示在 (0,0), (0,100), (100, 100), (100,0) 这四个点组成的正方型内画一个最大的圆
圆心在 (50,50) 半径为 50
 
可以用元的参数方程的方式画
r--半径
a,b--中心坐标
递增alpha
x:=a+round(r*sin(alpha))
y:=b+round(r*cos(alpha))
canvas.lineto(x,y);
 
[^][^]方法很多了!可以利用方程去画呵呵,不过稍稍复杂一些,得分呈四个扇形画
[:D]x*x+y*y=r*r,就是利用这个方程转换!
 
最好的方法 自己选一个大家说得这些方法写一个画圆的类[^][:D]随时用很方便!哈
 
多人接受答案了。
 
后退
顶部