我尝试创建具有自定义可视化效果的表单,但是我无法使用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;
我想念什么?
答案 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;