contains(x, y)
    {
        let inside = false;

        // use some raycasting to test hits
        // https://github.com/substack/point-in-polygon/blob/master/index.js
        const length = this.points.length / 2;

        for (let i = 0, j = length - 1; i < length; j = i++)
        {
            const xi = this.points[i * 2];
            const yi = this.points[(i * 2) + 1];
            const xj = this.points[j * 2];
            const yj = this.points[(j * 2) + 1];

            const intersect = ((yi > y) !== (yj > y))
                && (x < (((xj - xi) * (y - yi)) / (yj - yi)) + xi);

            if (intersect)
            {
                inside = !inside;
            }
        }

        return inside;
    }
/**
     * Checks whether the x and y coordinates passed to this function are contained within this polygon
     *
     * @param {number} x - The X coordinate of the point to test
     * @param {number} y - The Y coordinate of the point to test
     * @return {boolean} Whether the x/y coordinates are within this polygon
     */
Checks whether the x and y coordinates passed to this function are contained within this polygon
@param {number} x - The X coordinate of the point to test
@param {number} y - The Y coordinate of the point to test
@return {boolean} Whether the x/y coordinates are within this polygon
Checks whether the x and y coordinates passed to this function are contained within this polygon @param { number } x - The X coordinate of the point to test @param { number } y - The Y coordinate of the point to test @return { boolean } Whether the x / y coordinates are within this polygon
contains(x, y)
    {
        let inside = false;
        const length = this.points.length / 2;
        for (let i = 0, j = length - 1; i < length; j = i++)
        {
            const xi = this.points[i * 2];
            const yi = this.points[(i * 2) + 1];
            const xj = this.points[j * 2];
            const yj = this.points[(j * 2) + 1];
            const intersect = ((yi > y) !== (yj > y))
                && (x < (((xj - xi) * (y - yi)) / (yj - yi)) + xi);
            if (intersect)
            {
                inside = !inside;
            }
        }
        return inside;
    }
contains ( x , y ) { let inside = false ; const length = this . points . length / 2 ; for ( let i = 0 , j = length - 1 ; i < length ; j = i ++ ) { const xi = this . points [ i * 2 ] ; const yi = this . points [ ( i * 2 ) + 1 ] ; const xj = this . points [ j * 2 ] ; const yj = this . points [ ( j * 2 ) + 1 ] ; const intersect = ( ( yi > y ) !== ( yj > y ) ) && ( x < ( ( ( xj - xi ) * ( y - yi ) ) / ( yj - yi ) ) + xi ) ; if ( intersect ) { inside = ! inside ; } } return inside ; }
Checks whether the x and y coordinates passed to this function are contained within this polygon
 @param {number} x - The X coordinate of the point to test
 @param {number} y - The Y coordinate of the point to test
 @return {boolean} Whether the x/y coordinates are within this polygon
Checks whether the x and y coordinates passed to this function are contained within this polygon @param { number } x - The X coordinate of the point to test @param { number } y - The Y coordinate of the point to test @return { boolean } Whether the x / y coordinates are within this polygon
// use some raycasting to test hits // https://github.com/substack/point-in-polygon/blob/master/index.js