From 2c4a357e8f8e62fe50ab489519990e91e718c0d0 Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 23 Oct 2005 21:32:41 +0000 Subject: Changed handling of invalid calls --- vectorgfx.mod/vectorgfx.bmx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/vectorgfx.mod/vectorgfx.bmx b/vectorgfx.mod/vectorgfx.bmx index fbf5064..3da763a 100644 --- a/vectorgfx.mod/vectorgfx.bmx +++ b/vectorgfx.mod/vectorgfx.bmx @@ -328,10 +328,13 @@ Type TVectorGfxObject 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) + If rotated=Null + Return False + EndIf + Local cross:Int=False For Local l:TVectorGfxLine=EachIn lines @@ -352,9 +355,13 @@ Type TVectorGfxObject bbdoc: A line's adjusted co-ordinates. returns: The rotated and scaled points (in object co-ordinates) of the line. about: @i is the index of the line to return the points for. - about: Calling it before drawing the object will cause runtime errors. + about: Calling it before drawing the object will return null. EndRem Method AdjustedCoords:TVectorGfxPoint[](i:Int) + If rotated=Null + Return Null + EndIf + Local p:TVectorGfxPoint[]=New TVectorGfxPoint[2] Local l:TVectorGfxLine=lines[i] p[0]=rotated[l.i1] @@ -366,9 +373,13 @@ Type TVectorGfxObject bbdoc: A line's normal. returns: The normal of the selected line. about: @i is the index of the line to return the normal of. This will return the normal due to the rotation of the object after the object is drawn. - about: Calling it before drawing the object will cause runtime errors. + about: Calling it before drawing the object will return null. EndRem Method Normal:TVector(i:Int) + If rotated=Null + Return Null + EndIf + Local l:TVectorGfxLine=lines[i] Local v:TVector=TVector.Create(rotated[l.i2].y-rotated[l.i1].y,rotated[l.i1].x-rotated[l.i2].x) v.Normalise() -- cgit v1.2.3