Learn more about GDI + [52]: Path-reverse, reset

Source: Internet
Author: User
In this example:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) checkbox1: tcheckbox; checkbox2: tcheckbox; procedure alert (Sender: tobject); Procedure checkbox1click (Sender: tobject); Procedure checkbox2click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses gdipobj, gdipapi; var PTS: array [0 .. 6] of tgppoint; Procedure tform1.formcreate (Sender: tobject); begin PTS [0]. x: = 10; PTS [0]. y: = 50; PTS [1]. x: = 40; PTS [1]. y: = 90; PTS [2]. x: = 80; PTS [2]. y: = 10; PTS [3]. x: = 110; PTS [3]. y: = 50; PTS [4]. x: = 140; PTS [4]. y: = 10; PTS [5]. x: = 180; PTS [5]. y: = 90; PTS [6]. x: = 210; PTS [6]. y: = 50; checkbox1.caption: = 'point in the flipped path'; checkbox2.caption: = 'clear vertex in the path'; end; Procedure tform1.formpaint (Sender: tobject); var G: tgpgraphics; p: tgppen; Path: tgpgraphicspath; pathpts: array of tgppoint; I: integer; begin G: = tgpgraphics. create (canvas. handle); P: = tgppen. create (aclred, 2); Path: = tgpgraphicspath. create; Path. addbeziers (pgppoint (@ PTS), length (PTS); If checkbox1.checked then path. reverse; If checkbox2.checked then path. when reset; {reset, The pathpoints and pathtypes arrays are cleared and the fillmode is set to fillmodealternate} setlength (pathpts, path. getpointcount); Path. getpathpoints (pgppoint (pathpts), length (pathpts); canvas. pen. color: = clgray; for I: = low (pathpts) to high (pathpts) Do canvas. textout (pathpts [I]. x, pathpts [I]. y, inttostr (I + 1); G. drawpath (p, PATH); Path. free; p. free; G. free; end; Procedure tform1.checkbox1click (Sender: tobject); begin repaint; end; Procedure tform1.checkbox2click (Sender: tobject); begin repaint; end.
 
   
 

Form file:

 
Object form1: tform1 left = 0 Top = 0 caption = 'form1' clientheight = 156 clientwidth = 232 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 checkbox1: tcheckbox left = 12 Top = 126 width = 113 Height = 17 caption = 'checkbox1' taborder = 0 onclick = checkbox1click end object checkbox2: tcheckbox left = 123 Top = 126 width = 106 Height = 17 caption = 'checkbox2 'taborder = 1 onclick = checkbox2click 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.