Re-learning gdi+[33]: Tgppen

Source: Internet
Author: User
Tags min

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.