From e8ba24a43e45ceb663380c81deb63c980ec4acfd Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Fri, 11 May 2018 14:04:03 -0400 Subject: [PATCH] Prevent errors when testing empty silhouettes --- src/Silhouette.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Silhouette.js b/src/Silhouette.js index ceef8ab..029fedb 100644 --- a/src/Silhouette.js +++ b/src/Silhouette.js @@ -79,6 +79,7 @@ class Silhouette { * @return {boolean} If the nearest pixel has an alpha value. */ isTouchingNearest (vec) { + if (!this._data) return; return getPoint( this, Math.round(vec[0] * (this._width - 1)), @@ -93,6 +94,7 @@ class Silhouette { * @return {boolean} Any of the pixels have some alpha. */ isTouchingLinear (vec) { + if (!this._data) return; const x = Math.floor(vec[0] * (this._width - 1)); const y = Math.floor(vec[1] * (this._height - 1)); return getPoint(this, x, y) > 0 ||