如何使用FireMonkey TCanvas.DrawXXX方法?

时间:2018-09-18 17:59:05

标签: delphi firemonkey

我尝试创建具有自定义可视化效果的表单,但是我无法使用TCanvas的最简单的绘制方法。在下面的示例中,我只能看到填充的矩形,但是看不到直线和弧线:

procedure TEditorPanel.FormPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
var
  center, radius: TPointF;
  rect: TRectF;
begin
  with Canvas do
  begin
    Fill.Color := TAlphaColors.White;
    FillRect(RectF(0, 0, Width, Height), 0, 0, AllCorners, 1);

    center := PointF(200, 200);
    radius := PointF(40, 40);

    Stroke.Color := TAlphaColors.Red;
    Fill.Color := TAlphaColors.Blue;
    DrawLine(center, radius, 1);
    DrawArc(center, radius, 0, 90, 1);

    rect := RectF(10, 10, 100, 100);
    FillRect(rect, 0, 0, AllCorners, 100);
  end;
end;

我想念什么?

1 个答案:

答案 0 :(得分:1)

如果您使用的是Delphi 10.1或更高版本,则应将Stroke.Kind设置为TBrushKind.Solid以显示行,默认值在None中:

var
  center, radius: TPointF;
  rect: TRectF;
begin
  with Canvas do
  begin
    Fill.Color := TAlphaColors.White;
    FillRect(RectF(0, 0, Width, Height), 0, 0, AllCorners, 1);

    center := PointF(200, 200);
    radius := PointF(40, 40);

    Stroke.Kind := TBrushKind.Solid;
    Stroke.Color := TAlphaColors.Red;
    Fill.Color := TAlphaColors.Blue;
    DrawLine(center, radius, 1);
    DrawArc(center, radius, 0, 90, 1);

    rect := RectF(10, 10, 100, 100);
    FillRect(rect, 0, 0, AllCorners, 100);
  end;