Browse Source

Merge branch 'feature/62-output-diff-portion-from-inputs' of https://github.com/kamilbielawski/Resemble.js into kamilbielawski-feature/62-output-diff-portion-from-inputs

pull/112/head
james.cryer 7 years ago
parent
commit
ff93232049
  1. 4
      demoassets/main.js
  2. 2
      index.html
  3. 14
      resemble.js

4
demoassets/main.js

@ -179,9 +179,9 @@ $(function(){
resembleControl.repaint(); resembleControl.repaint();
} }
else else
if($this.is('#outputDiff')){ if($this.is('#diffOnly')){
resemble.outputSettings({ resemble.outputSettings({
outputDiff: true errorType: 'diffOnly'
}); });
resembleControl.repaint(); resembleControl.repaint();
} }

2
index.html

@ -119,7 +119,7 @@
<button class="btn" id="movement">Movement</button> <button class="btn" id="movement">Movement</button>
<button class="btn" id="flatDifferenceIntensity">Flat with diff intensity</button> <button class="btn" id="flatDifferenceIntensity">Flat with diff intensity</button>
<button class="btn" id="movementDifferenceIntensity">Movement with diff intensity</button> <button class="btn" id="movementDifferenceIntensity">Movement with diff intensity</button>
<button class="btn" id="outputDiff">Diff portion from the input</button> <button class="btn" id="diffOnly">Diff portion from the input</button>
</div> </div>
<br/> <br/>
<br/> <br/>

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

Loading…
Cancel
Save