棘手的问题,TextOut输出字符的定位,在线等 (200分)

  • 主题发起人 主题发起人 myevin
  • 开始时间 开始时间
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;
 
先计算
img.Canvas.TextWidth(inttostr(i*10)+'°');
再调整x1
 
同意skadon
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
707
import
I
后退
顶部