From fa2faaf8d7f69ac3d764808904eea96056090013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20C=C3=B4t=C3=A9?= Date: Thu, 28 Nov 2019 19:52:54 -0500 Subject: [PATCH] Check if the intersection is less than a pixel high or wide If the intersection is less than a pixel high or wide, `getImageData()` will (rightfully) throw the following error: ```Uncaught DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The source height is 0.``` I guess `getImageData()` does an implicit `Math.floor()` on the `width` and `height` parameters to make sure there is actual data to return. --- src/ndgmr.Collision.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ndgmr.Collision.js b/src/ndgmr.Collision.js index ae064eb..4bfe097 100644 --- a/src/ndgmr.Collision.js +++ b/src/ndgmr.Collision.js @@ -73,7 +73,7 @@ this.ndgmr = this.ndgmr || {}; //} intersection = checkRectCollision(bitmap1,bitmap2); - if ( !intersection ) { + if ( !intersection || intersection.width < 1 || intersection.height < 1) { return false; }