Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "restore global settings function" #123

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 35 additions & 50 deletions resemble.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ URL: https://github.com/Huddle/Resemble.js
}
};

var oldGlobalSettings = {};
var globalOutputSettings = oldGlobalSettings;

function setGlobalOutputSettings(settings) {
var msg = 'warning resemble.outputSettings mutates global state, and ' +
'will be removed in 3.0.0';
console.warn(msg);
globalOutputSettings = settings;
return this
}

var resemble = function( fileData ){
var pixelTransparency = 1;

Expand Down Expand Up @@ -596,6 +585,40 @@ URL: https://github.com/Huddle/Resemble.js
return img;
}

function compare(one, two){

function onceWeHaveBoth(){
var width;
var height;
if(images.length === 2){
if( images[0].error || images[1].error ){
data = {};
data.error = images[0].error ? images[0].error : images[1].error;
triggerDataUpdate();
return;
}
width = images[0].width > images[1].width ? images[0].width : images[1].width;
height = images[0].height > images[1].height ? images[0].height : images[1].height;

if( (images[0].width === images[1].width) && (images[0].height === images[1].height) ){
data.isSameDimensions = true;
} else {
data.isSameDimensions = false;
}

data.dimensionDifference = { width: images[0].width - images[1].width, height: images[0].height - images[1].height };

analyseImages( normalise(images[0],width, height), normalise(images[1],width, height), width, height);

triggerDataUpdate();
}
}

images = [];
loadImageData(one, onceWeHaveBoth);
loadImageData(two, onceWeHaveBoth);
}

function outputSettings(options){
var key;
var undefined;
Expand Down Expand Up @@ -631,43 +654,6 @@ URL: https://github.com/Huddle/Resemble.js

}

function compare(one, two){
if (globalOutputSettings !== oldGlobalSettings) {
outputSettings(options);
}

function onceWeHaveBoth(){
var width;
var height;
if(images.length === 2){
if( images[0].error || images[1].error ){
data = {};
data.error = images[0].error ? images[0].error : images[1].error;
triggerDataUpdate();
return;
}
width = images[0].width > images[1].width ? images[0].width : images[1].width;
height = images[0].height > images[1].height ? images[0].height : images[1].height;

if( (images[0].width === images[1].width) && (images[0].height === images[1].height) ){
data.isSameDimensions = true;
} else {
data.isSameDimensions = false;
}

data.dimensionDifference = { width: images[0].width - images[1].width, height: images[0].height - images[1].height };

analyseImages( normalise(images[0],width, height), normalise(images[1],width, height), width, height);

triggerDataUpdate();
}
}

images = [];
loadImageData(one, onceWeHaveBoth);
loadImageData(two, onceWeHaveBoth);
}

function getCompareApi(param){

var secondFileData,
Expand Down Expand Up @@ -797,7 +783,7 @@ URL: https://github.com/Huddle/Resemble.js
},
compareTo: function(secondFileData){
return getCompareApi(secondFileData);
},
}
graingert marked this conversation as resolved.
Show resolved Hide resolved
outputSettings: function(options) {
outputSettings(options);
return rootSelf;
Expand Down Expand Up @@ -852,6 +838,5 @@ URL: https://github.com/Huddle/Resemble.js
});
};

resemble.outputSettings = setGlobalOutputSettings;
return resemble;
}));