mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-07 00:40:00 +01:00
Compare commits
1 Commits
HarshKhand
...
dynamic-ma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21abb92d2b |
25004
dist/image-sequencer.js
vendored
25004
dist/image-sequencer.js
vendored
File diff suppressed because one or more lines are too long
2
dist/image-sequencer.min.js
vendored
2
dist/image-sequencer.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -54,6 +54,22 @@ module.exports = function Dynamic(options,UI) {
|
||||
]
|
||||
}
|
||||
|
||||
// via P5js: https://github.com/processing/p5.js/blob/2920492842aae9a8bf1a779916893ac19d65cd38/src/math/calculation.js#L461-L472
|
||||
function map(n, start1, stop1, start2, stop2, withinBounds) {
|
||||
var newval = (n - start1) / (stop1 - start1) * (stop2 - start2) + start2;
|
||||
if (!withinBounds) {
|
||||
return newval;
|
||||
}
|
||||
// also via P5js: https://github.com/processing/p5.js/blob/2920492842aae9a8bf1a779916893ac19d65cd38/src/math/calculation.js#L116-L119
|
||||
function constrain(n, low, high) {
|
||||
return Math.max(Math.min(n, high), low);
|
||||
};
|
||||
if (start2 < stop2) {
|
||||
return constrain(newval, start2, stop2);
|
||||
} else {
|
||||
return constrain(newval, stop2, start2);
|
||||
}
|
||||
};
|
||||
|
||||
function output(image,datauri,mimetype){
|
||||
|
||||
|
||||
Reference in New Issue
Block a user