demos/Collage/fabric.js
function (e, target) {
      var pointer = this.getPointer(e),
          xy = this._normalizePointer(target, pointer),
          x = xy.x,
          y = xy.y;

      // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html
      // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html

      // we iterate through each object. If target found, return it.
      var iLines = target._getImageLines(target.oCoords),
          xpoints = target._findCrossPoints(x, y, iLines);

      // if xcount is odd then we clicked inside the object
      // For the specific case of square images xcount === 1 in all true cases
      if ((xpoints && xpoints % 2 === 1) || target._findTargetCorner(e, this._offset)) {
        return true;
      }
      return false;
    }
function (e, target) {
      var pointer = this.getPointer(e),
          xy = this._normalizePointer(target, pointer),
          x = xy.x,
          y = xy.y;

      // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html
      // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html

      // we iterate through each object. If target found, return it.
      var iLines = target._getImageLines(target.oCoords),
          xpoints = target._findCrossPoints(x, y, iLines);

      // if xcount is odd then we clicked inside the object
      // For the specific case of square images xcount === 1 in all true cases
      if ((xpoints && xpoints % 2 === 1) || target._findTargetCorner(e, this._offset)) {
        return true;
      }
      return false;
    }
function ( e , target ) { var pointer = this . getPointer ( e ) , xy = this . _normalizePointer ( target , pointer ) , x = xy . x , y = xy . y ; // http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u32.html // http://idav.ucdavis.edu/~okreylos/TAship/Spring2000/PointInPolygon.html // we iterate through each object. If target found, return it. var iLines = target . _getImageLines ( target . oCoords ) , xpoints = target . _findCrossPoints ( x , y , iLines ) ; // if xcount is odd then we clicked inside the object // For the specific case of square images xcount === 1 in all true cases if ( ( xpoints && xpoints % 2 === 1 ) || target . _findTargetCorner ( e , this . _offset ) ) { return true ; } return false ; }
Applies one implementation of 'point inside polygon' algorithm
@method containsPoint
@param e { Event } event object
@param target { fabric.Object } object to test against
@return {Boolean} true if point contains within area of given object
Applies one implementation of point inside polygon algorithm