M
myevin
Unregistered / Unconfirmed
GUEST, unregistred user!
我的程序中需要绘制一个极坐标系,在画角度的时候,字符的位置总是不定的跑到极坐标的里面来,不知哪位大侠知道如何准确的将定位定位到极坐标的边上。(我可不想用Lable,)
我的代码如下:
procedure TForm1.FormCreate(Sender: TObject);
var
i, r, base : integer;
x1, y1, x2, y2 : integer;
c : extended;
begin
base := 20;
r := 200;
// Draw Circle
img.Canvas.Ellipse(base, base, base+r*2, base+r*2);
// Draw Deg Line
img.Canvas.Brush.Style := bsClear;
x2 := base+r;
y2 := base+r;
for i := 0 to 35 do begin
c := DegtoRad(10*i);
x1 := base+r-Trunc(r*cos(c));
y1 := base+r-Trunc(r*sin(c));
img.Canvas.MoveTo(x1, y1);
img.Canvas.LineTo(x2, y2);
// Draw Text
img.Canvas.TextOut(x1, y1, inttostr(i*10)+'°');
end;
end;
我的代码如下:
procedure TForm1.FormCreate(Sender: TObject);
var
i, r, base : integer;
x1, y1, x2, y2 : integer;
c : extended;
begin
base := 20;
r := 200;
// Draw Circle
img.Canvas.Ellipse(base, base, base+r*2, base+r*2);
// Draw Deg Line
img.Canvas.Brush.Style := bsClear;
x2 := base+r;
y2 := base+r;
for i := 0 to 35 do begin
c := DegtoRad(10*i);
x1 := base+r-Trunc(r*cos(c));
y1 := base+r-Trunc(r*sin(c));
img.Canvas.MoveTo(x1, y1);
img.Canvas.LineTo(x2, y2);
// Draw Text
img.Canvas.TextOut(x1, y1, inttostr(i*10)+'°');
end;
end;