The geometric transformation is the matrix transformation, and the matrix of the brush ignores the dx and dy translation parameters. Choose Linecapround Line cap effect is better.
This example effect chart:
Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Comctrls, Stdctrls, Extctrls;
Type
TForm1 = Class (Tform)
Panel1:tpanel;
Button1:tbutton;
Trackbar1:ttrackbar;
Trackbar2:ttrackbar;
Trackbar3:ttrackbar;
Trackbar4:ttrackbar;
Procedure Formcreate (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Trackbar1change (Sender:tobject);
Procedure Trackbar2change (Sender:tobject);
Procedure Trackbar3change (Sender:tobject);
Procedure Trackbar4change (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Procedure Tform1.formcreate (Sender:tobject);
Const
n = 40;
Begin
Trackbar1.min: =-N;
Trackbar1.max: = n;
Trackbar2.min: =-N;
Trackbar2.max: = n;
Trackbar3.min: =-N;
Trackbar3.max: = n;
Trackbar4.min: =-N;
Trackbar4.max: = n;
Trackbar1.position: = 10;
Trackbar2.position: = 0;
Trackbar3.position: = 0;
Trackbar4.position: = 10;
Button1.onclick: = formcreate;
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
B:tgpbrush;
P:tgppen;
Matrix:tgpmatrix;
M11, M12, M21, M22:single;
Begin
G: = Tgpgraphics.create (Canvas.handle);
B: = Tgphatchbrush.create (Hatchstylelargegrid, Aclforestgreen);
P: = tgppen.create (b, 16);
M11: = TRACKBAR1.POSITION/10;
M12: = TRACKBAR2.POSITION/10;
M21: = TRACKBAR3.POSITION/10;
M22: = TRACKBAR4.POSITION/10;
Matrix: = Tgpmatrix.create (M11, M12, M21, M22, 0, 0);
P.settransform (matrix);
P.setstartcap (Linecapround);
P.setendcap (Linecapround);
G.drawline (P, A, clientwidth-panel1.width-30, ClientHeight-30);
Matrix. Free;
B.free;
P.free;
G.free;
End
Procedure Tform1.trackbar1change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar2change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar3change (Sender:tobject);
Begin
Repaint;
End
Procedure Tform1.trackbar4change (Sender:tobject);
Begin
Repaint;
End
End.