我正在用FireMonkey和Delphi制作简单的绘图应用程序。它真正要做的只是画线和椭圆。这是代码:
Image1.Bitmap.Canvas.BeginScene;
with Form1 do begin
for i := 0 to 360 do
if (i mod 15)=0 then
begin
p1 := TPointF.Create(PX, PY);
p2 := TPointF.Create(Round(PX+200*sin(i*pi/180)), Round(PY+200*cos(i*pi/180)));
Image1.Bitmap.Canvas.DrawLine(p1, p2, 100);
end;
for i := 0 to 200 do
if (i mod 20)=0 then
begin
prst1 := TRectF.Create(PX+i,PY+i,PX-i,PY-i);
Image1.Bitmap.Canvas.DrawEllipse(prst1, 100);
end;
Image1.Bitmap.Canvas.EndScene;
end;
当我在Win32或Win64下编译该代码时,它可以完美地工作。但是,当我尝试对其进行编译并在Android设备上运行时,仅显示行,并且省略了省略号。有谁知道为什么会这样?
提前感谢您的帮助!
答案 0 :(得分:1)
您可以在Form.Canvas
事件处理程序中使用OnPaint
。这是一个示例:
procedure TForm1.FormPaint(Sender: TObject; Canvas: TCanvas;
const ARect: TRectF);
begin
with Canvas do begin
BeginUpdate;
try
Stroke.Kind := TBrushKind.Solid;
Stroke.Thickness := 2.0;
DrawEllipse(ARect,1);
DrawLine(PointF(ARect.Left,ARect.Height / 2), PointF(ARect.right,ARect.Height / 2), 1);
DrawLine(PointF(ARect.Left+(ARect.Width / 2),ARect.Height), PointF(ARect.Left+(ARect.Width / 2),0), 1);
finally
EndUpdate;
end;
end;
end;