Math&graphic

Please discuss general Delphi programming topics here.

Math&graphic

Postby hani » April 30th, 2006, 6:41 am

Hi,
How i can know if point is inside polygon or not




Thanks
hani
Active Member
Active Member
 
Posts: 17
Joined: October 17th, 2005, 9:15 am

Postby Kambiz » April 30th, 2006, 10:23 am

Code: Select all
function PtInPolygon(const Polygon: array of TPoint; const Pt: TPoint): Boolean;
var
  Rgn: HRGN;
begin
  Rgn := CreatePolygonRgn(Polygon, Length(Polygon), WINDING);
  try
    Result := PtInRegion(Rgn, Pt.X, Pt.Y);
  finally
    DeleteObject(Rgn);
  end;
end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby kokkoras » April 30th, 2006, 11:22 pm

Is PtInRegion a win API call?
Fotis
User avatar
kokkoras
Moderator
Moderator
 
Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Postby HPW » May 1st, 2006, 7:30 am

Yes, from the delphi windows SDK help:

Code: Select all
BOOL PtInRegion(

    HRGN hrgn,   // handle of region
    int X,   // x-coordinate of point 
    int Y    // y-coordinate of point 
   );   
 
Hans-Peter
HPW
Moderator
Moderator
 
Posts: 238
Joined: February 25th, 2006, 10:19 am
Location: Germany


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron