Gdiplus [41]: igpregion Region

Source: Internet
Author: User
// Create a region: tgpregion. create (); {the parameter can be a rectangle, path, hrgn, or region data, or no parameter} tgpregion. fromhrgn (); {initialize from hrgn} // calculate the region (rectangle, path, or another region): igpregion. intersect (); {intersection} igpregion. union (); {Union} igpregion. exclude (); {minus} igpregion. exclusiveor (); {minus intersection} igpregion. complement (); {non-intersection} // others: igpregion. isvisible (); {judge whether the specified vertex or rectangle is in the region} igpregion. getdata; {obtain region data (igpbuffer), which contains data pointer and data size} igpregion. getregionscans (); {Get the rectangle array from the region, float type} igpregion. getregionscansi (); {Get a rectangle array from the region, integer} igpregion. translate (); {offset} igpregion. transform (); {matrix transformation} igpregion. makeinfinite; {initialized to infinitely large} igpregion. makeempty; {Initialization is empty} igpregion. isempty (); {determines whether the region is empty} igpregion. isinfinite (); {determines whether the region is infinitely large} igpregion. getbounds (); {Get boundary rectangle} igpregion. gethrgn (); {obtain hrgn (Windows region handle)} igpregion. clone; {copy} igpregion. equals (); {judge whether it is the same}

  

Two important uses of a region:

1. igpregion. isvisible ();

2. igpgraphics. Clip or igpgraphics. setclip ();

Isvisible test:


Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formcreate (Sender: tobject ); procedure formpaint (Sender: tobject); Procedure formmousemove (Sender: tobject; shift: tshiftstate; X, Y: integer); end; var form1: tform1; implementation {$ R *. DFM} uses gdiplus, gdiplushelpers; Var region: igpregion; Procedure tform1.formcreate (Sender: tobject); var rect: tgprect; Path: igpgraphicspath; begin rect. initialize (clientrect); rect. inflate (-20,-20); region: = tgpregion. create (rect); rect. inflate (-2,-2); Path: = tgpgraphicspath. create (); Path. addellipse (rect); region. exclude (PATH); end; Procedure tform1.formpaint (Sender: tobject); var brush: igphatchbrush; begin brush: = tgphatchbrush. create (hatchstylemin, tgpcolor. silver, tgpcolor. red); canvas. togpgraphics. fillregion (brush, region); end; Procedure tform1.formmousemove (Sender: tobject; shift: tshiftstate; X, Y: integer); begin text: = 'form1 '; If region. isvisible (x, y) then text: = 'in the region'; end.
 
   
 

Cut area test:


 
Uses gdiplus; Procedure tform1.formpaint (Sender: tobject); const PTS: array [0 .. 3] of tgppoint = (X: 10; Y: 10), (X: 150; Y: 10), (X: 100; Y: 75), (X: 100; Y: 150); var graphics: igpgraphics; Path: igpgraphicspath; region: igpregion; pen: igppen; Font: igpfont; brush: igpbrush; begin graphics: = tgpgraphics. create (handle); Path: = tgpgraphicspath. create; Path. addpolygon (PTS); region: = tgpregion. create (PATH); pen: = tgppen. create ($ ff000000); graphics. drawpath (pen, PATH); graphics. clip: = region; // graphics. setclip (region); // or such Font: = tgpfont. create ('arial', 36, [fontstylebold], unitpixel); brush: = tgpsolidbrush. create ($ ffff0000); graphics. drawstring ('a Clipping Region ', Font, tgppointf. create (15, 25), brush); graphics. drawstring ('a Clipping Region ', Font, tgppointf. create (15, 68), brush); 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.