From 72bd43648775b005d67be433dbeaaa5684e917e1 Mon Sep 17 00:00:00 2001 From: Kamil Bielawski Date: Wed, 31 Jan 2018 21:58:40 +0100 Subject: [PATCH] Add support for ignoring rectangle --- README.md | 14 ++++++++++++++ demoassets/main.js | 19 +++++++++++++++---- index.html | 37 +++++++++++++++++++++++++++++++++---- resemble.js | 39 +++++++++++++++++++++++++++------------ 4 files changed, 89 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 6972c42..85c0b09 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,20 @@ resemble.outputSettings({ // .repaint(); ``` +You can also exclude part of the image from comparison, by specifying the excluded area in pixels from the top left: + +```javascript +resemble.outputSettings({ + ignoredBox: { + left: 100, + top: 200, + right: 200, + bottom: 600 + } +}) +// .repaint(); +``` + By default, the comparison algorithm skips pixels when the image width or height is larger than 1200 pixels. This is there to mitigate performance issues. You can modify this behaviour by setting the `largeImageThreshold` option to a different value. Set it to **0** to switch it off completely. diff --git a/demoassets/main.js b/demoassets/main.js index 7f73910..9ed4a1f 100644 --- a/demoassets/main.js +++ b/demoassets/main.js @@ -198,10 +198,21 @@ $(function(){ if($this.is('#boundingBox')){ resembleControl.outputSettings({ boundingBox: { - left: $("#x1").val(), - top: $("#y1").val(), - right: $("#x2").val(), - bottom: $("#y2").val() + left: $("#bounding-box-x1").val(), + top: $("#bounding-box-y1").val(), + right: $("#bounding-box-x2").val(), + bottom: $("#bounding-box-y2").val() + } + }).repaint(); + $this.removeClass('active'); + } + if($this.is('#ignoredBox')){ + resembleControl.outputSettings({ + ignoredBox: { + left: $("#ignored-box-x1").val(), + top: $("#ignored-box-y1").val(), + right: $("#ignored-box-x2").val(), + bottom: $("#ignored-box-y2").val() } }).repaint(); $this.removeClass('active'); diff --git a/index.html b/index.html index e1ba636..86c43fe 100644 --- a/index.html +++ b/index.html @@ -142,19 +142,19 @@
- +
- +
- +
- +
@@ -162,6 +162,35 @@
+ +
+
+ + +