diff options
Diffstat (limited to 'lib/rect.coffee')
| -rw-r--r-- | lib/rect.coffee | 20 | 
1 files changed, 9 insertions, 11 deletions
| diff --git a/lib/rect.coffee b/lib/rect.coffee index d4807cc2..0e9c3417 100644 --- a/lib/rect.coffee +++ b/lib/rect.coffee @@ -67,12 +67,18 @@ Rect =      rects.filter (rect) -> rect.height > 0 and rect.width > 0 -  contains: (rect1, rect2) -> +  # Determine whether two rects overlap. +  intersects: (rect1, rect2) ->      rect1.right > rect2.left and      rect1.left < rect2.right and      rect1.bottom > rect2.top and      rect1.top < rect2.bottom +  # Determine whether two rects overlap, including 0-width intersections at borders. +  intersectsStrict: (rect1, rect2) -> +    rect1.right >= rect2.left and rect1.left <= rect2.right and +    rect1.bottom >= rect2.top and rect1.top <= rect2.bottom +    equals: (rect1, rect2) ->      for property in ["top", "bottom", "left", "right", "width", "height"]        return false if rect1[property] != rect2[property] @@ -82,14 +88,6 @@ Rect =      @create (Math.max rect1.left, rect2.left), (Math.max rect1.top, rect2.top),          (Math.min rect1.right, rect2.right), (Math.min rect1.bottom, rect2.bottom) -  # Determine whether two rects overlap. -  rectsOverlap: do -> -    halfOverlapChecker = (rect1, rect2) -> -      (rect1.left <= rect2.left <= rect1.right or rect1.left <= rect2.right <= rect1.right) and -        (rect1.top <= rect2.top <= rect1.bottom or rect1.top <= rect2.bottom <= rect1.bottom) - -    (rect1, rect2) -> -      halfOverlapChecker(rect1, rect2) or halfOverlapChecker rect2, rect1 - -root = exports ? window +root = exports ? (window.root ?= {})  root.Rect = Rect +extend window, root unless exports? | 
