mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-13 20:00:05 +01:00
Colorbar added (#316)
* setup Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * overlay done Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add colorbar fixes #285 Signed-off-by: tech4GT <varun.gupta1798@gmail.com> * add inputs to colorbar Signed-off-by: tech4GT <varun.gupta1798@gmail.com>
This commit is contained in:
committed by
Jeffrey Warren
parent
43e6253095
commit
e15e981d0b
70
src/modules/Overlay/Module.js
Normal file
70
src/modules/Overlay/Module.js
Normal file
@@ -0,0 +1,70 @@
|
||||
module.exports = function Dynamic(options, UI, util) {
|
||||
|
||||
options.x = options.x || 0;
|
||||
options.y = options.y || 0;
|
||||
|
||||
var output;
|
||||
|
||||
// This function is called on every draw.
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
options.offset = options.offset || -2;
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
var step = this;
|
||||
|
||||
// save the pixels of the base image
|
||||
var baseStepImage = this.getStep(options.offset).image;
|
||||
var baseStepOutput = this.getOutput(options.offset);
|
||||
|
||||
var getPixels = require('get-pixels');
|
||||
|
||||
getPixels(input.src, function(err, pixels) {
|
||||
options.secondImagePixels = pixels;
|
||||
|
||||
function changePixel(r1, g1, b1, a1, x, y) {
|
||||
|
||||
// overlay
|
||||
var p = options.secondImagePixels;
|
||||
if (x >= options.x
|
||||
&& x < p.shape[0]
|
||||
&& y >= options.y
|
||||
&& y < p.shape[1])
|
||||
return [
|
||||
p.get(x, y, 0),
|
||||
p.get(x, y, 1),
|
||||
p.get(x, y, 2),
|
||||
p.get(x, y, 3)
|
||||
];
|
||||
else
|
||||
return [r1, g1, b1, a1];
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype) {
|
||||
|
||||
// This output is accessible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
|
||||
}
|
||||
|
||||
// run PixelManipulation on first Image pixels
|
||||
return require('../_nomodule/PixelManipulation.js')(baseStepOutput, {
|
||||
output: output,
|
||||
changePixel: changePixel,
|
||||
format: baseStepOutput.format,
|
||||
image: baseStepImage,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user