From 72e37d7e83692074fa9d5ad00b2e7c660f78c060 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 23 Oct 2005 17:41:57 +0000 Subject: Added IsInside() --- vectorgfx.mod/vectorgfx.bmx | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/vectorgfx.mod/vectorgfx.bmx b/vectorgfx.mod/vectorgfx.bmx index 57df6ee..fbf5064 100644 --- a/vectorgfx.mod/vectorgfx.bmx +++ b/vectorgfx.mod/vectorgfx.bmx @@ -324,11 +324,35 @@ Type TVectorGfxObject Next End Method + Rem + bbdoc: Whether a point is inside the object + returns: True if the point lies inside the object. The object is assumed to be a closed polygon for this test. + about: @cx, @cy is the point to test. + about: Calling it before drawing the object will cause runtime errors. + about: This routine is based on code from comp.graphics.algorithms FAQ 2.03 + EndRem + Method IsInside:Int(cx:Int, cy:Int) + Local cross:Int=False + + For Local l:TVectorGfxLine=EachIn lines + Local x1:Int=x+rotated[l.i1].x + Local y1:Int=y+rotated[l.i1].y + Local x2:Int=x+rotated[l.i2].x + Local y2:Int=y+rotated[l.i2].y + + If ((((y1<=cy) And (cy