Setting the Line End Styles for Canvas.LineTo

前端 未结 2 1063
一生所求
一生所求 2021-01-13 09:16

Is there any way to set the style for the lineends for the TCanvas.LineTo method? It seems to default to rounded ends, which looks very bad for several lines in a row of dif

相关标签:
2条回答
  • 2021-01-13 09:55

    Maybe ExtCreatePen helps. Check the PS_ENDCAP_* and PS_JOIN_* flags.

    0 讨论(0)
  • 2021-01-13 10:07

    Sample code from DelphiPraxis forum (German language)

    procedure TForm1.FormCreate(Sender: TObject);
       var LogBrush:TLOGBRUSH;
    begin
       ZeroMemory(@LogBrush, SizeOf(LogBrush));
       LogBrush.lbColor:=ColorToRGB(Canvas.Pen.Color);
       LogBrush.lbHatch:=0;
    
       DeleteObject(Canvas.Pen.Handle);
       Canvas.Pen.Handle:=ExtCreatePen(PS_Geometric or PS_Solid or PS_EndCap_Square or PS_Join_Miter, 10, LogBrush, 0, nil);
    end;
    
    procedure TForm1.FormPaint(Sender: TObject);
    begin
       Canvas.MoveTo(0, 0);
       Canvas.LineTo(50, 50);
    end; 
    
    0 讨论(0)
提交回复
热议问题