Learn more about GDI + [33]: tgppen-geometric transformation of the paint brush-settransform

Source: Internet
Author: User
Ry transformation is matrix transformation. The matrix of the paint brush ignores Dx and Dy translation parameters. It is better to select linecapround.
In this example:


Code File:
Unit unit1; interfaceuses 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 upload (Sender: tobject ); procedure future (Sender: tobject); Procedure trackbar2change (Sender: tobject); Procedure trackbar3change (Sender: tobject); Procedure future (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; Procedure plugin (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, 30, 30, clientwidth-panel1.width-30, clientheight-30); matrix. free; B. free; p. free; G. free; end; Procedure tform1.trackbar1change (Sender: tobject); begin repaint; end; Procedure prepare (Sender: tobject); begin repaint; end; Procedure tform1.trackbar3change (Sender: tobject ); begin repaint; end; Procedure tform1.trackbar4change (Sender: tobject); begin repaint; end.
 
   
 

Form file:

Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 184 clientwidth = 327 color = clbtnface font. charset = default_charset font. color = clwindowtext font. height =-11 font. name = 'tahoma 'font. style = [] oldcreateorder = false position = pow.topcenter oncreate = formcreate onpaint = formpaint pixelsperinch = 96 textheight = 13 object Panel1: tpanel left = 228 Top = 0 width = 99 Height = 184 align = alright taborder = 0 explicitleft = 225 explicitheight = 170 object button1: tbutton left = 14 top = 8 width = 75 Height = 25 caption = #21021 #22987 #21270 taborder = 0 end object trackbar1: ttrackbar left = 0 Top = 39 width = 100 Height = 20 showselrange = false taborder = 1 onchange = trackbar1change end object trackbar2: ttrackbar left = 0 Top = 72 width = 100 Height = 20 showselrange = false taborder = 2 onchange = trackbar2change end object trackbar3: ttrackbar left = 0 Top = 106 width = 100 Height = 20 showselrange = false taborder = 3 onchange = trackbar3change end object trackbar4: ttrackbar left = 0 Top = 140 width = 100 Height = 20 showselrange = false taborder = 4 onchange = trackbar4change end endend
 
  
 

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.