From 55ed24a782c2b2216ee555db5dc0d7a8054a0cb5 Mon Sep 17 00:00:00 2001 From: Kamil Bielawski Date: Sun, 15 Oct 2017 00:39:12 +0200 Subject: [PATCH] Implement as new errorType --- demoassets/main.js | 4 ++-- index.html | 2 +- resemble.js | 14 +++++--------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/demoassets/main.js b/demoassets/main.js index 8f44fdc..5f43e61 100644 --- a/demoassets/main.js +++ b/demoassets/main.js @@ -179,9 +179,9 @@ $(function(){ resembleControl.repaint(); } else - if($this.is('#outputDiff')){ + if($this.is('#diffOnly')){ resemble.outputSettings({ - outputDiff: true + errorType: 'diffOnly' }); resembleControl.repaint(); } diff --git a/index.html b/index.html index 827db2f..fab28ca 100644 --- a/index.html +++ b/index.html @@ -119,7 +119,7 @@ - +

diff --git a/resemble.js b/resemble.js index 5eeae61..5278074 100644 --- a/resemble.js +++ b/resemble.js @@ -67,7 +67,7 @@ URL: https://github.com/Huddle/Resemble.js px[offset + 2] = ((1 - ratio) * (d2.b * (errorPixelColor.blue / 255)) + ratio * errorPixelColor.blue); px[offset + 3] = d2.a; }, - copySecondImage: function (px, offset, d1, d2) { + diffOnly: function (px, offset, d1, d2) { px[offset] = d2.r; px[offset + 1] = d2.g; px[offset + 2] = d2.b; @@ -76,10 +76,10 @@ URL: https://github.com/Huddle/Resemble.js }; var errorPixel = errorPixelTransform.flat; + var errorType; var boundingBox; var largeImageThreshold = 1200; var useCrossOrigin = true; - var outputDiff = false; var document = typeof window != "undefined" ? window.document : { createElement: function() { // This will work as long as only createElement is used on window.document @@ -374,7 +374,7 @@ URL: https://github.com/Huddle/Resemble.js } function copyPixel(px, offset, data){ - if (outputDiff) { + if (errorType === 'diffOnly') { return; } @@ -385,7 +385,7 @@ URL: https://github.com/Huddle/Resemble.js } function copyGrayScalePixel(px, offset, data){ - if (outputDiff) { + if (errorType === 'diffOnly') { return; } @@ -739,6 +739,7 @@ URL: https://github.com/Huddle/Resemble.js if(options.errorType && errorPixelTransform[options.errorType] ){ errorPixel = errorPixelTransform[options.errorType]; + errorType = options.errorType; } if(options.errorPixel && typeof options.errorPixel === "function") { @@ -759,11 +760,6 @@ URL: https://github.com/Huddle/Resemble.js boundingBox = options.boundingBox; } - if (options.outputDiff) { - outputDiff = options.outputDiff; - errorPixel = errorPixelTransform.copySecondImage; - } - return this; };