mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-08 01:10:02 +01:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4162a14df6 | ||
|
|
031bf0d118 | ||
|
|
28f98d2790 | ||
|
|
0cbefa37bb | ||
|
|
24f33f0545 | ||
|
|
e95bbded68 | ||
|
|
d002549a15 | ||
|
|
39213b2e52 | ||
|
|
85758fc45f | ||
|
|
fd097b9ce1 | ||
|
|
ac1b837aea | ||
|
|
670fed4a25 |
5
package-lock.json
generated
5
package-lock.json
generated
@@ -6315,6 +6315,11 @@
|
||||
"integrity": "sha512-6Ey4Xy2xvmuQu7z7YQtMsaMV0EHJRpVxIDOd5GRrm04/I3nkTKIutELfECsLp6le+b3SSa3cXhPiw6PgqzxYWA==",
|
||||
"dev": true
|
||||
},
|
||||
"expr-eval": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/expr-eval/-/expr-eval-2.0.2.tgz",
|
||||
"integrity": "sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg=="
|
||||
},
|
||||
"ext-list": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ext-list/-/ext-list-2.2.2.tgz",
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"data-uri-to-buffer": "^3.0.0",
|
||||
"downloadjs": "^1.4.7",
|
||||
"eslint": "^6.1.0",
|
||||
"expr-eval": "^2.0.2",
|
||||
"fisheyegl": "^0.1.2",
|
||||
"font-awesome": "~4.7.0",
|
||||
"geotiff": "^1.0.0-beta.6",
|
||||
|
||||
@@ -14,20 +14,18 @@ module.exports = function Dynamic(options, UI) {
|
||||
options.blue = options.blue || defaults.blue;
|
||||
options.green = options.green || defaults.green;
|
||||
|
||||
const Parser = require('expr-eval').Parser;
|
||||
function generator(expression) {
|
||||
var func = 'f = function (r, g, b, a) { var R = r, G = g, B = b, A = a; return ' + expression + ';}';
|
||||
var f;
|
||||
eval(func);
|
||||
return f;
|
||||
let expr = Parser.parse('R = r; G = g; B = b; A = a; ' + expression);
|
||||
return expr.toJSFunction("r,g,b,a,R,G,B,A");
|
||||
}
|
||||
|
||||
|
||||
var channels = ['red', 'green', 'blue', 'alpha'];
|
||||
|
||||
channels.forEach(function(channel) {
|
||||
if (channel === 'alpha'){
|
||||
options['alpha_function'] = function() { return 255; };
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
options[channel + '_function'] = generator(options[channel]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = (moduleName, options, benchmark, input) => {
|
||||
looksSame(result, benchmark[0], function(err, res) {
|
||||
if (err) console.log(err);
|
||||
|
||||
t.equal(res.equal, true, `${moduleName} module works correctly with initial option ${options[0][moduleName]}`);
|
||||
t.equal(res.equal, true, `${moduleName} module works correctly with initial option ${JSON.stringify(options[0])}`);
|
||||
});
|
||||
// Change the option of the given module.
|
||||
sequencer.steps[1].setOptions(options[1]);
|
||||
@@ -54,7 +54,7 @@ module.exports = (moduleName, options, benchmark, input) => {
|
||||
looksSame(newResult, benchmark[1], function(err, res) {
|
||||
if (err) console.log(err);
|
||||
|
||||
t.equal(res.equal, true, `${moduleName} module works correctly when the option is changed to ${options[1][moduleName]}`);
|
||||
t.equal(res.equal, true, `${moduleName} module works correctly when the option is changed to ${JSON.stringify(options[1])}`);
|
||||
sequencer = null;
|
||||
t.end();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user