mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-11 19:00:00 +01:00
* remove trailing spaces from Run.js Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * minimize module requirements demonstrated with invert fixes #122 Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * refactored modules Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * update docs Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * remove all trailing spaces from all files Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fixing crop module Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * fix Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * update contributing.md Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
57 lines
1.1 KiB
JavaScript
57 lines
1.1 KiB
JavaScript
/*
|
|
* Saturate an image with a value from 0 to 1
|
|
*/
|
|
module.exports = function Saturation(options,UI) {
|
|
|
|
var output;
|
|
|
|
function draw(input,callback,progressObj) {
|
|
|
|
progressObj.stop(true);
|
|
progressObj.overrideFlag = true;
|
|
|
|
var step = this;
|
|
|
|
function changePixel(r, g, b, a) {
|
|
|
|
var cR = 0.299;
|
|
var cG = 0.587;
|
|
var cB = 0.114;
|
|
|
|
var p = Math.sqrt((cR * (r*r)) + (cG * (g*g)) + (cB * (g*g)));
|
|
|
|
r = p+(r-p)*(options.saturation);
|
|
g = p+(g-p)*(options.saturation);
|
|
b = p+(b-p)*(options.saturation);
|
|
|
|
|
|
return [Math.round(r), Math.round(g), Math.round(b), a];
|
|
}
|
|
|
|
function output(image,datauri,mimetype){
|
|
|
|
// This output is accesible by Image Sequencer
|
|
step.output = {src:datauri,format:mimetype};
|
|
|
|
}
|
|
|
|
return require('../_nomodule/PixelManipulation.js')(input, {
|
|
output: output,
|
|
changePixel: changePixel,
|
|
format: input.format,
|
|
image: options.image,
|
|
inBrowser: options.inBrowser,
|
|
callback: callback
|
|
});
|
|
|
|
}
|
|
|
|
return {
|
|
options: options,
|
|
//setup: setup, // optional
|
|
draw: draw,
|
|
output: output,
|
|
UI: UI
|
|
}
|
|
}
|