Calculate uregular bounds of Drawpath

Here’s Ricks simplification of my code, but passing the variables as Points rather than Pairs. I gather from the documentation that Points (which have always worked in iOS framework) are now available in the desktop frameworks as of 2019r2. Note that the Subtract operator works with points so we can simplify the first for loop a bit

[code]Public Function PointInPoly(p as Point, xy() as Point) as Boolean

// Parameters:
// p - a Point with the x- and y-coordinates of point clicked
// xy - array of Points containing the x, y coordinates of vertices of the polygon.
// ----------
// Returns True if the point is inside of the polygon.

Var w As Double
Var pt(-1) as Point
Var mx,my,nx,ny As Boolean
Var i, j As Integer
Var inout As Integer = -1

For i = 0 to xy.LastRowIndex
pt.AddRow (xy(i) - p)
Next

For i=0 to xy.LastRowIndex

j = (i mod xy.LastRowIndex)+1

mx = pt(i).X >= 0.0
nx = pt(j).X >= 0.0
my = pt(i).Y >= 0.0
ny = pt(j).Y >= 0.0

If (my Or ny) And (mx Or nx) And (Not mx Or Not nx) Then

If my And ny And (mx Or nx) And (Not mx Or Not nx) Then
  
  inout=-inout
  
else
  
  w = ((pt(i).Y * pt(j).X - pt(i).X * pt(j).Y) / (pt(j).X - pt(i).X))
  
  If w > 0 Then
    
    inout=-inout
    
  ElseIf w = 0 then
    
    inout=0
    Exit
    
  End
  
End

End

Next

Return inout >= 0 // The edge of the polygon (0) counts as if it were inside the polygon (>0)

End Function[/code]