forked from publiclab/image-sequencer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolves publiclab#113 add brightness module
Signed-off-by: tech4GT <[email protected]>
- Loading branch information
Showing
6 changed files
with
169 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Changes the Image Brightness | ||
*/ | ||
|
||
module.exports = function Brightness(options,UI){ | ||
options = options || {}; | ||
options.title = "Brightness"; | ||
options.description = "Changes the brightness of the image"; | ||
|
||
//Tell the UI that a step has been set up | ||
UI.onSetup(options.step); | ||
var output; | ||
|
||
function draw(input,callback){ | ||
|
||
// Tell the UI that a step is being drawn | ||
UI.onDraw(options.step); | ||
|
||
var step = this; | ||
|
||
function changePixel(r, g, b, a){ | ||
var val = (options.brightness)/100.0 | ||
|
||
r = val*r<255?val*r:255 | ||
g = val*g<255?val*g:255 | ||
b = val*b<255?val*b:255 | ||
return [r , g, b, a] | ||
} | ||
|
||
function output(image,datauri,mimetype){ | ||
|
||
// This output is accessible by Image Sequencer | ||
step.output = {src:datauri,format:mimetype}; | ||
|
||
// This output is accessible by UI | ||
options.step.output = datauri; | ||
|
||
// Tell UI that step has been drawn. | ||
UI.onComplete(options.step); | ||
} | ||
|
||
return require('../_nomodule/PixelManipulation.js')(input, { | ||
output: output, | ||
changePixel: changePixel, | ||
format: input.format, | ||
image: options.image, | ||
callback: callback | ||
}); | ||
|
||
} | ||
return { | ||
options: options, | ||
draw: draw, | ||
output: output, | ||
UI: UI | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "Brightness", | ||
"description": "Change the brightness of the image by given value", | ||
"inputs": { | ||
"brightness": { | ||
"type": "integer", | ||
"desc": "% brightness for the new image", | ||
"default": 0 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters