From: "adub" Newsgroups: borland.public.delphi.graphics References: <3e233fbf@newsgroups.borland.com> Subject: Re: Polygon pixel testing Date: Mon, 13 Jan 2003 17:23:24 -0700 Lines: 36 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 NNTP-Posting-Host: 162.42.85.46 Message-ID: <3e235630$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1042503216 162.42.85.46 (13 Jan 2003 16:13:36 -0800) Path: newsgroups.borland.com!not-for-mail Xref: newsgroups.borland.com borland.public.delphi.graphics:54903 function PtInPolygon( const pt : TPoint; points : array of TPoint; NumPts : integer): boolean; var Region : HRGN; begin Result:=false; Region := CreatePolygonRgn(Points, NumPts, Alternate); if PtInRegion( region, pt.x, pt.y ) then result:=true; DeleteObject( region ); end; "Jon Lennart Berg" <64pixels@tiscali.no> wrote in message news:3e233fbf@newsgroups.borland.com... > Hi! > > Is there any quick way to test if a coordinate is within the range of a > polygon shape? > > for example, let's say i have a polygon with 8 or more points that describe > a shape, how is it possible for me to check if a pixel is inside the bounds > of that shape? > > I seem to remember there was an API method that did this, but is it > compatible with the DrawPolygon method of the Delphi canvas? > > Or do i have to render a mask? > Surely there must be a more clever way of doing this... > > Jon Lennart Berg