Re-learning gdi+[51]: path

Source: Internet
Author: User

This example effect chart:

Code files:Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs;
Type
TForm1 = Class (Tform)
Procedure Formcreate (Sender:tobject);
Procedure Formdestroy (Sender:tobject);
Procedure Formpaint (Sender:tobject);
Procedure Formmousemove (Sender:tobject; Shift:tshiftstate; X, Y:integer);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Gdipobj, GDIPAPI;
Var
Path1,path2,path3:tgpgraphicspath;
P:tgppen;
Procedure Tform1.formcreate (Sender:tobject);
Var
R:trect;
Begin
path1: = tgpgraphicspath.create;
path2: = tgpgraphicspath.create;
Path3: = tgpgraphicspath.create;
P: = Tgppen.create (aclred, 3);
Path1. AddLine (0, 0, clientwidth, clientheight);
r: = Clientrect;
Inflaterect (R,-clientwidth Div 3,-clientheight Div 3);
Offsetrect (R,-trunc (r.right-r.left) * 0.6),-trunc ((r.bottom-r.top) * 0.6));
Path2. AddRectangle (Makerect (R));
Offsetrect (R, R.right-r.left, R.bottom-r.top);
Path3. AddEllipse (Makerect (R));
End
Procedure Tform1.formdestroy (Sender:tobject);
Begin
Path1. Free;
Path2. Free;
Path3. Free;
P.free;
End
Procedure Tform1.formpaint (Sender:tobject);
Var
G:tgpgraphics;
Begin
G: = Tgpgraphics.create (Canvas.handle);
G.drawpath (P, path1);
G.drawpath (P, path2);
G.drawpath (P, path3);
G.free;
End
Procedure Tform1.formmousemove (Sender:tobject; Shift:tshiftstate; X
Y:integer);
Begin
Text: = ';
If path1. IsVisible (Makepoint (x,y)) then Text: = ' within path1 ';
If path2. IsVisible (Makepoint (x,y)) then Text: = ' within the rectangle ';
If Path3. IsVisible (Makepoint (x,y)) then Text: = ' in Ellipse ';
If path1. Isoutlinevisible (X, Y, p) then Text: = ' on line ';
If path2. Isoutlinevisible (X, Y, p) then Text: = ' on the edge of the rectangle ';
If Path3. Isoutlinevisible (X, Y, p) then Text: = ' on the circular line of the ellipse ';
End
End.

Form file:object Form1: TForm1
 Left = 0
 Top = 0
 Caption = 'Form1'
 ClientHeight = 206
 ClientWidth = 339
 Color = clBtnFace
 Font.Charset = DEFAULT_CHARSET
 Font.Color = clWindowText
 Font.Height = -11
 Font.Name = 'Tahoma'
 Font.Style = []
 OldCreateOrder = False
 Position = poDesktopCenter
 OnCreate = FormCreate
 OnDestroy = FormDestroy
 OnMouseMove = FormMouseMove
 OnPaint = FormPaint
 PixelsPerInch = 96
 TextHeight = 13
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.