FMX.Graphics.TCanvas.DrawEllipse 不适用于 Android
FMX.Graphics.TCanvas.DrawEllipse doesn't work on Android
我正在使用 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 设备上编译它并 运行 时,只显示线条,并且缺少省略号。有谁知道为什么会这样?
提前感谢您的帮助!
您可以在 OnPaint
事件处理程序中利用 Form.Canvas
。这是一个例子:
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;
我正在使用 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 设备上编译它并 运行 时,只显示线条,并且缺少省略号。有谁知道为什么会这样?
提前感谢您的帮助!
您可以在 OnPaint
事件处理程序中利用 Form.Canvas
。这是一个例子:
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;