使用此代码,我想绘制一个矩形:
procedure TForm1.Button1Click(Sender: TObject);
var rectangle:Trect;
begin
fx:=400;
fy:=400;
sc1:=base/fx;
sc2:=altezza/fy;
sc:=max(sc1, sc2);
lx:=fx*sc;
ly:=fy*sc;
xc:=base/2;
yc:=altezza/2;
x1:=xc-(lx/2); x2:=xc+(lx/2); y1:=yc-(ly/2); y2:=yc+(ly/2);
panel1.Repaint;
panel1.Canvas.Brush.color:= clblack;
panel1.Canvas.line((panel1.width div 2),0,(panel1.Width div 2), panel1.Height);
panel1.Canvas.line(0,(panel1.height div 2), panel1.Width,(panel1.Height div 2));
panel1.canvas.brush.style:=bsclear;
Rectangle:=rect(x1, y1, x2, y2);
end;
但是有一个问题,因为我只能使用整数值。
是否可以使用真实值来绘制矩形TCanvas
?