This function will check, how many percent of a given (check) polygon are inside the given source polygon (ie. how much of the check polygon its surface does overlap with the source polygon its surface). Optionally it may also draw the checked polygon with given inside/outside colors respectivly. Also optionally it may draw a borderline surrounding the shape of the checked polygon. This function is a combination of the FillPolygon() subroutine and the PointInPolygon() function.
SYNTAX:
percent% = PolygonInPolygon% (chkPolyX%(), chkPolyY%(), srcPolyX%(), srcPolyY%(), ic&&, oc&&, sc&&)
INPUTS:
chkPolyX%(), chkPolyY%() (INTEGER arrays)
- These are 1-dimensional arrays containing the x/y coordinates of the corners of the polygon to check. Start with the first corner in the lowest array index, end with last corner in the highest index, ie. you must not return to the first corner. Obviously the arrays must match and must have exactly "number of corners" elements. The corners may be traced in either direction (clockwise or counter-clockwise).
srcPolyX%(), srcPolyY%() (INTEGER arrays)
- These are 1-dimensional arrays containing the x/y coordinates of the source polygon's corners. Start with the first corner in the lowest array index, end with last corner in the highest index, ie. you must not return to the first corner. Obviously the arrays must match and must have exactly "number of corners" elements. The corners may be traced in either direction (clockwise or counter-clockwise).
ic&&, oc&& (_INTEGER64s)
- Optional the inside/outside color numbers for drawing on a palette based screen, or the _RGB32/_RGBA32 color value on 32-bit screens. Any negative number will disable drawing for the respective case(s), hence make sure your 32-bit colors are defined as unsigned values.
sc&& (_INTEGER64)
- Optional the surrounding borderline color number for drawing on a palette based screen, or the _RGB32/_RGBA32 color value on 32-bit screens. Any negative number will disable drawing of the border, hence make sure your 32-bit colors are defined as unsigned values.
RESULT:
percent% (INTEGER)
- The percentage how much the given polygons do overlap:
- 0% -- The checked polygon is entirely outside of the given source polygon.
- 1-99% -- That many percent of the checked polygon are inside the given source polygon, hence overlapping.
- 100% -- The checked polygon is entirely inside the source polygon.