js/index.js
// returns the item that is hit, or null

returns the item that is hit, or null
returns the item that is hit or null
function hitTest(x, y) {
      var ret = null;
      _.each(_.orderBy(m.items, 'index', 'desc'), function (i) {
        if (!i.bounds) {
          if (!i.image){
            return;
          }
          var w = i.image.width;
          var h = i.image.height;
          if (x > i.x && y > i.y && x < i.x + w && y < i.y + h) {
            ret = i;
            return false;
          }
        } else {
          var localBounds = i.bounds.map(function(coords){
            return {x:coords.x + i.x, y:coords.y + i.y}
          });
          if( pip({x:x,y:y},localBounds) ){
            ret = i;
            return false;
          }
        }
      });
      return ret;
    }
function hitTest ( x , y ) { var ret = null ; _ . each ( _ . orderBy ( m . items , 'index' , 'desc' ) , function ( i ) { if ( ! i . bounds ) { if ( ! i . image ) { return ; } var w = i . image . width ; var h = i . image . height ; if ( x > i . x && y > i . y && x < i . x + w && y < i . y + h ) { ret = i ; return false ; } } else { var localBounds = i . bounds . map ( function ( coords ) { return { x : coords . x + i . x , y : coords . y + i . y } } ) ; if ( pip ( { x : x , y : y } , localBounds ) ) { ret = i ; return false ; } } } ) ; return ret ; }
returns the item that is hit, or null
returns the item that is hit or null
//iterate in reverse over the items
 //hit this item
 // have bounds
