");
- return pixels;
- }
-
- function output(image, datauri, mimetype){
-
- // This output is accessible by Image Sequencer
- step.output = {
- src: datauri,
- format: mimetype
- };
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- callback: callback
- });
-
- }
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+* Average all pixel colors
+*/
+module.exports = function Average(options, UI){
+
+ options.blur = options.blur || 2
+ var output;
+
+ options.step.metadata = options.step.metadata || {};
+
+ function draw(input,callback,progressObj){
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a){
+ return [r,g,b,a]
+ }
+
+ // do the averaging
+ function extraManipulation(pixels){
+ var sum = [0,0,0,0];
+ for (var i = 0; i < pixels.data.length; i += 4) {
+ sum[0] += pixels.data[i + 0];
+ sum[1] += pixels.data[i + 1];
+ sum[2] += pixels.data[i + 2];
+ sum[3] += pixels.data[i + 3];
+ }
+
+ sum[0] = parseInt(sum[0] / (pixels.data.length / 4));
+ sum[1] = parseInt(sum[1] / (pixels.data.length / 4));
+ sum[2] = parseInt(sum[2] / (pixels.data.length / 4));
+ sum[3] = parseInt(sum[3] / (pixels.data.length / 4));
+
+ for (var i = 0; i < pixels.data.length; i += 4) {
+ pixels.data[i + 0] = sum[0];
+ pixels.data[i + 1] = sum[1];
+ pixels.data[i + 2] = sum[2];
+ pixels.data[i + 3] = sum[3];
+ }
+ // report back and store average in metadata:
+ options.step.metadata.averages = sum;
+ console.log("average: ", sum);
+ // TODO: refactor into a new "display()" method as per https://github.com/publiclab/image-sequencer/issues/242
+ if (options.step.inBrowser && options.step.ui) $(options.step.ui).find('.details').append("
Averages (r, g, b, a): " + sum.join(', ') + "
");
+ return pixels;
+ }
+
+ function output(image, datauri, mimetype){
+
+ // This output is accessible by Image Sequencer
+ step.output = {
+ src: datauri,
+ format: mimetype
+ };
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ callback: callback
+ });
+
+ }
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249}],162:[function(require,module,exports){
-module.exports = [
- require('./Module'),
- require('./info.json')
+module.exports = [
+ require('./Module'),
+ require('./info.json')
]
},{"./Module":161,"./info.json":163}],163:[function(require,module,exports){
-module.exports={
- "name": "Average",
- "description": "Average all pixel color",
- "inputs": {
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Average",
+ "description": "Average all pixel color",
+ "inputs": {
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],164:[function(require,module,exports){
-module.exports = function Dynamic(options, UI, util) {
-
- options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }";
- options.offset = options.offset || -2;
-
- var output;
-
- // This function is called on every draw.
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- // convert to runnable code:
- if (typeof options.func === "string") eval('options.func = ' + options.func);
-
- var getPixels = require('get-pixels');
-
- // convert offset as string to int
- if(typeof options.offset === "string") options.offset = parseInt(options.offset);
-
- // save first image's pixels
- var priorStep = this.getStep(options.offset);
-
- getPixels(priorStep.output.src, function(err, pixels) {
- options.firstImagePixels = pixels;
-
- function changePixel(r2, g2, b2, a2, x, y) {
- // blend!
- var p = options.firstImagePixels;
- return options.func(
- r2, g2, b2, a2,
- p.get(x, y, 0),
- p.get(x, y, 1),
- p.get(x, y, 2),
- p.get(x, y, 3)
- )
- }
-
- function output(image, datauri, mimetype) {
-
- // This output is accessible by Image Sequencer
- step.output = { src: datauri, format: mimetype };
-
- }
-
- // run PixelManipulatin on second image's pixels
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: callback
- });
- });
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+module.exports = function Dynamic(options, UI, util) {
+
+ options.func = options.func || "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }";
+ options.offset = options.offset || -2;
+
+ var output;
+
+ // This function is called on every draw.
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ // convert to runnable code:
+ if (typeof options.func === "string") eval('options.func = ' + options.func);
+
+ var getPixels = require('get-pixels');
+
+ // convert offset as string to int
+ if(typeof options.offset === "string") options.offset = parseInt(options.offset);
+
+ // save first image's pixels
+ var priorStep = this.getStep(options.offset);
+
+ getPixels(priorStep.output.src, function(err, pixels) {
+ options.firstImagePixels = pixels;
+
+ function changePixel(r2, g2, b2, a2, x, y) {
+ // blend!
+ var p = options.firstImagePixels;
+ return options.func(
+ r2, g2, b2, a2,
+ p.get(x, y, 0),
+ p.get(x, y, 1),
+ p.get(x, y, 2),
+ p.get(x, y, 3)
+ )
+ }
+
+ function output(image, datauri, mimetype) {
+
+ // This output is accessible by Image Sequencer
+ step.output = { src: datauri, format: mimetype };
+
+ }
+
+ // run PixelManipulatin on second image's pixels
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: callback
+ });
+ });
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"get-pixels":29}],165:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":164,"./info.json":166,"dup":162}],166:[function(require,module,exports){
-module.exports={
- "name": "Blend",
- "description": "Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!",
- "inputs": {
- "offset": {
- "type": "integer",
- "desc": "Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.",
- "default": -2
- },
- "blend": {
- "type": "input",
- "desc": "Function to use to blend the two images.",
- "default": "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Blend",
+ "description": "Blend two chosen image steps with the given function. Defaults to using the red channel from image 1 and the green and blue and alpha channels of image 2. Easier to use interfaces coming soon!",
+ "inputs": {
+ "offset": {
+ "type": "integer",
+ "desc": "Choose which image to blend the current image with. Two steps back is -2, three steps back is -3 etc.",
+ "default": -2
+ },
+ "blend": {
+ "type": "input",
+ "desc": "Function to use to blend the two images.",
+ "default": "function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] }"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],167:[function(require,module,exports){
-module.exports = exports = function(pixels, blur) {
- let kernel = kernelGenerator(blur, 1), oldpix = pixels;
- kernel = flipKernel(kernel);
-
- for (let i = 0; i < pixels.shape[0]; i++) {
- for (let j = 0; j < pixels.shape[1]; j++) {
- let neighboutPos = getNeighbouringPixelPositions([i, j]);
- let acc = [0.0, 0.0, 0.0, 0.0];
- for (let a = 0; a < kernel.length; a++) {
- for (let b = 0; b < kernel.length; b++) {
- acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]);
- acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]);
- acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]);
- acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]);
- }
- }
- pixels.set(i, j, 0, acc[0]);
- pixels.set(i, j, 1, acc[1]);
- pixels.set(i, j, 2, acc[2]);
- }
- }
- return pixels;
-
-
-
- //Generates a 3x3 Gaussian kernel
- function kernelGenerator(sigma, size) {
-
- /*
- Trying out a variable radius kernel not working as of now
- */
- // const coeff = (1.0/(2.0*Math.PI*sigma*sigma))
- // const expCoeff = -1 * (1.0/2.0 * sigma * sigma)
- // let e = Math.E
- // let result = []
- // for(let i = -1 * size;i<=size;i++){
- // let arr = []
- // for(let j= -1 * size;j<=size;j++){
- // arr.push(coeff * Math.pow(e,expCoeff * ((i * i) + (j*j))))
- // }
- // result.push(arr)
- // }
- // let sum = result.reduce((sum,val)=>{
- // return val.reduce((sumInner,valInner)=>{
- // return sumInner+valInner
- // })
- // })
- // result = result.map(arr=>arr.map(val=>(val + 0.0)/(sum + 0.0)))
-
- // return result
-
- return [
- [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0],
- [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0],
- [5.0 / 159.0, 12.0 / 159.0, 15.0 / 159.0, 12.0 / 159.0, 5.0 / 159.0],
- [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0],
- [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0]
- ];
- }
- function getNeighbouringPixelPositions(pixelPosition) {
- let x = pixelPosition[0], y = pixelPosition[1], result = [];
-
- for (let i = -2; i <= 2; i++) {
- let arr = [];
- for (let j = -2; j <= 2; j++)
- arr.push([x + i, y + j]);
-
- result.push(arr);
- }
- return result;
- }
-
- function flipKernel(kernel) {
- let result = [];
- for (let i = kernel.length - 1; i >= 0; i--) {
- let arr = [];
- for (let j = kernel[i].length - 1; j >= 0; j--) {
- arr.push(kernel[i][j]);
- }
- result.push(arr);
- }
- return result;
- }
+module.exports = exports = function(pixels, blur) {
+ let kernel = kernelGenerator(blur, 1), oldpix = pixels;
+ kernel = flipKernel(kernel);
+
+ for (let i = 0; i < pixels.shape[0]; i++) {
+ for (let j = 0; j < pixels.shape[1]; j++) {
+ let neighboutPos = getNeighbouringPixelPositions([i, j]);
+ let acc = [0.0, 0.0, 0.0, 0.0];
+ for (let a = 0; a < kernel.length; a++) {
+ for (let b = 0; b < kernel.length; b++) {
+ acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]);
+ acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]);
+ acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]);
+ acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]);
+ }
+ }
+ pixels.set(i, j, 0, acc[0]);
+ pixels.set(i, j, 1, acc[1]);
+ pixels.set(i, j, 2, acc[2]);
+ }
+ }
+ return pixels;
+
+
+
+ //Generates a 3x3 Gaussian kernel
+ function kernelGenerator(sigma, size) {
+
+ /*
+ Trying out a variable radius kernel not working as of now
+ */
+ // const coeff = (1.0/(2.0*Math.PI*sigma*sigma))
+ // const expCoeff = -1 * (1.0/2.0 * sigma * sigma)
+ // let e = Math.E
+ // let result = []
+ // for(let i = -1 * size;i<=size;i++){
+ // let arr = []
+ // for(let j= -1 * size;j<=size;j++){
+ // arr.push(coeff * Math.pow(e,expCoeff * ((i * i) + (j*j))))
+ // }
+ // result.push(arr)
+ // }
+ // let sum = result.reduce((sum,val)=>{
+ // return val.reduce((sumInner,valInner)=>{
+ // return sumInner+valInner
+ // })
+ // })
+ // result = result.map(arr=>arr.map(val=>(val + 0.0)/(sum + 0.0)))
+
+ // return result
+
+ return [
+ [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0],
+ [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0],
+ [5.0 / 159.0, 12.0 / 159.0, 15.0 / 159.0, 12.0 / 159.0, 5.0 / 159.0],
+ [4.0 / 159.0, 9.0 / 159.0, 12.0 / 159.0, 9.0 / 159.0, 4.0 / 159.0],
+ [2.0 / 159.0, 4.0 / 159.0, 5.0 / 159.0, 4.0 / 159.0, 2.0 / 159.0]
+ ];
+ }
+ function getNeighbouringPixelPositions(pixelPosition) {
+ let x = pixelPosition[0], y = pixelPosition[1], result = [];
+
+ for (let i = -2; i <= 2; i++) {
+ let arr = [];
+ for (let j = -2; j <= 2; j++)
+ arr.push([x + i, y + j]);
+
+ result.push(arr);
+ }
+ return result;
+ }
+
+ function flipKernel(kernel) {
+ let result = [];
+ for (let i = kernel.length - 1; i >= 0; i--) {
+ let arr = [];
+ for (let j = kernel[i].length - 1; j >= 0; j--) {
+ arr.push(kernel[i][j]);
+ }
+ result.push(arr);
+ }
+ return result;
+ }
}
},{}],168:[function(require,module,exports){
-/*
-* Blur an Image
-*/
-module.exports = function Blur(options, UI) {
-
- options.blur = options.blur || 2
- var output;
-
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- return [r, g, b, a]
- }
-
- function extraManipulation(pixels) {
- pixels = require('./Blur')(pixels, options.blur)
- return pixels
- }
-
- function output(image, datauri, mimetype) {
-
- // This output is accessible by Image Sequencer
- step.output = { src: datauri, format: mimetype };
-
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- callback: callback
- });
-
- }
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+* Blur an Image
+*/
+module.exports = function Blur(options, UI) {
+
+ options.blur = options.blur || 2
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ return [r, g, b, a]
+ }
+
+ function extraManipulation(pixels) {
+ pixels = require('./Blur')(pixels, options.blur)
+ return pixels
+ }
+
+ function output(image, datauri, mimetype) {
+
+ // This output is accessible by Image Sequencer
+ step.output = { src: datauri, format: mimetype };
+
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ callback: callback
+ });
+
+ }
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"./Blur":167}],169:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":168,"./info.json":170,"dup":162}],170:[function(require,module,exports){
-module.exports={
- "name": "Blur",
- "description": "Applies a Gaussian blur given by the intensity value",
- "inputs": {
- "blur": {
- "type": "range",
- "desc": "Amount of gaussian blur(Less blur gives more detail, typically 0-5)",
- "default": "2",
- "min": "0",
- "max": "5",
- "step": "0.25"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Blur",
+ "description": "Applies a Gaussian blur given by the intensity value",
+ "inputs": {
+ "blur": {
+ "type": "range",
+ "desc": "Amount of gaussian blur(Less blur gives more detail, typically 0-5)",
+ "default": "2",
+ "min": "0",
+ "max": "5",
+ "step": "0.25"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],171:[function(require,module,exports){
-/*
-* Changes the Image Brightness
-*/
-
-module.exports = function Brightness(options,UI){
-
-
- var output;
-
- function draw(input,callback,progressObj){
-
- options.brightness = parseInt(options.brightness) || 100;
- var val = (options.brightness)/100.0;
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- /*
- In this case progress is handled by changepixel internally otherwise progressObj
- needs to be overriden and used
- For eg. progressObj = new SomeProgressModule()
- */
-
- var step = this;
-
- function changePixel(r, g, b, a){
-
- r = Math.min(val*r, 255)
- g = Math.min(val*g, 255)
- b = Math.min(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};
-
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: callback
- });
-
- }
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+* Changes the Image Brightness
+*/
+
+module.exports = function Brightness(options,UI){
+
+
+ var output;
+
+ function draw(input,callback,progressObj){
+
+ options.brightness = parseInt(options.brightness) || 100;
+ var val = (options.brightness)/100.0;
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ /*
+ In this case progress is handled by changepixel internally otherwise progressObj
+ needs to be overriden and used
+ For eg. progressObj = new SomeProgressModule()
+ */
+
+ var step = this;
+
+ function changePixel(r, g, b, a){
+
+ r = Math.min(val*r, 255)
+ g = Math.min(val*g, 255)
+ b = Math.min(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};
+
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: callback
+ });
+
+ }
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249}],172:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":171,"./info.json":173,"dup":162}],173:[function(require,module,exports){
-module.exports={
- "name": "Brightness",
- "description": "Change the brightness of the image by given percent value",
- "inputs": {
- "brightness": {
- "type": "range",
- "desc": "% brightness for the new image",
- "default": "175",
- "min": "0",
- "max": "200",
- "step": "1"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Brightness",
+ "description": "Change the brightness of the image by given percent value",
+ "inputs": {
+ "brightness": {
+ "type": "range",
+ "desc": "% brightness for the new image",
+ "default": "175",
+ "min": "0",
+ "max": "200",
+ "step": "1"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],174:[function(require,module,exports){
-/*
- * Display only one color channel
- */
-module.exports = function Channel(options, UI) {
-
- options.channel = options.channel || "green";
-
- var output;
-
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- if (options.channel == "red") return [r, 0, 0, a];
- if (options.channel == "green") return [0, g, 0, a];
- if (options.channel == "blue") return [0, 0, 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
- }
-}
+/*
+ * Display only one color channel
+ */
+module.exports = function Channel(options, UI) {
+
+ options.channel = options.channel || "green";
+
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ if (options.channel == "red") return [r, 0, 0, a];
+ if (options.channel == "green") return [0, g, 0, a];
+ if (options.channel == "blue") return [0, 0, 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
+ }
+}
},{"../_nomodule/PixelManipulation.js":249}],175:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":174,"./info.json":176,"dup":162}],176:[function(require,module,exports){
-module.exports={
- "name": "Channel",
- "description": "Displays only one color channel of an image -- default is green",
- "inputs": {
- "channel": {
- "type": "select",
- "desc": "Color channel",
- "default": "green",
- "values": ["red", "green", "blue"]
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Channel",
+ "description": "Displays only one color channel of an image -- default is green",
+ "inputs": {
+ "channel": {
+ "type": "select",
+ "desc": "Color channel",
+ "default": "green",
+ "values": ["red", "green", "blue"]
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],177:[function(require,module,exports){
-module.exports = function NdviColormapfunction(options, UI) {
-
- options.x = options.x || 0;
- options.y = options.y || 0;
- options.colormap = options.colormap || "default";
- options.h = options.h || 10;
- this.expandSteps([
- { 'name': 'gradient', 'options': {} },
- { 'name': 'colormap', 'options': { colormap: options.colormap } },
- { 'name': 'crop', 'options': { 'y': 0, 'h': options.h } },
- { 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } }
- ]);
- return {
- isMeta: true
- }
+module.exports = function NdviColormapfunction(options, UI) {
+
+ options.x = options.x || 0;
+ options.y = options.y || 0;
+ options.colormap = options.colormap || "default";
+ options.h = options.h || 10;
+ this.expandSteps([
+ { 'name': 'gradient', 'options': {} },
+ { 'name': 'colormap', 'options': { colormap: options.colormap } },
+ { 'name': 'crop', 'options': { 'y': 0, 'h': options.h } },
+ { 'name': 'overlay', 'options': { 'x': options.x, 'y': options.y, 'offset': -4 } }
+ ]);
+ return {
+ isMeta: true
+ }
}
},{}],178:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":177,"./info.json":179,"dup":162}],179:[function(require,module,exports){
-module.exports={
- "name": "Colorbar",
- "description": "Generates a colorbar to lay over the image",
- "inputs": {
- "colormap": {
- "type": "select",
- "desc": "Name of the Colormap",
- "default": "default",
- "values": [
- "default",
- "greyscale",
- "stretched",
- "fastie"
- ]
- },
- "x": {
- "type": "integer",
- "desc": "X-position of the image on which the new image is overlayed",
- "default": 0
- },
- "y": {
- "type": "integer",
- "desc": "Y-position of the image on which the new image is overlayed",
- "default": 0
- },
- "h": {
- "type": "iinteger",
- "desc": "height of the colorbar",
- "default": 10
- }
- },
- "length": 4,
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Colorbar",
+ "description": "Generates a colorbar to lay over the image",
+ "inputs": {
+ "colormap": {
+ "type": "select",
+ "desc": "Name of the Colormap",
+ "default": "default",
+ "values": [
+ "default",
+ "greyscale",
+ "stretched",
+ "fastie"
+ ]
+ },
+ "x": {
+ "type": "integer",
+ "desc": "X-position of the image on which the new image is overlayed",
+ "default": 0
+ },
+ "y": {
+ "type": "integer",
+ "desc": "Y-position of the image on which the new image is overlayed",
+ "default": 0
+ },
+ "h": {
+ "type": "iinteger",
+ "desc": "height of the colorbar",
+ "default": 10
+ }
+ },
+ "length": 4,
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],180:[function(require,module,exports){
-/*
- * Accepts a value from 0-255 and returns the new color-mapped pixel
- * from a lookup table, which can be specified as an array of [begin, end]
- * gradients, where begin and end are represented as [r, g, b] colors. In
- * combination, a lookup table which maps values from 0 - 255 smoothly from black to white looks like:
- * [
- * [0, [0, 0, 0], [255, 255, 255]],
- * [1, [255, 255, 255], [255, 255, 255]]
- * ]
- *
- * Adapted from bgamari's work in Infragram: https://github.com/p-v-o-s/infragram-js/commit/346c97576a07b71a55671d17e0153b7df74e803b
- */
-
-module.exports = function Colormap(value, options) {
- options.colormap = options.colormap || colormaps.default;
- // if a lookup table is provided as an array:
- if(typeof(options.colormap) == "object")
- colormapFunction = colormap(options.colormap);
- // if a stored colormap is named with a string like "fastie":
- else if(colormaps.hasOwnProperty(options.colormap))
- colormapFunction = colormaps[options.colormap];
- else colormapFunction = colormaps.default;
- return colormapFunction(value / 255.00);
-}
-
-function colormap(segments) {
- return function(x) {
- var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;
- _ref = [0, 0], y0 = _ref[0], y1 = _ref[1];
- _ref1 = [segments[0][0], 1], x0 = _ref1[0], x1 = _ref1[1];
- if (x < x0) {
- return y0;
- }
- for (i = _i = 0, _len = segments.length; _i < _len; i = ++_i) {
- _ref2 = segments[i], xstart = _ref2[0], y0 = _ref2[1], y1 = _ref2[2];
- x0 = xstart;
- if (i === segments.length - 1) {
- x1 = 1;
- break;
- }
- x1 = segments[i + 1][0];
- if ((xstart <= x && x < x1)) {
- break;
- }
- }
- result = [];
- for (i = _j = 0, _ref3 = y0.length; 0 <= _ref3 ? _j < _ref3 : _j > _ref3; i = 0 <= _ref3 ? ++_j : --_j) {
- result[i] = (x - x0) / (x1 - x0) * (y1[i] - y0[i]) + y0[i];
- }
- return result;
- };
-};
-
-var colormaps = {
- greyscale: colormap([
- [0, [0, 0, 0], [255, 255, 255] ],
- [1, [255, 255, 255], [255, 255, 255] ]
- ]),
-
- bluwhtgrngis: colormap([
- [0, [6,23,86], [6,25, 84] ],
- [0.0625, [6,25,84], [6,25, 84] ],//1
- [0.125, [6,25,84], [6,25, 84] ],//2
- [0.1875, [6,25,84], [6,25, 84] ],
- [0.25, [6,25,84], [6,25,84] ],
- [0.3125, [6,25,84], [9,24, 84] ],//5
- [0.3438, [9,24, 84], [119,120,162] ],//5
- [0.375, [119,129,162],[249,250,251] ], //6
- [0.406, [249,250,251],[255,255,255] ], //6.5
- [0.4375, [255,255,255],[255,255,255] ], //7 white
- [0.50, [255,255,255],[214,205,191] ],//8
- [0.52, [214,205,191],[178,175,96] ],//8.2
- [0.5625, [178,175,96], [151,176,53] ],//9
- [0.593, [151,176,53], [146,188,12] ],//9.5
- [0.625, [146,188,12], [96,161,1] ], //10
- [0.6875, [96,161,1], [30,127,3] ],//11
- [0.75, [30,127,3], [0,99,1] ],//12
- [0.8125, [0,99,1], [0,74,1] ],//13
- [0.875, [0,74,1], [0,52, 0] ],//14
- [0.9375, [0,52, 0], [0,34,0] ], //15
- [0.968, [0,34,0], [68,70,67] ] //16
- ]),
-
-
- brntogrn: colormap([
- [0, [110,12,3], [118,6,1] ],
- [0.0625, [118,6,1], [141,19,6] ],
- [0.125, [141,19,6], [165,35,13] ],
- [0.1875, [165,35,13], [177,59,25] ],
- [0.2188, [177,59,25], [192,91,36] ],
- [0.25, [192,91,36], [214, 145, 76] ],
- [0.3125, [214,145,76], [230,183,134] ],
- [0.375, [230,183,134],[243, 224, 194]],
- [0.4375, [243,224,194],[250,252,229] ],
- [0.50, [250,252,229],[217,235,185] ],
- [0.5625, [217,235,185],[184,218,143] ],
- [0.625, [184,218,143],[141,202,89] ],
- [0.6875, [141,202,89], [80,176,61] ],
- [0.75, [80,176,61], [0, 147, 32] ],
- [0.8125, [0,147,32], [1, 122, 22] ],
- [0.875, [1,122,22], [0, 114, 19] ],
- [0.90, [0,114,19], [0,105,18] ],
- [0.9375, [0,105,18], [7,70,14] ]
-
- ]),
-
-
- blutoredjet: colormap([
- [0, [0,0,140], [1,1,186] ],
- [0.0625, [1,1,186], [0,1,248] ],
- [0.125, [0,1,248], [0,70,254] ],
- [0.1875, [0,70,254], [0,130,255] ],
- [0.25, [0,130,255], [2,160,255] ],
- [0.2813, [2,160,255], [0,187,255] ], //inset
- [0.3125, [0,187,255], [6,250,255] ],
- // [0.348, [0,218,255], [8,252,251] ],//inset
- [0.375, [8,252,251], [27,254,228] ],
- [0.406, [27,254,228], [70,255,187] ], //insert
- [0.4375, [70,255,187], [104,254,151]],
- [0.47, [104,254,151],[132,255,19] ],//insert
- [0.50, [132,255,19], [195,255,60] ],
- [0.5625, [195,255,60], [231,254,25] ],
- [0.5976, [231,254,25], [253,246,1] ],//insert
- [0.625, [253,246,1], [252,210,1] ], //yellow
- [0.657, [252,210,1], [255,183,0] ],//insert
- [0.6875, [255,183,0], [255,125,2] ],
- [0.75, [255,125,2], [255,65, 1] ],
- [0.8125, [255,65, 1], [247, 1, 1] ],
- [0.875, [247,1,1], [200, 1, 3] ],
- [0.9375, [200,1,3], [122, 3, 2] ]
-
- ]),
-
-
- colors16: colormap([
- [0, [0,0,0], [0,0,0] ],
- [0.0625, [3,1,172], [3,1,172] ],
- [0.125, [3,1,222], [3,1, 222] ],
- [0.1875, [0,111,255], [0,111,255] ],
- [0.25, [3,172,255], [3,172,255] ],
- [0.3125, [1,226,255], [1,226,255] ],
- [0.375, [2,255,0], [2,255,0] ],
- [0.4375, [198,254,0], [190,254,0] ],
- [0.50, [252,255,0], [252,255,0] ],
- [0.5625, [255,223,3], [255,223,3] ],
- [0.625, [255,143,3], [255,143,3] ],
- [0.6875, [255,95,3], [255,95,3] ],
- [0.75, [242,0,1], [242,0,1] ],
- [0.8125, [245,0,170], [245,0,170] ],
- [0.875, [223,180,225], [223,180,225] ],
- [0.9375, [255,255,255], [255,255, 255]]
-
- ]),
-
- default: colormap([
- [0, [45,1,121], [25,1,137] ],
- [0.125, [25,1,137], [0,6,156] ],
- [0.1875, [0,6,156], [7,41,172] ],
- [0.25, [7,41,172], [22,84,187] ],
- [0.3125, [22,84,187], [25,125,194] ],
- [0.375, [25,125,194], [26,177,197] ],
- [0.4375, [26,177,197], [23,199,193] ],
- [0.47, [23,199,193], [25, 200,170] ],
- [0.50, [25, 200,170], [21,209,27] ],
- [0.5625, [21,209,27], [108,215,18] ],
- [0.625, [108,215,18], [166,218,19] ],
- [0.6875, [166,218,19], [206,221,20] ],
- [0.75, [206,221,20], [222,213,19 ] ],
- [0.7813, [222,213,19], [222, 191, 19]],
- [0.8125, [222, 191, 19], [227,133,17] ],
- [0.875, [227,133,17], [231,83,16] ],
- [0.9375, [231,83,16], [220,61,48] ]
-
- ]),
-
-
- fastie: colormap([
- [0, [255, 255, 255], [0, 0, 0] ],
- [0.167, [0, 0, 0], [255, 255, 255] ],
- [0.33, [255, 255, 255], [0, 0, 0] ],
- [0.5, [0, 0, 0], [140, 140, 255] ],
- [0.55, [140, 140, 255], [0, 255, 0] ],
- [0.63, [0, 255, 0], [255, 255, 0] ],
- [0.75, [255, 255, 0], [255, 0, 0] ],
- [0.95, [255, 0, 0], [255, 0, 255] ]
- ]),
-
-
- stretched: colormap([
- [0, [0, 0, 255], [0, 0, 255] ],
- [0.1, [0, 0, 255], [38, 195, 195] ],
- [0.5, [0, 150, 0], [255, 255, 0] ],
- [0.7, [255, 255, 0], [255, 50, 50] ],
- [0.9, [255, 50, 50], [255, 50, 50] ]
- ])
-
+/*
+ * Accepts a value from 0-255 and returns the new color-mapped pixel
+ * from a lookup table, which can be specified as an array of [begin, end]
+ * gradients, where begin and end are represented as [r, g, b] colors. In
+ * combination, a lookup table which maps values from 0 - 255 smoothly from black to white looks like:
+ * [
+ * [0, [0, 0, 0], [255, 255, 255]],
+ * [1, [255, 255, 255], [255, 255, 255]]
+ * ]
+ *
+ * Adapted from bgamari's work in Infragram: https://github.com/p-v-o-s/infragram-js/commit/346c97576a07b71a55671d17e0153b7df74e803b
+ */
+
+module.exports = function Colormap(value, options) {
+ options.colormap = options.colormap || colormaps.default;
+ // if a lookup table is provided as an array:
+ if(typeof(options.colormap) == "object")
+ colormapFunction = colormap(options.colormap);
+ // if a stored colormap is named with a string like "fastie":
+ else if(colormaps.hasOwnProperty(options.colormap))
+ colormapFunction = colormaps[options.colormap];
+ else colormapFunction = colormaps.default;
+ return colormapFunction(value / 255.00);
+}
+
+function colormap(segments) {
+ return function(x) {
+ var i, result, x0, x1, xstart, y0, y1, _i, _j, _len, _ref, _ref1, _ref2, _ref3;
+ _ref = [0, 0], y0 = _ref[0], y1 = _ref[1];
+ _ref1 = [segments[0][0], 1], x0 = _ref1[0], x1 = _ref1[1];
+ if (x < x0) {
+ return y0;
+ }
+ for (i = _i = 0, _len = segments.length; _i < _len; i = ++_i) {
+ _ref2 = segments[i], xstart = _ref2[0], y0 = _ref2[1], y1 = _ref2[2];
+ x0 = xstart;
+ if (i === segments.length - 1) {
+ x1 = 1;
+ break;
+ }
+ x1 = segments[i + 1][0];
+ if ((xstart <= x && x < x1)) {
+ break;
+ }
+ }
+ result = [];
+ for (i = _j = 0, _ref3 = y0.length; 0 <= _ref3 ? _j < _ref3 : _j > _ref3; i = 0 <= _ref3 ? ++_j : --_j) {
+ result[i] = (x - x0) / (x1 - x0) * (y1[i] - y0[i]) + y0[i];
+ }
+ return result;
+ };
+};
+
+var colormaps = {
+ greyscale: colormap([
+ [0, [0, 0, 0], [255, 255, 255] ],
+ [1, [255, 255, 255], [255, 255, 255] ]
+ ]),
+
+ bluwhtgrngis: colormap([
+ [0, [6,23,86], [6,25, 84] ],
+ [0.0625, [6,25,84], [6,25, 84] ],//1
+ [0.125, [6,25,84], [6,25, 84] ],//2
+ [0.1875, [6,25,84], [6,25, 84] ],
+ [0.25, [6,25,84], [6,25,84] ],
+ [0.3125, [6,25,84], [9,24, 84] ],//5
+ [0.3438, [9,24, 84], [119,120,162] ],//5
+ [0.375, [119,129,162],[249,250,251] ], //6
+ [0.406, [249,250,251],[255,255,255] ], //6.5
+ [0.4375, [255,255,255],[255,255,255] ], //7 white
+ [0.50, [255,255,255],[214,205,191] ],//8
+ [0.52, [214,205,191],[178,175,96] ],//8.2
+ [0.5625, [178,175,96], [151,176,53] ],//9
+ [0.593, [151,176,53], [146,188,12] ],//9.5
+ [0.625, [146,188,12], [96,161,1] ], //10
+ [0.6875, [96,161,1], [30,127,3] ],//11
+ [0.75, [30,127,3], [0,99,1] ],//12
+ [0.8125, [0,99,1], [0,74,1] ],//13
+ [0.875, [0,74,1], [0,52, 0] ],//14
+ [0.9375, [0,52, 0], [0,34,0] ], //15
+ [0.968, [0,34,0], [68,70,67] ] //16
+ ]),
+
+
+ brntogrn: colormap([
+ [0, [110,12,3], [118,6,1] ],
+ [0.0625, [118,6,1], [141,19,6] ],
+ [0.125, [141,19,6], [165,35,13] ],
+ [0.1875, [165,35,13], [177,59,25] ],
+ [0.2188, [177,59,25], [192,91,36] ],
+ [0.25, [192,91,36], [214, 145, 76] ],
+ [0.3125, [214,145,76], [230,183,134] ],
+ [0.375, [230,183,134],[243, 224, 194]],
+ [0.4375, [243,224,194],[250,252,229] ],
+ [0.50, [250,252,229],[217,235,185] ],
+ [0.5625, [217,235,185],[184,218,143] ],
+ [0.625, [184,218,143],[141,202,89] ],
+ [0.6875, [141,202,89], [80,176,61] ],
+ [0.75, [80,176,61], [0, 147, 32] ],
+ [0.8125, [0,147,32], [1, 122, 22] ],
+ [0.875, [1,122,22], [0, 114, 19] ],
+ [0.90, [0,114,19], [0,105,18] ],
+ [0.9375, [0,105,18], [7,70,14] ]
+
+ ]),
+
+
+ blutoredjet: colormap([
+ [0, [0,0,140], [1,1,186] ],
+ [0.0625, [1,1,186], [0,1,248] ],
+ [0.125, [0,1,248], [0,70,254] ],
+ [0.1875, [0,70,254], [0,130,255] ],
+ [0.25, [0,130,255], [2,160,255] ],
+ [0.2813, [2,160,255], [0,187,255] ], //inset
+ [0.3125, [0,187,255], [6,250,255] ],
+ // [0.348, [0,218,255], [8,252,251] ],//inset
+ [0.375, [8,252,251], [27,254,228] ],
+ [0.406, [27,254,228], [70,255,187] ], //insert
+ [0.4375, [70,255,187], [104,254,151]],
+ [0.47, [104,254,151],[132,255,19] ],//insert
+ [0.50, [132,255,19], [195,255,60] ],
+ [0.5625, [195,255,60], [231,254,25] ],
+ [0.5976, [231,254,25], [253,246,1] ],//insert
+ [0.625, [253,246,1], [252,210,1] ], //yellow
+ [0.657, [252,210,1], [255,183,0] ],//insert
+ [0.6875, [255,183,0], [255,125,2] ],
+ [0.75, [255,125,2], [255,65, 1] ],
+ [0.8125, [255,65, 1], [247, 1, 1] ],
+ [0.875, [247,1,1], [200, 1, 3] ],
+ [0.9375, [200,1,3], [122, 3, 2] ]
+
+ ]),
+
+
+ colors16: colormap([
+ [0, [0,0,0], [0,0,0] ],
+ [0.0625, [3,1,172], [3,1,172] ],
+ [0.125, [3,1,222], [3,1, 222] ],
+ [0.1875, [0,111,255], [0,111,255] ],
+ [0.25, [3,172,255], [3,172,255] ],
+ [0.3125, [1,226,255], [1,226,255] ],
+ [0.375, [2,255,0], [2,255,0] ],
+ [0.4375, [198,254,0], [190,254,0] ],
+ [0.50, [252,255,0], [252,255,0] ],
+ [0.5625, [255,223,3], [255,223,3] ],
+ [0.625, [255,143,3], [255,143,3] ],
+ [0.6875, [255,95,3], [255,95,3] ],
+ [0.75, [242,0,1], [242,0,1] ],
+ [0.8125, [245,0,170], [245,0,170] ],
+ [0.875, [223,180,225], [223,180,225] ],
+ [0.9375, [255,255,255], [255,255, 255]]
+
+ ]),
+
+ default: colormap([
+ [0, [45,1,121], [25,1,137] ],
+ [0.125, [25,1,137], [0,6,156] ],
+ [0.1875, [0,6,156], [7,41,172] ],
+ [0.25, [7,41,172], [22,84,187] ],
+ [0.3125, [22,84,187], [25,125,194] ],
+ [0.375, [25,125,194], [26,177,197] ],
+ [0.4375, [26,177,197], [23,199,193] ],
+ [0.47, [23,199,193], [25, 200,170] ],
+ [0.50, [25, 200,170], [21,209,27] ],
+ [0.5625, [21,209,27], [108,215,18] ],
+ [0.625, [108,215,18], [166,218,19] ],
+ [0.6875, [166,218,19], [206,221,20] ],
+ [0.75, [206,221,20], [222,213,19 ] ],
+ [0.7813, [222,213,19], [222, 191, 19]],
+ [0.8125, [222, 191, 19], [227,133,17] ],
+ [0.875, [227,133,17], [231,83,16] ],
+ [0.9375, [231,83,16], [220,61,48] ]
+
+ ]),
+
+
+ fastie: colormap([
+ [0, [255, 255, 255], [0, 0, 0] ],
+ [0.167, [0, 0, 0], [255, 255, 255] ],
+ [0.33, [255, 255, 255], [0, 0, 0] ],
+ [0.5, [0, 0, 0], [140, 140, 255] ],
+ [0.55, [140, 140, 255], [0, 255, 0] ],
+ [0.63, [0, 255, 0], [255, 255, 0] ],
+ [0.75, [255, 255, 0], [255, 0, 0] ],
+ [0.95, [255, 0, 0], [255, 0, 255] ]
+ ]),
+
+
+ stretched: colormap([
+ [0, [0, 0, 255], [0, 0, 255] ],
+ [0.1, [0, 0, 255], [38, 195, 195] ],
+ [0.5, [0, 150, 0], [255, 255, 0] ],
+ [0.7, [255, 255, 0], [255, 50, 50] ],
+ [0.9, [255, 50, 50], [255, 50, 50] ]
+ ])
+
}
},{}],181:[function(require,module,exports){
-module.exports = function Colormap(options,UI) {
-
- var output;
-
- // This function is called on every draw.
- function draw(input,callback,progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- var combined = (r + g + b) / 3.000;
- var res = require('./Colormap')(combined, options);
- return [res[0], res[1], res[2], 255];
- }
-
- function output(image,datauri,mimetype){
-
- // This output is accessible 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,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+module.exports = function Colormap(options,UI) {
+
+ var output;
+
+ // This function is called on every draw.
+ function draw(input,callback,progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ var combined = (r + g + b) / 3.000;
+ var res = require('./Colormap')(combined, options);
+ return [res[0], res[1], res[2], 255];
+ }
+
+ function output(image,datauri,mimetype){
+
+ // This output is accessible 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,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"./Colormap":180}],182:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":181,"./info.json":183,"dup":162}],183:[function(require,module,exports){
-module.exports={
- "name": "Colormap",
- "description": "Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.\n\nFor example, 'cooler' colors like blue could represent low values, while 'hot' colors like red could represent high values.",
- "inputs": {
- "colormap": {
- "type": "select",
- "desc": "Name of the Colormap",
- "default": "default",
- "values": ["default","greyscale","bluwhtgrngis","stretched","fastie","brntogrn","blutoredjet","colors16"]
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Colormap",
+ "description": "Maps brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.\n\nFor example, 'cooler' colors like blue could represent low values, while 'hot' colors like red could represent high values.",
+ "inputs": {
+ "colormap": {
+ "type": "select",
+ "desc": "Name of the Colormap",
+ "default": "default",
+ "values": ["default","greyscale","bluwhtgrngis","stretched","fastie","brntogrn","blutoredjet","colors16"]
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],184:[function(require,module,exports){
-var _ = require('lodash');
-module.exports = exports = function(pixels , contrast){
- let oldpix = _.cloneDeep(pixels);
- contrast = Number(contrast)
- if (contrast < -100) contrast = -100;
- if (contrast > 100) contrast = 100;
- contrast = (100.0 + contrast) / 100.0;
- contrast *= contrast;
-
- for (let i = 0; i < oldpix.shape[0]; i++) {
- for (let j = 0; j < oldpix.shape[1]; j++) {
- var r = oldpix.get(i,j,0)/255.0;
- r -= 0.5;
- r *= contrast;
- r += 0.5;
- r *= 255;
- if (r < 0) r = 0;
- if (r > 255) r = 255;
-
-
- var g = oldpix.get(i,j,1)/255.0;
- g -= 0.5;
- g *= contrast;
- g += 0.5;
- g *= 255;
- if (g < 0) g = 0;
- if (g > 255) g = 255;
-
-
-
- var b = oldpix.get(i,j,2)/255.0;
- b -= 0.5;
- b *= contrast;
- b += 0.5;
- b *= 255;
- if (b < 0) b = 0;
- if (b > 255) b = 255;
-
-
- pixels.set(i, j, 0, r);
- pixels.set(i, j, 1, g);
- pixels.set(i, j, 2, b);
-
- }
- }
- return pixels;
+var _ = require('lodash');
+module.exports = exports = function(pixels , contrast){
+ let oldpix = _.cloneDeep(pixels);
+ contrast = Number(contrast)
+ if (contrast < -100) contrast = -100;
+ if (contrast > 100) contrast = 100;
+ contrast = (100.0 + contrast) / 100.0;
+ contrast *= contrast;
+
+ for (let i = 0; i < oldpix.shape[0]; i++) {
+ for (let j = 0; j < oldpix.shape[1]; j++) {
+ var r = oldpix.get(i,j,0)/255.0;
+ r -= 0.5;
+ r *= contrast;
+ r += 0.5;
+ r *= 255;
+ if (r < 0) r = 0;
+ if (r > 255) r = 255;
+
+
+ var g = oldpix.get(i,j,1)/255.0;
+ g -= 0.5;
+ g *= contrast;
+ g += 0.5;
+ g *= 255;
+ if (g < 0) g = 0;
+ if (g > 255) g = 255;
+
+
+
+ var b = oldpix.get(i,j,2)/255.0;
+ b -= 0.5;
+ b *= contrast;
+ b += 0.5;
+ b *= 255;
+ if (b < 0) b = 0;
+ if (b > 255) b = 255;
+
+
+ pixels.set(i, j, 0, r);
+ pixels.set(i, j, 1, g);
+ pixels.set(i, j, 2, b);
+
+ }
+ }
+ return pixels;
}
},{"lodash":75}],185:[function(require,module,exports){
-// /*
-// * Changes the Image Contrast
-// */
-
-module.exports = function Contrast(options, UI) {
-
- options.contrast = options.contrast || 70
- var output;
-
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- return [r, g, b, a]
- }
-
- function extraManipulation(pixels) {
- pixels = require('./Contrast')(pixels, options.contrast)
- return pixels
- }
-
- function output(image, datauri, mimetype) {
-
- // This output is accessible by Image Sequencer
- step.output = { src: datauri, format: mimetype };
-
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- callback: callback
- });
-
- }
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+// /*
+// * Changes the Image Contrast
+// */
+
+module.exports = function Contrast(options, UI) {
+
+ options.contrast = options.contrast || 70
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ return [r, g, b, a]
+ }
+
+ function extraManipulation(pixels) {
+ pixels = require('./Contrast')(pixels, options.contrast)
+ return pixels
+ }
+
+ function output(image, datauri, mimetype) {
+
+ // This output is accessible by Image Sequencer
+ step.output = { src: datauri, format: mimetype };
+
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ callback: callback
+ });
+
+ }
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"./Contrast":184}],186:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":185,"./info.json":187,"dup":162}],187:[function(require,module,exports){
-module.exports={
- "name": "Contrast",
- "description": "Change the contrast of the image by given value",
- "inputs": {
- "contrast": {
- "type": "range",
- "desc": "contrast for the new image, typically -100 to 100",
- "default": "70",
- "min": "-100",
- "max": "100",
- "step": "1"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Contrast",
+ "description": "Change the contrast of the image by given value",
+ "inputs": {
+ "contrast": {
+ "type": "range",
+ "desc": "contrast for the new image, typically -100 to 100",
+ "default": "70",
+ "min": "-100",
+ "max": "100",
+ "step": "1"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],188:[function(require,module,exports){
-var _ = require('lodash');
-module.exports = exports = function(pixels, constantFactor, kernelValues){
- let kernel = kernelGenerator(constantFactor, kernelValues), oldpix = _.cloneDeep(pixels);
- kernel = flipKernel(kernel);
-
- for (let i = 0; i < pixels.shape[0]; i++) {
- for (let j = 0; j < pixels.shape[1]; j++) {
- let neighboutPos = getNeighbouringPixelPositions([i, j]);
- let acc = [0.0, 0.0, 0.0, 0.0];
- for (let a = 0; a < kernel.length; a++) {
- for (let b = 0; b < kernel.length; b++) {
- acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]);
- acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]);
- acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]);
- acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]);
- }
- }
- acc[0] = acc[0]%255;
- acc[1] = acc[1]%255;
- acc[2] = acc[2]%255;
- pixels.set(i, j, 0, acc[0]);
- pixels.set(i, j, 1, acc[1]);
- pixels.set(i, j, 2, acc[2]);
- }
- }
- return pixels;
-
-
- function kernelGenerator(constantFactor, kernelValues){
- kernelValues = kernelValues.split(" ");
- for(i = 0 ; i < 9; i++){
- kernelValues[i] = Number(kernelValues[i]) * constantFactor;
- }
- let k = 0;
- let arr = [];
- for(i = 0; i < 3; i++){
- let columns = [];
- for(j = 0; j < 3; j++){
- columns.push(kernelValues[k]);
- k += 1;
- }
- arr.push(columns);
- }
- return arr;
- }
-
- function getNeighbouringPixelPositions(pixelPosition) {
- let x = pixelPosition[0], y = pixelPosition[1], result = [];
-
- for (let i = -1; i <= 1; i++) {
- let arr = [];
- for (let j = -1; j <= 1; j++)
- arr.push([x + i, y + j]);
-
- result.push(arr);
- }
- return result;
- }
-
- function flipKernel(kernel) {
- let result = [];
- for (let i = kernel.length - 1; i >= 0; i--) {
- let arr = [];
- for (let j = kernel[i].length - 1; j >= 0; j--) {
- arr.push(kernel[i][j]);
- }
- result.push(arr);
- }
- return result;
- }
+var _ = require('lodash');
+module.exports = exports = function(pixels, constantFactor, kernelValues){
+ let kernel = kernelGenerator(constantFactor, kernelValues), oldpix = _.cloneDeep(pixels);
+ kernel = flipKernel(kernel);
+
+ for (let i = 0; i < pixels.shape[0]; i++) {
+ for (let j = 0; j < pixels.shape[1]; j++) {
+ let neighboutPos = getNeighbouringPixelPositions([i, j]);
+ let acc = [0.0, 0.0, 0.0, 0.0];
+ for (let a = 0; a < kernel.length; a++) {
+ for (let b = 0; b < kernel.length; b++) {
+ acc[0] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 0) * kernel[a][b]);
+ acc[1] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 1) * kernel[a][b]);
+ acc[2] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 2) * kernel[a][b]);
+ acc[3] += (oldpix.get(neighboutPos[a][b][0], neighboutPos[a][b][1], 3) * kernel[a][b]);
+ }
+ }
+ acc[0] = acc[0]%255;
+ acc[1] = acc[1]%255;
+ acc[2] = acc[2]%255;
+ pixels.set(i, j, 0, acc[0]);
+ pixels.set(i, j, 1, acc[1]);
+ pixels.set(i, j, 2, acc[2]);
+ }
+ }
+ return pixels;
+
+
+ function kernelGenerator(constantFactor, kernelValues){
+ kernelValues = kernelValues.split(" ");
+ for(i = 0 ; i < 9; i++){
+ kernelValues[i] = Number(kernelValues[i]) * constantFactor;
+ }
+ let k = 0;
+ let arr = [];
+ for(i = 0; i < 3; i++){
+ let columns = [];
+ for(j = 0; j < 3; j++){
+ columns.push(kernelValues[k]);
+ k += 1;
+ }
+ arr.push(columns);
+ }
+ return arr;
+ }
+
+ function getNeighbouringPixelPositions(pixelPosition) {
+ let x = pixelPosition[0], y = pixelPosition[1], result = [];
+
+ for (let i = -1; i <= 1; i++) {
+ let arr = [];
+ for (let j = -1; j <= 1; j++)
+ arr.push([x + i, y + j]);
+
+ result.push(arr);
+ }
+ return result;
+ }
+
+ function flipKernel(kernel) {
+ let result = [];
+ for (let i = kernel.length - 1; i >= 0; i--) {
+ let arr = [];
+ for (let j = kernel[i].length - 1; j >= 0; j--) {
+ arr.push(kernel[i][j]);
+ }
+ result.push(arr);
+ }
+ return result;
+ }
}
},{"lodash":75}],189:[function(require,module,exports){
-module.exports = function Convolution(options, UI) {
-
- options.kernelValues = options.kernelValues || '1 1 1 1 1 1 1 1 1';
- options.constantFactor = options.constantFactor || 1/9;
- var output;
-
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- return [r, g, b, a]
- }
-
- function extraManipulation(pixels) {
- pixels = require('./Convolution')(pixels, options.constantFactor, options.kernelValues)
- return pixels
- }
-
- function output(image, datauri, mimetype) {
-
- step.output = { src: datauri, format: mimetype };
-
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- callback: callback
- });
-
- }
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+module.exports = function Convolution(options, UI) {
+
+ options.kernelValues = options.kernelValues || '1 1 1 1 1 1 1 1 1';
+ options.constantFactor = options.constantFactor || 1/9;
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ return [r, g, b, a]
+ }
+
+ function extraManipulation(pixels) {
+ pixels = require('./Convolution')(pixels, options.constantFactor, options.kernelValues)
+ return pixels
+ }
+
+ function output(image, datauri, mimetype) {
+
+ step.output = { src: datauri, format: mimetype };
+
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ callback: callback
+ });
+
+ }
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"./Convolution":188}],190:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":189,"./info.json":191,"dup":162}],191:[function(require,module,exports){
-module.exports={
- "name": "Convolution",
- "description": "Image Convolution using a given 3x3 kernel matrix Read more",
- "inputs": {
- "constantFactor":{
- "type": "Float",
- "desc": "a constant factor, multiplies all the kernel values by that factor",
- "default": 0.1111,
- "placeholder": 0.1111
- },
-
- "kernelValues": {
- "type": "String",
- "desc": "nine space separated numbers representing the kernel values in left to right and top to bottom format.",
- "default": "1 1 1 1 1 1 1 1 1",
- "placeholder": "1 1 1 1 1 1 1 1 1"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Convolution",
+ "description": "Image Convolution using a given 3x3 kernel matrix Read more",
+ "inputs": {
+ "constantFactor":{
+ "type": "Float",
+ "desc": "a constant factor, multiplies all the kernel values by that factor",
+ "default": 0.1111,
+ "placeholder": 0.1111
+ },
+
+ "kernelValues": {
+ "type": "String",
+ "desc": "nine space separated numbers representing the kernel values in left to right and top to bottom format.",
+ "default": "1 1 1 1 1 1 1 1 1",
+ "placeholder": "1 1 1 1 1 1 1 1 1"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],192:[function(require,module,exports){
(function (Buffer){
-module.exports = function Crop(input,options,callback) {
-
- var getPixels = require('get-pixels'),
- savePixels = require('save-pixels');
-
- options.x = parseInt(options.x) || 0;
- options.y = parseInt(options.y) || 0;
-
- getPixels(input.src,function(err,pixels){
- options.w = parseInt(options.w) || Math.floor(pixels.shape[0]);
- options.h = parseInt(options.h) || Math.floor(pixels.shape[1]);
- options.backgroundColor = options.backgroundColor || '255 255 255 255';
- var ox = options.x;
- var oy = options.y;
- var w = options.w;
- var h = options.h;
- var iw = pixels.shape[0]; //Width of Original Image
- var ih = pixels.shape[1]; //Height of Original Image
- var backgroundArray = [];
- backgroundColor = options.backgroundColor.split(" ");
- for(var i = 0; i < w ; i++){
- backgroundArray = backgroundArray.concat([backgroundColor[0],backgroundColor[1],backgroundColor[2],backgroundColor[3]]);
- }
- var newarray = new Uint8Array(4*w*h);
- for (var n = oy; n < oy + h; n++) {
- if(nInfragrammar.",
- "inputs": {
- "red": {
- "type": "input",
- "desc": "Expression to return for red channel with R, G, B, and A inputs",
- "default": "r"
- },
- "green": {
- "type": "input",
- "desc": "Expression to return for green channel with R, G, B, and A inputs",
- "default": "g"
- },
- "blue": {
- "type": "input",
- "desc": "Expression to return for blue channel with R, G, B, and A inputs",
- "default": "b"
- },
- "monochrome (fallback)": {
- "type": "input",
- "desc": "Expression to return with R, G, B, and A inputs; fallback for other channels if none provided",
- "default": "r + g + b"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Dynamic",
+ "description": "A module which accepts JavaScript math expressions to produce each color channel based on the original image's color. See Infragrammar.",
+ "inputs": {
+ "red": {
+ "type": "input",
+ "desc": "Expression to return for red channel with R, G, B, and A inputs",
+ "default": "r"
+ },
+ "green": {
+ "type": "input",
+ "desc": "Expression to return for green channel with R, G, B, and A inputs",
+ "default": "g"
+ },
+ "blue": {
+ "type": "input",
+ "desc": "Expression to return for blue channel with R, G, B, and A inputs",
+ "default": "b"
+ },
+ "monochrome (fallback)": {
+ "type": "input",
+ "desc": "Expression to return with R, G, B, and A inputs; fallback for other channels if none provided",
+ "default": "r + g + b"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],207:[function(require,module,exports){
-const _ = require('lodash')
-
-//define kernels for the sobel filter
-const kernelx = [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]],
- kernely = [[-1, -2, -1], [0, 0, 0], [1, 2, 1]];
-
-module.exports = function(pixels, highThresholdRatio, lowThresholdRatio, inBrowser) {
- let angles = [], mags = [], strongEdgePixels = [], weakEdgePixels = [], notInUI = !inBrowser;
- for (var x = 0; x < pixels.shape[0]; x++) {
- angles.push([]);
- mags.push([]);
- for (var y = 0; y < pixels.shape[1]; y++) {
- var result = changePixel(
- pixels,
- pixels.get(x, y, 0),
- pixels.get(x, y, 3),
- x,
- y
- );
- let pixel = result.pixel;
-
- pixels.set(x, y, 0, pixel[0]);
- pixels.set(x, y, 1, pixel[1]);
- pixels.set(x, y, 2, pixel[2]);
- pixels.set(x, y, 3, pixel[3]);
-
- mags.slice(-1)[0].push(pixel[3]);
- angles.slice(-1)[0].push(result.angle);
- }
- }
- nonMaxSupress(pixels, mags, angles);
- doubleThreshold(pixels, highThresholdRatio, lowThresholdRatio, mags, strongEdgePixels, weakEdgePixels);
- return pixels;
-}
-
-//changepixel function that convolutes every pixel (sobel filter)
-function changePixel(pixels, val, a, x, y) {
- let magX = 0.0;
- for (let a = 0; a < 3; a++) {
- for (let b = 0; b < 3; b++) {
-
- let xn = x + a - 1;
- let yn = y + b - 1;
-
- magX += pixels.get(xn, yn, 0) * kernelx[a][b];
- }
- }
- let magY = 0.0;
- for (let a = 0; a < 3; a++) {
- for (let b = 0; b < 3; b++) {
-
- let xn = x + a - 1;
- let yn = y + b - 1;
-
- magY += pixels.get(xn, yn, 0) * kernely[a][b];
- }
- }
- let mag = Math.sqrt(Math.pow(magX, 2) + Math.pow(magY, 2));
- let angle = Math.atan2(magY, magX);
- return {
- pixel:
- [val, val, val, mag],
- angle: angle
- };
-}
-
-//Non Maximum Supression without interpolation
-function nonMaxSupress(pixels, mags, angles) {
-
- angles = angles.map((arr) => arr.map(convertToDegrees));
-
- for (let i = 1; i < pixels.shape[0] - 1; i++) {
- for (let j = 1; j < pixels.shape[1] - 1; j++) {
-
- let angle = angles[i][j];
- let pixel = pixels.get(i, j);
-
- if ((angle >= -22.5 && angle <= 22.5) ||
- (angle < -157.5 && angle >= -180))
-
- if ((mags[i][j] >= mags[i][j + 1]) &&
- (mags[i][j] >= mags[i][j - 1]))
- pixels.set(i, j, 3, mags[i][j]);
- else
- pixels.set(i, j, 3, 0);
-
- else if ((angle >= 22.5 && angle <= 67.5) ||
- (angle < -112.5 && angle >= -157.5))
-
- if ((mags[i][j] >= mags[i + 1][j + 1]) &&
- (mags[i][j] >= mags[i - 1][j - 1]))
- pixels.set(i, j, 3, mags[i][j]);
- else
- pixels.set(i, j, 3, 0);
-
- else if ((angle >= 67.5 && angle <= 112.5) ||
- (angle < -67.5 && angle >= -112.5))
-
- if ((mags[i][i] >= mags[i + 1][j]) &&
- (mags[i][j] >= mags[i][j]))
- pixels.set(i, j, 3, mags[i][j]);
- else
- pixels.set(i, j, 3, 0);
-
- else if ((angle >= 112.5 && angle <= 157.5) ||
- (angle < -22.5 && angle >= -67.5))
-
- if ((mags[i][j] >= mags[i + 1][j - 1]) &&
- (mags[i][j] >= mags[i - 1][j + 1]))
- pixels.set(i, j, 3, mags[i][j]);
- else
- pixels.set(i, j, 3, 0);
-
- }
- }
-}
-//Converts radians to degrees
-var convertToDegrees = radians => (radians * 180) / Math.PI;
-
-//Finds the max value in a 2d array like mags
-var findMaxInMatrix = arr => Math.max(...arr.map(el => el.map(val => !!val ? val : 0)).map(el => Math.max(...el)));
-
-//Applies the double threshold to the image
-function doubleThreshold(pixels, highThresholdRatio, lowThresholdRatio, mags, strongEdgePixels, weakEdgePixels) {
-
- const highThreshold = findMaxInMatrix(mags) * highThresholdRatio;
- const lowThreshold = highThreshold * lowThresholdRatio;
-
- for (let i = 0; i < pixels.shape[0]; i++) {
- for (let j = 0; j < pixels.shape[1]; j++) {
- let pixelPos = [i, j];
-
- mags[i][j] > lowThreshold
- ? mags[i][j] > highThreshold
- ? strongEdgePixels.push(pixelPos)
- : weakEdgePixels.push(pixelPos)
- : pixels.set(i, j, 3, 0);
- }
- }
-
- strongEdgePixels.forEach(pix => pixels.set(pix[0], pix[1], 3, 255));
-}
-
-// hysteresis edge tracking algorithm -- not working as of now
-/* function hysteresis(pixels) {
- function getNeighbouringPixelPositions(pixelPosition) {
- let x = pixelPosition[0], y = pixelPosition[1]
- return [[x + 1, y + 1],
- [x + 1, y],
- [x + 1, y - 1],
- [x, y + 1],
- [x, y - 1],
- [x - 1, y + 1],
- [x - 1, y],
- [x - 1, y - 1]]
- }
-
- //This can potentially be improved see https://en.wikipedia.org/wiki/Connected-component_labeling
- for (weakPixel in weakEdgePixels) {
- let neighbourPixels = getNeighbouringPixelPositions(weakEdgePixels[weakPixel])
- for (pixel in neighbourPixels) {
- if (strongEdgePixels.find(el => _.isEqual(el, neighbourPixels[pixel]))) {
- pixels.set(weakPixel[0], weakPixel[1], 3, 255)
- weakEdgePixels.splice(weakPixel, weakPixel)
- break
- }
- }
- }
- weakEdgePixels.forEach(pix => pixels.set(pix[0], pix[1], 3, 0))
- return pixels
-} */
-
-
-
+const _ = require('lodash')
+
+//define kernels for the sobel filter
+const kernelx = [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]],
+ kernely = [[-1, -2, -1], [0, 0, 0], [1, 2, 1]];
+
+module.exports = function(pixels, highThresholdRatio, lowThresholdRatio, inBrowser) {
+ let angles = [], mags = [], strongEdgePixels = [], weakEdgePixels = [], notInUI = !inBrowser;
+ for (var x = 0; x < pixels.shape[0]; x++) {
+ angles.push([]);
+ mags.push([]);
+ for (var y = 0; y < pixels.shape[1]; y++) {
+ var result = changePixel(
+ pixels,
+ pixels.get(x, y, 0),
+ pixels.get(x, y, 3),
+ x,
+ y
+ );
+ let pixel = result.pixel;
+
+ pixels.set(x, y, 0, pixel[0]);
+ pixels.set(x, y, 1, pixel[1]);
+ pixels.set(x, y, 2, pixel[2]);
+ pixels.set(x, y, 3, pixel[3]);
+
+ mags.slice(-1)[0].push(pixel[3]);
+ angles.slice(-1)[0].push(result.angle);
+ }
+ }
+ nonMaxSupress(pixels, mags, angles);
+ doubleThreshold(pixels, highThresholdRatio, lowThresholdRatio, mags, strongEdgePixels, weakEdgePixels);
+ return pixels;
+}
+
+//changepixel function that convolutes every pixel (sobel filter)
+function changePixel(pixels, val, a, x, y) {
+ let magX = 0.0;
+ for (let a = 0; a < 3; a++) {
+ for (let b = 0; b < 3; b++) {
+
+ let xn = x + a - 1;
+ let yn = y + b - 1;
+
+ magX += pixels.get(xn, yn, 0) * kernelx[a][b];
+ }
+ }
+ let magY = 0.0;
+ for (let a = 0; a < 3; a++) {
+ for (let b = 0; b < 3; b++) {
+
+ let xn = x + a - 1;
+ let yn = y + b - 1;
+
+ magY += pixels.get(xn, yn, 0) * kernely[a][b];
+ }
+ }
+ let mag = Math.sqrt(Math.pow(magX, 2) + Math.pow(magY, 2));
+ let angle = Math.atan2(magY, magX);
+ return {
+ pixel:
+ [val, val, val, mag],
+ angle: angle
+ };
+}
+
+//Non Maximum Supression without interpolation
+function nonMaxSupress(pixels, mags, angles) {
+
+ angles = angles.map((arr) => arr.map(convertToDegrees));
+
+ for (let i = 1; i < pixels.shape[0] - 1; i++) {
+ for (let j = 1; j < pixels.shape[1] - 1; j++) {
+
+ let angle = angles[i][j];
+ let pixel = pixels.get(i, j);
+
+ if ((angle >= -22.5 && angle <= 22.5) ||
+ (angle < -157.5 && angle >= -180))
+
+ if ((mags[i][j] >= mags[i][j + 1]) &&
+ (mags[i][j] >= mags[i][j - 1]))
+ pixels.set(i, j, 3, mags[i][j]);
+ else
+ pixels.set(i, j, 3, 0);
+
+ else if ((angle >= 22.5 && angle <= 67.5) ||
+ (angle < -112.5 && angle >= -157.5))
+
+ if ((mags[i][j] >= mags[i + 1][j + 1]) &&
+ (mags[i][j] >= mags[i - 1][j - 1]))
+ pixels.set(i, j, 3, mags[i][j]);
+ else
+ pixels.set(i, j, 3, 0);
+
+ else if ((angle >= 67.5 && angle <= 112.5) ||
+ (angle < -67.5 && angle >= -112.5))
+
+ if ((mags[i][i] >= mags[i + 1][j]) &&
+ (mags[i][j] >= mags[i][j]))
+ pixels.set(i, j, 3, mags[i][j]);
+ else
+ pixels.set(i, j, 3, 0);
+
+ else if ((angle >= 112.5 && angle <= 157.5) ||
+ (angle < -22.5 && angle >= -67.5))
+
+ if ((mags[i][j] >= mags[i + 1][j - 1]) &&
+ (mags[i][j] >= mags[i - 1][j + 1]))
+ pixels.set(i, j, 3, mags[i][j]);
+ else
+ pixels.set(i, j, 3, 0);
+
+ }
+ }
+}
+//Converts radians to degrees
+var convertToDegrees = radians => (radians * 180) / Math.PI;
+
+//Finds the max value in a 2d array like mags
+var findMaxInMatrix = arr => Math.max(...arr.map(el => el.map(val => !!val ? val : 0)).map(el => Math.max(...el)));
+
+//Applies the double threshold to the image
+function doubleThreshold(pixels, highThresholdRatio, lowThresholdRatio, mags, strongEdgePixels, weakEdgePixels) {
+
+ const highThreshold = findMaxInMatrix(mags) * highThresholdRatio;
+ const lowThreshold = highThreshold * lowThresholdRatio;
+
+ for (let i = 0; i < pixels.shape[0]; i++) {
+ for (let j = 0; j < pixels.shape[1]; j++) {
+ let pixelPos = [i, j];
+
+ mags[i][j] > lowThreshold
+ ? mags[i][j] > highThreshold
+ ? strongEdgePixels.push(pixelPos)
+ : weakEdgePixels.push(pixelPos)
+ : pixels.set(i, j, 3, 0);
+ }
+ }
+
+ strongEdgePixels.forEach(pix => pixels.set(pix[0], pix[1], 3, 255));
+}
+
+// hysteresis edge tracking algorithm -- not working as of now
+/* function hysteresis(pixels) {
+ function getNeighbouringPixelPositions(pixelPosition) {
+ let x = pixelPosition[0], y = pixelPosition[1]
+ return [[x + 1, y + 1],
+ [x + 1, y],
+ [x + 1, y - 1],
+ [x, y + 1],
+ [x, y - 1],
+ [x - 1, y + 1],
+ [x - 1, y],
+ [x - 1, y - 1]]
+ }
+
+ //This can potentially be improved see https://en.wikipedia.org/wiki/Connected-component_labeling
+ for (weakPixel in weakEdgePixels) {
+ let neighbourPixels = getNeighbouringPixelPositions(weakEdgePixels[weakPixel])
+ for (pixel in neighbourPixels) {
+ if (strongEdgePixels.find(el => _.isEqual(el, neighbourPixels[pixel]))) {
+ pixels.set(weakPixel[0], weakPixel[1], 3, 255)
+ weakEdgePixels.splice(weakPixel, weakPixel)
+ break
+ }
+ }
+ }
+ weakEdgePixels.forEach(pix => pixels.set(pix[0], pix[1], 3, 0))
+ return pixels
+} */
+
+
+
},{"lodash":75}],208:[function(require,module,exports){
-/*
-* Detect Edges in an Image
-*/
-module.exports = function edgeDetect(options, UI) {
-
- options.blur = options.blur || 2;
- options.highThresholdRatio = options.highThresholdRatio || 0.2;
- options.lowThresholdRatio = options.lowThresholdRatio || 0.15;
-
- var output;
-
- // The function which is called on every draw.
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
-
- // Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution
- function extraManipulation(pixels) {
- pixels = require('ndarray-gaussian-filter')(pixels, options.blur);
- pixels = require('./EdgeUtils')(pixels, options.highThresholdRatio, options.lowThresholdRatio, options.inBrowser);
- return pixels;
- }
-
- function changePixel(r, g, b, a) {
- return [(r + g + b) / 3, (r + g + b) / 3, (r + g + b) / 3, a];
- }
-
- function output(image, datauri, mimetype) {
-
- // This output is accessible by Image Sequencer
- step.output = { src: datauri, format: mimetype };
-
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: callback
- });
-
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+* Detect Edges in an Image
+*/
+module.exports = function edgeDetect(options, UI) {
+
+ options.blur = options.blur || 2;
+ options.highThresholdRatio = options.highThresholdRatio || 0.2;
+ options.lowThresholdRatio = options.lowThresholdRatio || 0.15;
+
+ var output;
+
+ // The function which is called on every draw.
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+
+ // Extra Manipulation function used as an enveloper for applying gaussian blur and Convolution
+ function extraManipulation(pixels) {
+ pixels = require('ndarray-gaussian-filter')(pixels, options.blur);
+ pixels = require('./EdgeUtils')(pixels, options.highThresholdRatio, options.lowThresholdRatio, options.inBrowser);
+ return pixels;
+ }
+
+ function changePixel(r, g, b, a) {
+ return [(r + g + b) / 3, (r + g + b) / 3, (r + g + b) / 3, a];
+ }
+
+ function output(image, datauri, mimetype) {
+
+ // This output is accessible by Image Sequencer
+ step.output = { src: datauri, format: mimetype };
+
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: callback
+ });
+
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"./EdgeUtils":207,"ndarray-gaussian-filter":80}],209:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":208,"./info.json":210,"dup":162}],210:[function(require,module,exports){
-module.exports={
- "name": "Detect Edges",
- "description": "This module detects edges using the Canny method, which first Gaussian blurs the image to reduce noise (amount of blur configurable in settings as `options.blur`), then applies a number of steps to highlight edges, resulting in a greyscale image where the brighter the pixel, the stronger the detected edge. Read more. ",
- "inputs": {
- "blur": {
- "type": "range",
- "desc": "Amount of gaussian blur(Less blur gives more detail, typically 0-5)",
- "default": "2",
- "min": "0",
- "max": "5",
- "step": "0.25"
- },
- "highThresholdRatio":{
- "type": "float",
- "desc": "The high threshold ratio for the image",
- "default": 0.2
- },
- "lowThresholdRatio": {
- "type": "float",
- "desc": "The low threshold value for the image",
- "default": 0.15
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Detect Edges",
+ "description": "This module detects edges using the Canny method, which first Gaussian blurs the image to reduce noise (amount of blur configurable in settings as `options.blur`), then applies a number of steps to highlight edges, resulting in a greyscale image where the brighter the pixel, the stronger the detected edge. Read more. ",
+ "inputs": {
+ "blur": {
+ "type": "range",
+ "desc": "Amount of gaussian blur(Less blur gives more detail, typically 0-5)",
+ "default": "2",
+ "min": "0",
+ "max": "5",
+ "step": "0.25"
+ },
+ "highThresholdRatio":{
+ "type": "float",
+ "desc": "The high threshold ratio for the image",
+ "default": 0.2
+ },
+ "lowThresholdRatio": {
+ "type": "float",
+ "desc": "The low threshold value for the image",
+ "default": 0.15
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],211:[function(require,module,exports){
-/*
- * Resolves Fisheye Effect
- */
-module.exports = function DoNothing(options,UI) {
-
- var output;
-
- require('fisheyegl');
-
- function draw(input,callback) {
-
- var step = this;
-
- if (!options.inBrowser) { // This module is only for browser
- this.output = input;
- callback();
- }
- else {
- // Create a canvas, if it doesn't already exist.
- if (!document.querySelector('#image-sequencer-canvas')) {
- var canvas = document.createElement('canvas');
- canvas.style.display = "none";
- canvas.setAttribute('id','image-sequencer-canvas');
- document.body.append(canvas);
- }
- else var canvas = document.querySelector('#image-sequencer-canvas');
-
- distorter = FisheyeGl({
- selector: "#image-sequencer-canvas"
- });
-
- // Parse the inputs
- options.a = parseFloat(options.a) || distorter.lens.a;
- options.b = parseFloat(options.b) || distorter.lens.b;
- options.Fx = parseFloat(options.Fx) || distorter.lens.Fx;
- options.Fy = parseFloat(options.Fy) || distorter.lens.Fy;
- options.scale = parseFloat(options.scale) || distorter.lens.scale;
- options.x = parseFloat(options.x) || distorter.fov.x;
- options.y = parseFloat(options.y) || distorter.fov.y;
-
- // Set fisheyegl inputs
- distorter.lens.a = options.a;
- distorter.lens.b = options.b;
- distorter.lens.Fx = options.Fx;
- distorter.lens.Fy = options.Fy;
- distorter.lens.scale = options.scale;
- distorter.fov.x = options.x;
- distorter.fov.y = options.y;
-
- // generate fisheyegl output
- distorter.setImage(input.src,function(){
-
- // this output is accessible to Image Sequencer
- step.output = {src: canvas.toDataURL(), format: input.format};
-
- // Tell Image Sequencer and UI that step has been drawn
- callback();
-
- });
-
- }
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+ * Resolves Fisheye Effect
+ */
+module.exports = function DoNothing(options,UI) {
+
+ var output;
+
+ require('fisheyegl');
+
+ function draw(input,callback) {
+
+ var step = this;
+
+ if (!options.inBrowser) { // This module is only for browser
+ this.output = input;
+ callback();
+ }
+ else {
+ // Create a canvas, if it doesn't already exist.
+ if (!document.querySelector('#image-sequencer-canvas')) {
+ var canvas = document.createElement('canvas');
+ canvas.style.display = "none";
+ canvas.setAttribute('id','image-sequencer-canvas');
+ document.body.append(canvas);
+ }
+ else var canvas = document.querySelector('#image-sequencer-canvas');
+
+ distorter = FisheyeGl({
+ selector: "#image-sequencer-canvas"
+ });
+
+ // Parse the inputs
+ options.a = parseFloat(options.a) || distorter.lens.a;
+ options.b = parseFloat(options.b) || distorter.lens.b;
+ options.Fx = parseFloat(options.Fx) || distorter.lens.Fx;
+ options.Fy = parseFloat(options.Fy) || distorter.lens.Fy;
+ options.scale = parseFloat(options.scale) || distorter.lens.scale;
+ options.x = parseFloat(options.x) || distorter.fov.x;
+ options.y = parseFloat(options.y) || distorter.fov.y;
+
+ // Set fisheyegl inputs
+ distorter.lens.a = options.a;
+ distorter.lens.b = options.b;
+ distorter.lens.Fx = options.Fx;
+ distorter.lens.Fy = options.Fy;
+ distorter.lens.scale = options.scale;
+ distorter.fov.x = options.x;
+ distorter.fov.y = options.y;
+
+ // generate fisheyegl output
+ distorter.setImage(input.src,function(){
+
+ // this output is accessible to Image Sequencer
+ step.output = {src: canvas.toDataURL(), format: input.format};
+
+ // Tell Image Sequencer and UI that step has been drawn
+ callback();
+
+ });
+
+ }
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"fisheyegl":21}],212:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":211,"./info.json":213,"dup":162}],213:[function(require,module,exports){
-module.exports={
- "name": "Fisheye GL",
- "description": "Correct fisheye, or barrel distortion, in images (with WebGL -- adapted from fisheye-correction-webgl by @bluemir).",
- "requires": [ "webgl" ],
- "inputs": {
- "a": {
- "type": "float",
- "desc": "a parameter",
- "default": 1,
- "min": 1,
- "max": 4
- },
- "b": {
- "type": "float",
- "desc": "b parameter",
- "default": 1,
- "min": 1,
- "max": 4
- },
- "Fx": {
- "type": "float",
- "desc": "Fx parameter",
- "default": 0,
- "min": 0,
- "max": 4
- },
- "Fy": {
- "type": "float",
- "desc": "Fy parameter",
- "default": 0,
- "min": 0,
- "max": 4
- },
- "scale": {
- "type": "float",
- "desc": "Image Scaling",
- "default": 1.5,
- "min": 0,
- "max": 20
- },
- "x": {
- "type": "float",
- "desc": "FOV x parameter",
- "default": 1.5,
- "min": 0,
- "max": 20
- },
- "y": {
- "type": "float",
- "desc": "FOV y parameter",
- "default": 1.5,
- "min": 0,
- "max": 20
- },
- "fragmentSrc": {
- "type": "PATH",
- "desc": "Path to a WebGL fragment shader file",
- "default": "(inbuilt)"
- },
- "vertexSrc": {
- "type": "PATH",
- "desc": "Path to a WebGL vertex shader file",
- "default": "(inbuilt)"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Fisheye GL",
+ "description": "Correct fisheye, or barrel distortion, in images (with WebGL -- adapted from fisheye-correction-webgl by @bluemir).",
+ "requires": [ "webgl" ],
+ "inputs": {
+ "a": {
+ "type": "float",
+ "desc": "a parameter",
+ "default": 1,
+ "min": 1,
+ "max": 4
+ },
+ "b": {
+ "type": "float",
+ "desc": "b parameter",
+ "default": 1,
+ "min": 1,
+ "max": 4
+ },
+ "Fx": {
+ "type": "float",
+ "desc": "Fx parameter",
+ "default": 0,
+ "min": 0,
+ "max": 4
+ },
+ "Fy": {
+ "type": "float",
+ "desc": "Fy parameter",
+ "default": 0,
+ "min": 0,
+ "max": 4
+ },
+ "scale": {
+ "type": "float",
+ "desc": "Image Scaling",
+ "default": 1.5,
+ "min": 0,
+ "max": 20
+ },
+ "x": {
+ "type": "float",
+ "desc": "FOV x parameter",
+ "default": 1.5,
+ "min": 0,
+ "max": 20
+ },
+ "y": {
+ "type": "float",
+ "desc": "FOV y parameter",
+ "default": 1.5,
+ "min": 0,
+ "max": 20
+ },
+ "fragmentSrc": {
+ "type": "PATH",
+ "desc": "Path to a WebGL fragment shader file",
+ "default": "(inbuilt)"
+ },
+ "vertexSrc": {
+ "type": "PATH",
+ "desc": "Path to a WebGL vertex shader file",
+ "default": "(inbuilt)"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],214:[function(require,module,exports){
-module.exports = function Gamma(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 val = options.adjustment || 0.2;
-
- r = Math.pow(r / 255, val) * 255;
- g = Math.pow(g / 255, val) * 255;
- b = Math.pow(b / 255, val) * 255;
-
- return [r , g, b, a];
- }
-
- function output(image,datauri,mimetype){
-
- 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,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+module.exports = function Gamma(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 val = options.adjustment || 0.2;
+
+ r = Math.pow(r / 255, val) * 255;
+ g = Math.pow(g / 255, val) * 255;
+ b = Math.pow(b / 255, val) * 255;
+
+ return [r , g, b, a];
+ }
+
+ function output(image,datauri,mimetype){
+
+ 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,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249}],215:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":214,"./info.json":216,"dup":162}],216:[function(require,module,exports){
-module.exports={
- "name": "Gamma Correction",
- "description": "Apply gamma correction on the image Read more",
- "inputs": {
- "adjustment": {
- "type": "float",
- "desc": "gamma correction (inverse of actual gamma factor) for the new image",
- "default": 0.2
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Gamma Correction",
+ "description": "Apply gamma correction on the image Read more",
+ "inputs": {
+ "adjustment": {
+ "type": "float",
+ "desc": "gamma correction (inverse of actual gamma factor) for the new image",
+ "default": 0.2
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],217:[function(require,module,exports){
(function (Buffer){
-module.exports = function Invert(options, UI) {
-
- var output;
-
- // The function which is called on every draw.
- function draw(input, callback, progressObj) {
- var getPixels = require('get-pixels');
- var savePixels = require('save-pixels');
-
- var step = this;
-
- getPixels(input.src, function(err, pixels) {
-
- if (err) {
- console.log("Bad Image path");
- return;
- }
- var width = 0;
-
- for (var i = 0; i < pixels.shape[0]; i++) width++;
-
- for (var i = 0; i < pixels.shape[0]; i++) {
- for (var j = 0; j < pixels.shape[1]; j++) {
- let val = (i / width) * 255;
- pixels.set(i, j, 0, val);
- pixels.set(i, j, 1, val);
- pixels.set(i, j, 2, val);
- pixels.set(i, j, 3, 255);
- }
- }
- var chunks = [];
- var totalLength = 0;
- var r = savePixels(pixels, input.format, { quality: 100 });
-
- r.on("data", function(chunk) {
- totalLength += chunk.length;
- chunks.push(chunk);
- });
-
- r.on("end", function() {
- var data = Buffer.concat(chunks, totalLength).toString("base64");
- var datauri = "data:image/" + input.format + ";base64," + data;
- output(input.image, datauri, input.format);
- callback();
- });
- });
-
- function output(image, datauri, mimetype) {
-
- // This output is accessible by Image Sequencer
- step.output = { src: datauri, format: mimetype };
-
- }
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+module.exports = function Invert(options, UI) {
+
+ var output;
+
+ // The function which is called on every draw.
+ function draw(input, callback, progressObj) {
+ var getPixels = require('get-pixels');
+ var savePixels = require('save-pixels');
+
+ var step = this;
+
+ getPixels(input.src, function(err, pixels) {
+
+ if (err) {
+ console.log("Bad Image path");
+ return;
+ }
+ var width = 0;
+
+ for (var i = 0; i < pixels.shape[0]; i++) width++;
+
+ for (var i = 0; i < pixels.shape[0]; i++) {
+ for (var j = 0; j < pixels.shape[1]; j++) {
+ let val = (i / width) * 255;
+ pixels.set(i, j, 0, val);
+ pixels.set(i, j, 1, val);
+ pixels.set(i, j, 2, val);
+ pixels.set(i, j, 3, 255);
+ }
+ }
+ var chunks = [];
+ var totalLength = 0;
+ var r = savePixels(pixels, input.format, { quality: 100 });
+
+ r.on("data", function(chunk) {
+ totalLength += chunk.length;
+ chunks.push(chunk);
+ });
+
+ r.on("end", function() {
+ var data = Buffer.concat(chunks, totalLength).toString("base64");
+ var datauri = "data:image/" + input.format + ";base64," + data;
+ output(input.image, datauri, input.format);
+ callback();
+ });
+ });
+
+ function output(image, datauri, mimetype) {
+
+ // This output is accessible by Image Sequencer
+ step.output = { src: datauri, format: mimetype };
+
+ }
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
}).call(this,require("buffer").Buffer)
},{"buffer":47,"get-pixels":29,"save-pixels":138}],218:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":217,"./info.json":219,"dup":162}],219:[function(require,module,exports){
-module.exports={
- "name": "Gradient",
- "description": "Gives a gradient of the image",
- "inputs": {},
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Gradient",
+ "description": "Gives a gradient of the image",
+ "inputs": {},
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],220:[function(require,module,exports){
-/*
- * Calculates the histogram of the image
- */
-module.exports = function Channel(options, UI) {
-
- var output;
-
- function draw(input, callback, progressObj) {
-
- options.gradient = options.gradient || "true";
- options.gradient = JSON.parse(options.gradient);
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this, hist = new Array(256).fill(0);
-
- function changePixel(r, g, b, a) {
- let pixVal = Math.round((r + g + b) / 3);
- hist[pixVal]++;
- return [r, g, b, a];
- }
-
- function extraManipulation(pixels) {
- // if (!options.inBrowser)
- // require('fs').writeFileSync('./output/histo.txt', hist.reduce((tot, cur, idx) => `${tot}\n${idx} : ${cur}`, ``));
- var newarray = new Uint8Array(4 * 256 * 256);
- pixels.data = newarray;
- pixels.shape = [256, 256, 4];
- pixels.stride[1] = 4 * 256;
-
- for (let x = 0; x < 256; x++) {
- for (let y = 0; y < 256; y++) {
- pixels.set(x, y, 0, 255);
- pixels.set(x, y, 1, 255);
- pixels.set(x, y, 2, 255);
- pixels.set(x, y, 3, 255);
- }
- }
-
- let startY = options.gradient ? 10 : 0;
- if (options.gradient) {
- for (let x = 0; x < 256; x++) {
- for (let y = 0; y < 10; y++) {
- pixels.set(x, 255 - y, 0, x);
- pixels.set(x, 255 - y, 1, x);
- pixels.set(x, 255 - y, 2, x);
- }
- }
- }
-
- let convfactor = (256 - startY) / Math.max(...hist);
-
- for (let x = 0; x < 256; x++) {
- let pixCount = Math.round(convfactor * hist[x]);
-
- for (let y = startY; y < pixCount; y++) {
- pixels.set(x, 255 - y, 0, 204);
- pixels.set(x, 255 - y, 1, 255);
- pixels.set(x, 255 - y, 2, 153);
- }
- }
-
- return pixels;
- }
-
- 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,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: callback
- });
-
- }
-
- return {
- options: options,
- //setup: setup, // optional
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+ * Calculates the histogram of the image
+ */
+module.exports = function Channel(options, UI) {
+
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ options.gradient = options.gradient || "true";
+ options.gradient = JSON.parse(options.gradient);
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this, hist = new Array(256).fill(0);
+
+ function changePixel(r, g, b, a) {
+ let pixVal = Math.round((r + g + b) / 3);
+ hist[pixVal]++;
+ return [r, g, b, a];
+ }
+
+ function extraManipulation(pixels) {
+ // if (!options.inBrowser)
+ // require('fs').writeFileSync('./output/histo.txt', hist.reduce((tot, cur, idx) => `${tot}\n${idx} : ${cur}`, ``));
+ var newarray = new Uint8Array(4 * 256 * 256);
+ pixels.data = newarray;
+ pixels.shape = [256, 256, 4];
+ pixels.stride[1] = 4 * 256;
+
+ for (let x = 0; x < 256; x++) {
+ for (let y = 0; y < 256; y++) {
+ pixels.set(x, y, 0, 255);
+ pixels.set(x, y, 1, 255);
+ pixels.set(x, y, 2, 255);
+ pixels.set(x, y, 3, 255);
+ }
+ }
+
+ let startY = options.gradient ? 10 : 0;
+ if (options.gradient) {
+ for (let x = 0; x < 256; x++) {
+ for (let y = 0; y < 10; y++) {
+ pixels.set(x, 255 - y, 0, x);
+ pixels.set(x, 255 - y, 1, x);
+ pixels.set(x, 255 - y, 2, x);
+ }
+ }
+ }
+
+ let convfactor = (256 - startY) / Math.max(...hist);
+
+ for (let x = 0; x < 256; x++) {
+ let pixCount = Math.round(convfactor * hist[x]);
+
+ for (let y = startY; y < pixCount; y++) {
+ pixels.set(x, 255 - y, 0, 204);
+ pixels.set(x, 255 - y, 1, 255);
+ pixels.set(x, 255 - y, 2, 153);
+ }
+ }
+
+ return pixels;
+ }
+
+ 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,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: callback
+ });
+
+ }
+
+ return {
+ options: options,
+ //setup: setup, // optional
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249}],221:[function(require,module,exports){
-module.exports = [
- require('./Module.js'),
- require('./info.json')
+module.exports = [
+ require('./Module.js'),
+ require('./info.json')
]
},{"./Module.js":220,"./info.json":222}],222:[function(require,module,exports){
-module.exports={
- "name": "Histogram",
- "description": "Calculates the histogram for the image",
- "inputs": {
- "gradient": {
- "type": "select",
- "desc": "Toggle the gradient along x-axis",
- "default": "true",
- "values": [
- "true",
- "false"
- ]
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Histogram",
+ "description": "Calculates the histogram for the image",
+ "inputs": {
+ "gradient": {
+ "type": "select",
+ "desc": "Toggle the gradient along x-axis",
+ "default": "true",
+ "values": [
+ "true",
+ "false"
+ ]
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],223:[function(require,module,exports){
-/*
- * Import Image module; this fetches a given remote or local image via URL
- * or data-url, and overwrites the current one. It saves the original as
- * step.metadata.input for use in future modules such as blending.
- * TODO: we could accept an operation for blending like "screen" or "overlay",
- * or a function with blend(r1,g1,b1,a1,r2,g2,b2,a2), OR we could simply allow
- * subsequent modules to do this blending and keep this one simple.
- */
-module.exports = function ImportImageModule(options, UI) {
-
- options.imageUrl = options.url || "./images/monarch.png";
-
- var output,
- imgObj = new Image();
-
- // we should get UI to return the image thumbnail so we can attach our own UI extensions
-
- // add our custom in-module html ui:
- if (options.step.inBrowser) {
- var ui = require('./Ui.js')(options.step, UI);
- ui.setup();
- }
-
- // This function is caled everytime the step has to be redrawn
- function draw(input,callback) {
-
- var step = this;
-
- step.metadata = step.metadata || {};
- // TODO: develop a standard API method for saving each input state,
- // for reference in future steps (for blending, for example)
- step.metadata.input = input;
-
- function onLoad() {
-
- // This output is accessible to Image Sequencer
- step.output = {
- src: imgObj.src,
- format: options.format
- }
-
- // Tell Image Sequencer that step has been drawn
- callback();
- }
-
- options.format = require('../../util/GetFormat')(options.imageUrl);
- imgObj.onload = onLoad;
- imgObj.src = options.imageUrl;
-
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+ * Import Image module; this fetches a given remote or local image via URL
+ * or data-url, and overwrites the current one. It saves the original as
+ * step.metadata.input for use in future modules such as blending.
+ * TODO: we could accept an operation for blending like "screen" or "overlay",
+ * or a function with blend(r1,g1,b1,a1,r2,g2,b2,a2), OR we could simply allow
+ * subsequent modules to do this blending and keep this one simple.
+ */
+module.exports = function ImportImageModule(options, UI) {
+
+ options.imageUrl = options.url || "./images/monarch.png";
+
+ var output,
+ imgObj = new Image();
+
+ // we should get UI to return the image thumbnail so we can attach our own UI extensions
+
+ // add our custom in-module html ui:
+ if (options.step.inBrowser) {
+ var ui = require('./Ui.js')(options.step, UI);
+ ui.setup();
+ }
+
+ // This function is caled everytime the step has to be redrawn
+ function draw(input,callback) {
+
+ var step = this;
+
+ step.metadata = step.metadata || {};
+ // TODO: develop a standard API method for saving each input state,
+ // for reference in future steps (for blending, for example)
+ step.metadata.input = input;
+
+ function onLoad() {
+
+ // This output is accessible to Image Sequencer
+ step.output = {
+ src: imgObj.src,
+ format: options.format
+ }
+
+ // Tell Image Sequencer that step has been drawn
+ callback();
+ }
+
+ options.format = require('../../util/GetFormat')(options.imageUrl);
+ imgObj.onload = onLoad;
+ imgObj.src = options.imageUrl;
+
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../../util/GetFormat":253,"./Ui.js":224}],224:[function(require,module,exports){
-// hide on save
-module.exports = function ImportImageModuleUi(step, ui) {
-
- function setup(setImage, onLoad) {
-
- // generate a unique timestamp based id for the dropzone
- var dropzoneId = 'dropzone-import-image-' + step.ID;
-
- // add a file input listener
- var dropZone ='\
-
\
-
\
- Select or drag in an image to overlay.\
-
\
-
\
- \
-
\
-
';
-
- // insert into .details area
- // TODO: develop API-based consistent way to add UI elements
- $(step.ui)
- .find('.details')
- .prepend(dropZone);
-
- // setup file input listener
- sequencer.setInputStep({
- dropZoneSelector: "#" + dropzoneId,
- fileInputSelector: "#" + dropzoneId + " .file-input",
- onLoad: function onLoadFromInput(progress) {
- var reader = progress.target;
- step.options.imageUrl = reader.result;
- step.options.url = reader.result;
- sequencer.run();
- setUrlHashParameter("steps", sequencer.toString());
- }
- });
-
- $(step.ui)
- .find('.btn-save').on('click', function onClickSave() {
-
- var src = $(step.ui)
- .find('.det input').val();
- step.options.imageUrl = src;
- sequencer.run();
-
- });
-
- }
-
- return {
- setup: setup
- }
-}
+// hide on save
+module.exports = function ImportImageModuleUi(step, ui) {
+
+ function setup(setImage, onLoad) {
+
+ // generate a unique timestamp based id for the dropzone
+ var dropzoneId = 'dropzone-import-image-' + step.ID;
+
+ // add a file input listener
+ var dropZone ='\
+
\
+
\
+ Select or drag in an image to overlay.\
+
\
+
\
+ \
+
\
+
';
+
+ // insert into .details area
+ // TODO: develop API-based consistent way to add UI elements
+ $(step.ui)
+ .find('.details')
+ .prepend(dropZone);
+
+ // setup file input listener
+ sequencer.setInputStep({
+ dropZoneSelector: "#" + dropzoneId,
+ fileInputSelector: "#" + dropzoneId + " .file-input",
+ onLoad: function onLoadFromInput(progress) {
+ var reader = progress.target;
+ step.options.imageUrl = reader.result;
+ step.options.url = reader.result;
+ sequencer.run();
+ setUrlHashParameter("steps", sequencer.toString());
+ }
+ });
+
+ $(step.ui)
+ .find('.btn-save').on('click', function onClickSave() {
+
+ var src = $(step.ui)
+ .find('.det input').val();
+ step.options.imageUrl = src;
+ sequencer.run();
+
+ });
+
+ }
+
+ return {
+ setup: setup
+ }
+}
},{}],225:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":223,"./info.json":226,"dup":162}],226:[function(require,module,exports){
-module.exports={
- "name": "Import Image",
- "description": "Import a new image and replace the original with it. Future versions may enable a blend mode. Specify an image by URL or by file selector.",
- "url": "https://github.com/publiclab/image-sequencer/tree/master/MODULES.md",
- "inputs": {
- "url": {
- "type": "string",
- "desc": "URL of image to import",
- "default": "./images/monarch.png"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Import Image",
+ "description": "Import a new image and replace the original with it. Future versions may enable a blend mode. Specify an image by URL or by file selector.",
+ "url": "https://github.com/publiclab/image-sequencer/tree/master/MODULES.md",
+ "inputs": {
+ "url": {
+ "type": "string",
+ "desc": "URL of image to import",
+ "default": "./images/monarch.png"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],227:[function(require,module,exports){
-/*
- * Sample Meta Module for demonstration purpose only
- */
-module.exports = function NdviColormapfunction() {
- this.expandSteps([{ 'name': 'ndvi', 'options': {} }, { 'name': 'colormap', options: {} }]);
- return {
- isMeta: true
- }
+/*
+ * NDVI with red filter (blue channel is infrared)
+ */
+module.exports = function Ndvi(options, UI) {
+
+ if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI);
+
+ options.filter = options.filter || "red";
+
+ var output;
+
+ // The function which is called on every draw.
+ function draw(input, callback, progressObj) {
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ if (options.filter == "red") var ndvi = (b - r) / (1.00 * b + r);
+ if (options.filter == "blue") var ndvi = (r - b) / (1.00 * b + r);
+ var x = 255 * (ndvi + 1) / 2;
+ return [x, x, x, a];
+ }
+
+ function output(image, datauri, mimetype) {
+
+ // This output is accessible by Image Sequencer
+ step.output = { src: datauri, format: mimetype };
+
+ }
+
+ function modifiedCallback() {
+ if (options.step.inBrowser) {
+ ui.setup();
+ }
+ callback();
+ }
+
+ return require('../_nomodule/PixelManipulation.js')(input, {
+ output: output,
+ changePixel: changePixel,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: modifiedCallback
+ });
+
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
}
-},{}],228:[function(require,module,exports){
+
+},{"../_nomodule/PixelManipulation.js":249,"./Ui.js":228}],228:[function(require,module,exports){
+// hide on save
+module.exports = function CropModuleUi(step, ui) {
+
+ /* sets the pixel value under the mouse pointer
+ * on the title attribute of the image element.
+ */
+ function setup() {
+ var ndviImage = $(imgEl());
+
+ ndviImage.mousemove(function ndviMousemove(e) {
+
+ var canvas = document.createElement("canvas");
+ canvas.width = ndviImage.width();
+ canvas.height = ndviImage.height();
+ canvas.getContext('2d').drawImage(this, 0, 0);
+
+ var offset = $(this).offset();
+ var xPos = e.pageX - offset.left;
+ var yPos = e.pageY - offset.top;
+ var ndvi = canvas.getContext('2d').getImageData(xPos, yPos, 1, 1).data[0];
+ ndvi = ndvi/127.5 - 1 ;
+ ndvi = ndvi.toFixed(2);
+ ndviImage[0].title = "NDVI: " + ndvi;
+ });
+ }
+ // step.imgSelector is not defined, imgElement is:
+ function imgEl() {
+ return step.imgElement;
+ }
+
+ return {
+ setup: setup
+ }
+}
+
+},{}],229:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
-},{"./Module":227,"./info.json":229,"dup":162}],229:[function(require,module,exports){
-module.exports={
- "name": "NDVI-Colormap",
- "description": "Sequentially Applies NDVI and Colormap steps",
- "inputs": {},
- "length": 2,
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+},{"./Module":227,"./info.json":230,"dup":162}],230:[function(require,module,exports){
+module.exports={
+ "name": "NDVI",
+ "description": "Normalized Difference Vegetation Index, or NDVI, is an image analysis technique used with aerial photography. It's a way to visualize the amounts of infrared and other wavelengths of light reflected from vegetation by comparing ratios of blue and red light absorbed versus green and IR light reflected. NDVI is used to evaluate the health of vegetation in satellite imagery, where it correlates with how much photosynthesis is happening. This is helpful in assessing vegetative health or stress. Read more.
This is designed for use with red-filtered single camera DIY Infragram cameras; change to 'blue' for blue filters",
+ "inputs": {
+ "filter": {
+ "type": "select",
+ "desc": "Filter color",
+ "default": "red",
+ "values": ["red", "blue"]
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
-},{}],230:[function(require,module,exports){
-/*
- * NDVI with red filter (blue channel is infrared)
- */
-module.exports = function Ndvi(options, UI) {
-
- if (options.step.inBrowser) var ui = require('./Ui.js')(options.step, UI);
-
- options.filter = options.filter || "red";
-
- var output;
-
- // The function which is called on every draw.
- function draw(input, callback, progressObj) {
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- if (options.filter == "red") var ndvi = (b - r) / (1.00 * b + r);
- if (options.filter == "blue") var ndvi = (r - b) / (1.00 * b + r);
- var x = 255 * (ndvi + 1) / 2;
- return [x, x, x, a];
- }
-
- function output(image, datauri, mimetype) {
-
- // This output is accessible by Image Sequencer
- step.output = { src: datauri, format: mimetype };
-
- }
-
- function modifiedCallback() {
- if (options.step.inBrowser) {
- ui.setup();
- }
- callback();
- }
-
- return require('../_nomodule/PixelManipulation.js')(input, {
- output: output,
- changePixel: changePixel,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: modifiedCallback
- });
-
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
-
-},{"../_nomodule/PixelManipulation.js":249,"./Ui.js":231}],231:[function(require,module,exports){
-// hide on save
-module.exports = function CropModuleUi(step, ui) {
-
- /* sets the pixel value under the mouse pointer
- * on the title attribute of the image element.
- */
- function setup() {
- var ndviImage = $(imgEl());
-
- ndviImage.mousemove(function ndviMousemove(e) {
-
- var canvas = document.createElement("canvas");
- canvas.width = ndviImage.width();
- canvas.height = ndviImage.height();
- canvas.getContext('2d').drawImage(this, 0, 0);
-
- var offset = $(this).offset();
- var xPos = e.pageX - offset.left;
- var yPos = e.pageY - offset.top;
- var ndvi = canvas.getContext('2d').getImageData(xPos, yPos, 1, 1).data[0];
- ndvi = ndvi/127.5 - 1 ;
- ndvi = ndvi.toFixed(2);
- ndviImage[0].title = "NDVI: " + ndvi;
- });
- }
- // step.imgSelector is not defined, imgElement is:
- function imgEl() {
- return step.imgElement;
- }
-
- return {
- setup: setup
- }
-}
+},{}],231:[function(require,module,exports){
+/*
+ * Sample Meta Module for demonstration purpose only
+ */
+module.exports = function NdviColormapfunction() {
+ this.expandSteps([{ 'name': 'ndvi', 'options': {} }, { 'name': 'colormap', options: {} }]);
+ return {
+ isMeta: true
+ }
+}
},{}],232:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
-},{"./Module":230,"./info.json":233,"dup":162}],233:[function(require,module,exports){
-module.exports={
- "name": "NDVI",
- "description": "Normalized Difference Vegetation Index, or NDVI, is an image analysis technique used with aerial photography. It's a way to visualize the amounts of infrared and other wavelengths of light reflected from vegetation by comparing ratios of blue and red light absorbed versus green and IR light reflected. NDVI is used to evaluate the health of vegetation in satellite imagery, where it correlates with how much photosynthesis is happening. This is helpful in assessing vegetative health or stress. Read more.
This is designed for use with red-filtered single camera DIY Infragram cameras; change to 'blue' for blue filters",
- "inputs": {
- "filter": {
- "type": "select",
- "desc": "Filter color",
- "default": "red",
- "values": ["red", "blue"]
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
-
+},{"./Module":231,"./info.json":233,"dup":162}],233:[function(require,module,exports){
+module.exports={
+ "name": "NDVI-Colormap",
+ "description": "Sequentially Applies NDVI and Colormap steps",
+ "inputs": {},
+ "length": 2,
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],234:[function(require,module,exports){
-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;
-
- var parseCoordInputs = require('../../util/ParseInputCoordinates');
-
- //parse the inputs
- parseCoordInputs.parseCornerCoordinateInputs(options, {
- src: input.src,
- x: { valInp: options.x, type: 'horizontal' },
- y: { valInp: options.y, type: 'vertical' },
- }, function (options, input) {
- options.x = parseInt(input.x.valInp);
- options.y = parseInt(input.y.valInp);
- });
-
- // 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
- }
-}
+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;
+
+ var parseCornerCoordinateInputs = require('../../util/ParseInputCoordinates');
+
+ //parse the inputs
+ parseCornerCoordinateInputs(options, {
+ src: input.src,
+ x: { valInp: options.x, type: 'horizontal' },
+ y: { valInp: options.y, type: 'vertical' },
+ }, function (options, input) {
+ options.x = parseInt(input.x.valInp);
+ options.y = parseInt(input.y.valInp);
+ });
+
+ // 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
+ }
+}
},{"../../util/ParseInputCoordinates":254,"../_nomodule/PixelManipulation.js":249,"get-pixels":29}],235:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":234,"./info.json":236,"dup":162}],236:[function(require,module,exports){
-module.exports={
- "name": "Overlay",
- "description": "Overlays an Image over another at a given position(x,y) in pixels or in %",
- "inputs": {
- "x": {
- "type": "integer",
- "desc": "X-position of the image on which the new image is overlayed",
- "default": 0
- },
- "y": {
- "type": "integer",
- "desc": "Y-position of the image on which the new image is overlayed",
- "default": 0
- },
- "offset": {
- "type": "integer",
- "desc": "offset to the output of the step on which the output of the last step is overlayed",
- "default": -2
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Overlay",
+ "description": "Overlays an Image over another at a given position(x,y) in pixels or in %",
+ "inputs": {
+ "x": {
+ "type": "integer",
+ "desc": "X-position of the image on which the new image is overlayed",
+ "default": 0
+ },
+ "y": {
+ "type": "integer",
+ "desc": "Y-position of the image on which the new image is overlayed",
+ "default": 0
+ },
+ "offset": {
+ "type": "integer",
+ "desc": "offset to the output of the step on which the output of the last step is overlayed",
+ "default": -2
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],237:[function(require,module,exports){
-/*
- * Resize the image by given percentage value
- */
-module.exports = function Resize(options, UI) {
-
- var output;
-
- function draw(input, callback, progressObj) {
-
- options.resize = options.resize || "125%";
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- var imagejs = require('imagejs');
-
- function changePixel(r, g, b, a) {
- return [r, g, b, a]
- }
-
- function extraManipulation(pixels) {
- // value above 100% scales up, and below 100% scales down
- var resize_value = parseInt(options.resize.slice(0, -1));
-
- var new_width,
- new_height;
-
- new_width = Math.round(pixels.shape[0] * (resize_value / 100));
- new_height = Math.round(pixels.shape[1] * (resize_value / 100));
-
- var bitmap = new imagejs.Bitmap({width: pixels.shape[0], height: pixels.shape[1]});
- bitmap._data.data = pixels.data;
-
-
- var resized = bitmap.resize({
- width: new_width, height: new_height,
- algorithm: "bicubicInterpolation"
- });
-
- pixels.data = resized._data.data;
- pixels.shape = [new_width,new_height,4];
- pixels.stride[1] = 4 * new_width;
-
- return pixels;
- }
-
- 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,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: callback
- });
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+ * Resize the image by given percentage value
+ */
+module.exports = function Resize(options, UI) {
+
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ options.resize = options.resize || "125%";
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ var imagejs = require('imagejs');
+
+ function changePixel(r, g, b, a) {
+ return [r, g, b, a]
+ }
+
+ function extraManipulation(pixels) {
+ // value above 100% scales up, and below 100% scales down
+ var resize_value = parseInt(options.resize.slice(0, -1));
+
+ var new_width,
+ new_height;
+
+ new_width = Math.round(pixels.shape[0] * (resize_value / 100));
+ new_height = Math.round(pixels.shape[1] * (resize_value / 100));
+
+ var bitmap = new imagejs.Bitmap({width: pixels.shape[0], height: pixels.shape[1]});
+ bitmap._data.data = pixels.data;
+
+
+ var resized = bitmap.resize({
+ width: new_width, height: new_height,
+ algorithm: "bicubicInterpolation"
+ });
+
+ pixels.data = resized._data.data;
+ pixels.shape = [new_width,new_height,4];
+ pixels.stride[1] = 4 * new_width;
+
+ return pixels;
+ }
+
+ 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,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: callback
+ });
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"imagejs":62}],238:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":237,"./info.json":239,"dup":162}],239:[function(require,module,exports){
-module.exports={
- "name": "Resize",
- "description": "Resize image by given percentage value",
- "inputs": {
- "resize": {
- "type": "string",
- "desc": "Percentage value of the resize",
- "default": "125%"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Resize",
+ "description": "Resize image by given percentage value",
+ "inputs": {
+ "resize": {
+ "type": "string",
+ "desc": "Percentage value of the resize",
+ "default": "125%"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],240:[function(require,module,exports){
-/*
- * Rotates image
- */
-module.exports = function Rotate(options, UI) {
-
- var output;
-
- function draw(input, callback, progressObj) {
-
- options.rotate = parseInt(options.rotate) || 0;
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- var imagejs = require('imagejs');
-
- function changePixel(r, g, b, a) {
- return [r, g, b, a]
- }
-
- function extraManipulation(pixels) {
- var rotate_value = (options.rotate)%360;
-
- if(rotate_value%360 == 0)
- return pixels;
-
- var bitmap = new imagejs.Bitmap({width: pixels.shape[0], height: pixels.shape[1]});
- bitmap._data.data = pixels.data;
-
- var rotated = bitmap.rotate({
- degrees: rotate_value,
- });
- pixels.data = rotated._data.data;
-
- return pixels;
- }
-
- 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,
- extraManipulation: extraManipulation,
- format: input.format,
- image: options.image,
- inBrowser: options.inBrowser,
- callback: callback
- });
- }
-
- return {
- options: options,
- draw: draw,
- output: output,
- UI: UI
- }
-}
+/*
+ * Rotates image
+ */
+module.exports = function Rotate(options, UI) {
+
+ var output;
+
+ function draw(input, callback, progressObj) {
+
+ options.rotate = parseInt(options.rotate) || 0;
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ var imagejs = require('imagejs');
+
+ function changePixel(r, g, b, a) {
+ return [r, g, b, a]
+ }
+
+ function extraManipulation(pixels) {
+ var rotate_value = (options.rotate)%360;
+
+ if(rotate_value%360 == 0)
+ return pixels;
+
+ var bitmap = new imagejs.Bitmap({width: pixels.shape[0], height: pixels.shape[1]});
+ bitmap._data.data = pixels.data;
+
+ var rotated = bitmap.rotate({
+ degrees: rotate_value,
+ });
+ pixels.data = rotated._data.data;
+
+ return pixels;
+ }
+
+ 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,
+ extraManipulation: extraManipulation,
+ format: input.format,
+ image: options.image,
+ inBrowser: options.inBrowser,
+ callback: callback
+ });
+ }
+
+ return {
+ options: options,
+ draw: draw,
+ output: output,
+ UI: UI
+ }
+}
},{"../_nomodule/PixelManipulation.js":249,"imagejs":62}],241:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":240,"./info.json":242,"dup":162}],242:[function(require,module,exports){
-module.exports={
- "name": "Rotate",
- "description": "Rotates image by specified degrees",
- "inputs": {
- "rotate": {
- "type": "range",
- "desc": "Angular value for rotation in degrees",
- "default": "0",
- "min": "0",
- "max": "360",
- "step": "1"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+module.exports={
+ "name": "Rotate",
+ "description": "Rotates image by specified degrees",
+ "inputs": {
+ "rotate": {
+ "type": "range",
+ "desc": "Angular value for rotation in degrees",
+ "default": "0",
+ "min": "0",
+ "max": "360",
+ "step": "1"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
}
},{}],243:[function(require,module,exports){
-/*
- * 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
- }
-}
+/*
+ * 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
+ }
+}
},{"../_nomodule/PixelManipulation.js":249}],244:[function(require,module,exports){
arguments[4][162][0].apply(exports,arguments)
},{"./Module":243,"./info.json":245,"dup":162}],245:[function(require,module,exports){
-module.exports={
- "name": "Saturation",
- "description": "Change the saturation of the image by given value, from 0-1, with 1 being 100% saturated.",
- "inputs": {
- "saturation": {
- "type": "range",
- "desc": "saturation for the new image between 0 and 2, 0 being black and white and 2 being highly saturated",
- "default": "0.5",
- "min": "0",
- "max": "2",
- "step": "0.1"
- }
- },
- "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
-}
+module.exports={
+ "name": "Saturation",
+ "description": "Change the saturation of the image by given value, from 0-1, with 1 being 100% saturated.",
+ "inputs": {
+ "saturation": {
+ "type": "range",
+ "desc": "saturation for the new image between 0 and 2, 0 being black and white and 2 being highly saturated",
+ "default": "0.5",
+ "min": "0",
+ "max": "2",
+ "step": "0.1"
+ }
+ },
+ "docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md"
+}
},{}],246:[function(require,module,exports){
-module.exports = function Balance(options, UI) {
-
- var output;
-
- function draw (input, callback, progressObj) {
-
- options.temperature = (options.temperature > "40000") ? "40000" : options.temperature
-
- progressObj.stop(true);
- progressObj.overrideFlag = true;
-
- var step = this;
-
- function changePixel(r, g, b, a) {
- return [r, g, b ,a]
- }
-
- function extraManipulation(pixels) {
-
- let temp = parseInt(options.temperature)
- temp /= 100
-
- let r, g, b;
-
- if (temp <= 66) {
- r = 255;
- g = Math.min(Math.max(99.4708025861 * Math.log(temp) - 161.1195681661, 0), 255);
- } else {
- r = Math.min(Math.max(329.698727446 * Math.pow(temp - 60, -0.1332047592), 0), 255);
- g = Math.min(Math.max(288.1221695283 * Math.pow(temp - 60, -0.0755148492), 0), 255);
- }
-
- if (temp >= 66) {
- b = 255;
- } else if (temp <= 19) {
- b = 0;
- } else {
- b = temp - 10;
- b = Math.min(Math.max(138.5177312231 * Math.log(b) - 305.0447927307, 0), 255);
- }
-
- for(let i=0; i "40000") ? "40000" : options.temperature
+
+ progressObj.stop(true);
+ progressObj.overrideFlag = true;
+
+ var step = this;
+
+ function changePixel(r, g, b, a) {
+ return [r, g, b ,a]
+ }
+
+ function extraManipulation(pixels) {
+
+ let temp = parseInt(options.temperature)
+ temp /= 100
+
+ let r, g, b;
+
+ if (temp <= 66) {
+ r = 255;
+ g = Math.min(Math.max(99.4708025861 * Math.log(temp) - 161.1195681661, 0), 255);
+ } else {
+ r = Math.min(Math.max(329.698727446 * Math.pow(temp - 60, -0.1332047592), 0), 255);
+ g = Math.min(Math.max(288.1221695283 * Math.pow(temp - 60, -0.0755148492), 0), 255);
+ }
+
+ if (temp >= 66) {
+ b = 255;
+ } else if (temp <= 19) {
+ b = 0;
+ } else {
+ b = temp - 10;
+ b = Math.min(Math.max(138.5177312231 * Math.log(b) - 305.0447927307, 0), 255);
+ }
+
+ for(let i=0; i To work with a new or different image, drag one into the drop zone.",
- ID: ref.options.sequencerCounter++,
- imageName: name,
- inBrowser: ref.options.inBrowser,
- ui: ref.options.ui
- };
-
- var image = {
- src: src,
- steps: [{
- options: {
- id: step.ID,
- name: "load-image",
- description: "This initial step loads and displays the original image without any modifications.",
- title: "Load Image",
- step: step
- },
- UI: ref.events,
- draw: function() {
- UI.onDraw(options.step);
- if(arguments.length==1){
- this.output = CImage(arguments[0]);
- options.step.output = this.output;
- UI.onComplete(options.step);
- return true;
- }
- else if(arguments.length==2) {
- this.output = CImage(arguments[0]);
- options.step.output = this.output;
- arguments[1]();
- UI.onComplete(options.step);
- return true;
- }
- return false;
- },
- }]
- };
- CImage(src, function(datauri) {
- var output = makeImage(datauri);
- ref.images[name] = image;
- var loadImageStep = ref.images[name].steps[0];
- loadImageStep.output = output;
- loadImageStep.options.step.output = loadImageStep.output.src;
- loadImageStep.UI.onSetup(loadImageStep.options.step);
- loadImageStep.UI.onDraw(loadImageStep.options.step);
- loadImageStep.UI.onComplete(loadImageStep.options.step);
-
- main_callback();
- return true;
- });
- }
-
- return loadImage(name,src);
-}
-
-module.exports = LoadImage;
+// special module to load an image into the start of the sequence; used in the HTML UI
+function LoadImage(ref, name, src, main_callback) {
+ function makeImage(datauri) {
+ var image = {
+ src: datauri,
+ format: datauri.split(':')[1].split(';')[0].split('/')[1]
+ }
+ return image;
+ }
+ function CImage(src, callback) {
+ var datauri;
+ if (!!src.match(/^data:/i)) {
+ datauri = src;
+ callback(datauri);
+ }
+ else if (!ref.options.inBrowser && !!src.match(/^https?:\/\//i)) {
+ require( src.match(/^(https?):\/\//i)[1] ).get(src,function(res){
+ var data = '';
+ var contentType = res.headers['content-type'];
+ res.setEncoding('base64');
+ res.on('data',function(chunk) {data += chunk;});
+ res.on('end',function() {
+ callback("data:"+contentType+";base64,"+data);
+ });
+ });
+ }
+ else if (ref.options.inBrowser) {
+ var ext = src.split('.').pop();
+ var image = document.createElement('img');
+ var canvas = document.createElement('canvas');
+ var context = canvas.getContext('2d');
+ image.onload = function() {
+ canvas.width = image.naturalWidth;
+ canvas.height = image.naturalHeight;
+ context.drawImage(image,0,0);
+ datauri = canvas.toDataURL(ext);
+ callback(datauri);
+ }
+ image.src = src;
+ }
+ else {
+ datauri = require('urify')(src);
+ callback(datauri);
+ }
+ }
+
+ function loadImage(name, src) {
+ var step = {
+ name: "load-image",
+ description: "This initial step loads and displays the original image without any modifications.
To work with a new or different image, drag one into the drop zone.",
+ ID: ref.options.sequencerCounter++,
+ imageName: name,
+ inBrowser: ref.options.inBrowser,
+ ui: ref.options.ui
+ };
+
+ var image = {
+ src: src,
+ steps: [{
+ options: {
+ id: step.ID,
+ name: "load-image",
+ description: "This initial step loads and displays the original image without any modifications.",
+ title: "Load Image",
+ step: step
+ },
+ UI: ref.events,
+ draw: function() {
+ UI.onDraw(options.step);
+ if(arguments.length==1){
+ this.output = CImage(arguments[0]);
+ options.step.output = this.output;
+ UI.onComplete(options.step);
+ return true;
+ }
+ else if(arguments.length==2) {
+ this.output = CImage(arguments[0]);
+ options.step.output = this.output;
+ arguments[1]();
+ UI.onComplete(options.step);
+ return true;
+ }
+ return false;
+ },
+ }]
+ };
+ CImage(src, function(datauri) {
+ var output = makeImage(datauri);
+ ref.images[name] = image;
+ var loadImageStep = ref.images[name].steps[0];
+ loadImageStep.output = output;
+ loadImageStep.options.step.output = loadImageStep.output.src;
+ loadImageStep.UI.onSetup(loadImageStep.options.step);
+ loadImageStep.UI.onDraw(loadImageStep.options.step);
+ loadImageStep.UI.onComplete(loadImageStep.options.step);
+
+ main_callback();
+ return true;
+ });
+ }
+
+ return loadImage(name,src);
+}
+
+module.exports = LoadImage;
},{"urify":147}],251:[function(require,module,exports){
-// TODO: potentially move this into ImportImage module
-function setInputStepInit() {
-
- return function setInputStep(options) {
-
- var dropzone = $(options.dropZoneSelector);
- var fileInput = $(options.fileInputSelector);
- var takePhoto = $(options.takePhotoSelector);
-
- var onLoad = options.onLoad;
- var onTakePhoto = options.onTakePhoto;
-
- var reader = new FileReader();
-
- function handleFile(e) {
-
- e.preventDefault();
- e.stopPropagation(); // stops the browser from redirecting.
-
- if (e.target && e.target.files) var file = e.target.files[0];
- else var file = e.dataTransfer.files[0];
- if(!file) return;
-
- var reader = new FileReader();
-
- reader.onload = onLoad;
-
- reader.readAsDataURL(file);
- }
-
- function runVideo(){
- /* event handler for Take-Photo */
- document.getElementById('video').style.display='inline';
- document.getElementById('capture').style.display='inline';
- document.getElementById('close').style.display='inline';
-
- var video = document.getElementById('video');
- canvas = document.getElementById('canvas'),
- context = canvas.getContext('2d'),
- vendorUrl = window.URL || window.webkitURL;
-
- navigator.getMedia = navigator.getUserMedia || navigator.wekitGetUserMedia ||
- navigator.mozGetUserMedia || navigator.msGetUserMedia;
-
- navigator.getMedia({
- video: true,
- audio: false
- }, function(stream){ // success callback
- video.srcObject = stream;
- video.onloadedmetadata = function(e) {
- video.play();
- };
- document.getElementById('close').addEventListener('click', function () {
- stopStream(stream);
- });
- }, function(error){ // error
- console.log("error");
- });
-
- document.getElementById('capture').addEventListener('click', function(stream){
- context.drawImage(video, 0, 0, 400, 300);
- options.onTakePhoto(canvas.toDataURL());
- });
-
- function stopStream(stream) {
- stream.getVideoTracks().forEach(function (track) {
- track.stop();
- });
- document.getElementById('video').style.display='none';
- document.getElementById('capture').style.display='none';
- document.getElementById('close').style.display='none';
- }
-}
-
- fileInput.on('change', handleFile);
- takePhoto.on('click', runVideo);
-
- dropzone[0].addEventListener('drop', handleFile, false);
-
- dropzone.on('dragover', function onDragover(e) {
- e.stopPropagation();
- e.preventDefault();
- e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
- }, false);
-
- dropzone.on('dragenter', function onDragEnter(e) {
- dropzone.addClass('hover');
- });
-
- dropzone.on('dragleave', function onDragLeave(e) {
- dropzone.removeClass('hover');
- });
-
- }
-
-}
-module.exports = setInputStepInit;
+// TODO: potentially move this into ImportImage module
+function setInputStepInit() {
+
+ return function setInputStep(options) {
+
+ var dropzone = $(options.dropZoneSelector);
+ var fileInput = $(options.fileInputSelector);
+ var takePhoto = $(options.takePhotoSelector);
+
+ var onLoad = options.onLoad;
+ var onTakePhoto = options.onTakePhoto;
+
+ var reader = new FileReader();
+
+ function handleFile(e) {
+
+ e.preventDefault();
+ e.stopPropagation(); // stops the browser from redirecting.
+
+ if (e.target && e.target.files) var file = e.target.files[0];
+ else var file = e.dataTransfer.files[0];
+ if(!file) return;
+
+ var reader = new FileReader();
+
+ reader.onload = onLoad;
+
+ reader.readAsDataURL(file);
+ }
+
+ function runVideo(){
+ /* event handler for Take-Photo */
+ document.getElementById('video').style.display='inline';
+ document.getElementById('capture').style.display='inline';
+ document.getElementById('close').style.display='inline';
+
+ var video = document.getElementById('video');
+ canvas = document.getElementById('canvas'),
+ context = canvas.getContext('2d'),
+ vendorUrl = window.URL || window.webkitURL;
+
+ navigator.getMedia = navigator.getUserMedia || navigator.wekitGetUserMedia ||
+ navigator.mozGetUserMedia || navigator.msGetUserMedia;
+
+ navigator.getMedia({
+ video: true,
+ audio: false
+ }, function(stream){ // success callback
+ video.srcObject = stream;
+ video.onloadedmetadata = function(e) {
+ video.play();
+ };
+ document.getElementById('close').addEventListener('click', function () {
+ stopStream(stream);
+ });
+ }, function(error){ // error
+ console.log("error");
+ });
+
+ document.getElementById('capture').addEventListener('click', function(stream){
+ context.drawImage(video, 0, 0, 400, 300);
+ options.onTakePhoto(canvas.toDataURL());
+ });
+
+ function stopStream(stream) {
+ stream.getVideoTracks().forEach(function (track) {
+ track.stop();
+ });
+ document.getElementById('video').style.display='none';
+ document.getElementById('capture').style.display='none';
+ document.getElementById('close').style.display='none';
+ }
+}
+
+ fileInput.on('change', handleFile);
+ takePhoto.on('click', runVideo);
+
+ dropzone[0].addEventListener('drop', handleFile, false);
+
+ dropzone.on('dragover', function onDragover(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
+ }, false);
+
+ dropzone.on('dragenter', function onDragEnter(e) {
+ dropzone.addClass('hover');
+ });
+
+ dropzone.on('dragleave', function onDragLeave(e) {
+ dropzone.removeClass('hover');
+ });
+
+ }
+
+}
+module.exports = setInputStepInit;
},{}],252:[function(require,module,exports){
-/*
- * User Interface Handling Module
- */
-
-module.exports = function UserInterface(events = {}) {
-
- events.onSetup = events.onSetup || function(step) {
- if (step.ui == false) {
- // No UI
- } else if(step.inBrowser) {
- // Create and append an HTML Element
- console.log("Added Step \""+step.name+"\" to \""+step.imageName+"\".");
- } else {
- // Create a NodeJS Object
- console.log('\x1b[36m%s\x1b[0m',"Added Step \""+step.name+"\" to \""+step.imageName+"\".");
- }
- }
-
- events.onDraw = events.onDraw || function(step) {
- if (step.ui == false) {
- // No UI
- } else if(step.inBrowser) {
- // Overlay a loading spinner
- console.log("Drawing Step \""+step.name+"\" on \""+step.imageName+"\".");
- } else {
- // Don't do anything
- console.log('\x1b[33m%s\x1b[0m',"Drawing Step \""+step.name+"\" on \""+step.imageName+"\".");
- }
- }
-
- events.onComplete = events.onComplete || function(step) {
- if (step.ui == false) {
- // No UI
- } else if(step.inBrowser) {
- // Update the DIV Element
- // Hide the laoding spinner
- console.log("Drawn Step \""+step.name+"\" on \""+step.imageName+"\".");
- } else {
- // Update the NodeJS Object
- console.log('\x1b[32m%s\x1b[0m',"Drawn Step \""+step.name+"\" on \""+step.imageName+"\".");
- }
- }
-
- events.onRemove = events.onRemove || function(step) {
- if (step.ui == false){
- // No UI
- } else if(step.inBrowser) {
- // Remove the DIV Element
- console.log("Removing Step \""+step.name+"\" of \""+step.imageName+"\".");
- } else {
- // Delete the NodeJS Object
- console.log('\x1b[31m%s\x1b[0m',"Removing Step \""+step.name+"\" of \""+step.imageName+"\".");
- }
- }
-
- return events;
-
-}
+/*
+ * User Interface Handling Module
+ */
+
+module.exports = function UserInterface(events = {}) {
+
+ events.onSetup = events.onSetup || function(step) {
+ if (step.ui == false) {
+ // No UI
+ } else if(step.inBrowser) {
+ // Create and append an HTML Element
+ console.log("Added Step \""+step.name+"\" to \""+step.imageName+"\".");
+ } else {
+ // Create a NodeJS Object
+ console.log('\x1b[36m%s\x1b[0m',"Added Step \""+step.name+"\" to \""+step.imageName+"\".");
+ }
+ }
+
+ events.onDraw = events.onDraw || function(step) {
+ if (step.ui == false) {
+ // No UI
+ } else if(step.inBrowser) {
+ // Overlay a loading spinner
+ console.log("Drawing Step \""+step.name+"\" on \""+step.imageName+"\".");
+ } else {
+ // Don't do anything
+ console.log('\x1b[33m%s\x1b[0m',"Drawing Step \""+step.name+"\" on \""+step.imageName+"\".");
+ }
+ }
+
+ events.onComplete = events.onComplete || function(step) {
+ if (step.ui == false) {
+ // No UI
+ } else if(step.inBrowser) {
+ // Update the DIV Element
+ // Hide the laoding spinner
+ console.log("Drawn Step \""+step.name+"\" on \""+step.imageName+"\".");
+ } else {
+ // Update the NodeJS Object
+ console.log('\x1b[32m%s\x1b[0m',"Drawn Step \""+step.name+"\" on \""+step.imageName+"\".");
+ }
+ }
+
+ events.onRemove = events.onRemove || function(step) {
+ if (step.ui == false){
+ // No UI
+ } else if(step.inBrowser) {
+ // Remove the DIV Element
+ console.log("Removing Step \""+step.name+"\" of \""+step.imageName+"\".");
+ } else {
+ // Delete the NodeJS Object
+ console.log('\x1b[31m%s\x1b[0m',"Removing Step \""+step.name+"\" of \""+step.imageName+"\".");
+ }
+ }
+
+ return events;
+
+}
},{}],253:[function(require,module,exports){
-/*
-* Determine format from a URL or data-url, return "jpg" "png" "gif" etc
-* TODO: write a test for this using the examples
-*/
-module.exports = function GetFormat(src) {
-
- var format = undefined; // haha default
-
- // EXAMPLE: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
- // EXAMPLE: "http://example.com/example.png"
- // EXAMPLE: "/example.png"
-
- if (isDataUrl(src)) {
- format = src.split(';')[0].split('/').pop();
- } else {
- format = src.split('.').pop();
- }
-
- function isDataUrl(src) {
- return src.substr(0, 10) === "data:image"
- }
-
- format = format.toLowerCase();
-
- if (format === "jpeg") format = "jpg";
-
- function validateFormat(data){
- let supportedFormats = [
- 'jpg',
- 'jpeg',
- 'png',
- 'gif',
- 'canvas',
- ];
- return supportedFormats.includes(data);
- }
-
- return validateFormat(format)?format:'jpg';
-
-}
+/*
+* Determine format from a URL or data-url, return "jpg" "png" "gif" etc
+* TODO: write a test for this using the examples
+*/
+module.exports = function GetFormat(src) {
+
+ var format = undefined; // haha default
+
+ // EXAMPLE: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAAQABADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAf/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFQEBAQAAAAAAAAAAAAAAAAAABgj/xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwCdABykX//Z";
+ // EXAMPLE: "http://example.com/example.png"
+ // EXAMPLE: "/example.png"
+
+ if (isDataUrl(src)) {
+ format = src.split(';')[0].split('/').pop();
+ } else {
+ format = src.split('.').pop();
+ }
+
+ function isDataUrl(src) {
+ return src.substr(0, 10) === "data:image"
+ }
+
+ format = format.toLowerCase();
+
+ if (format === "jpeg") format = "jpg";
+
+ function validateFormat(data){
+ let supportedFormats = [
+ 'jpg',
+ 'jpeg',
+ 'png',
+ 'gif',
+ 'canvas',
+ ];
+ return supportedFormats.includes(data);
+ }
+
+ return validateFormat(format)?format:'jpg';
+
+}
},{}],254:[function(require,module,exports){
-module.exports = function parseCornerCoordinateInputs(options,coord,callback) {
- var getPixels = require('get-pixels');
- getPixels(coord.src, function(err, pixels) {
- var iw = pixels.shape[0],
- ih = pixels.shape[1];
- if (!coord.x.valInp) {
- return
- }
- else {
- Object.keys(coord).forEach(convert);
- function convert(key) {
- var val = coord[key];
- if (val.valInp && val.valInp.slice(-1) === "%") {
- val.valInp = parseInt(val.valInp, 10);
- if (val.type === 'horizontal')
- val.valInp = val.valInp * iw / 100;
- else
- val.valInp = val.valInp * ih / 100;
- }
- }
- }
- callback(options, coord);
- })
+module.exports = function parseCornerCoordinateInputs(options,coord,callback) {
+ var getPixels = require('get-pixels');
+ getPixels(coord.src, function(err, pixels) {
+ var iw = pixels.shape[0],
+ ih = pixels.shape[1];
+ if (!coord.x.valInp) {
+ return
+ }
+ else {
+ Object.keys(coord).forEach(convert);
+ function convert(key) {
+ var val = coord[key];
+ if (val.valInp && val.valInp.slice(-1) === "%") {
+ val.valInp = parseInt(val.valInp, 10);
+ if (val.type === 'horizontal')
+ val.valInp = val.valInp * iw / 100;
+ else
+ val.valInp = val.valInp * ih / 100;
+ }
+ }
+ }
+ callback(options, coord);
+ })
}
},{"get-pixels":29}],255:[function(require,module,exports){
-module.exports = {
- getPreviousStep: function() {
- return this.getStep(-1);
- },
-
- getNextStep: function() {
- return this.getStep(1);
- },
-
- getInput: function(offset) {
- if (offset + this.getIndex() === 0) offset++;
- return this.getStep(offset - 1).output;
- },
-
- getOutput: function(offset) {
- return this.getStep(offset).output;
- },
-
- getOptions: function() {
- return this.getStep(0).options;
- },
-
- setOptions: function(optionsObj) {
- let options = this.getStep(0).options;
- for (let key in optionsObj) {
- if (options[key]) options[key] = optionsObj[key];
- }
- },
-
- getFormat: function() {
- return this.getStep(-1).output.format;
- },
-
- getHeight: function(callback) {
- let img = new Image();
- img.onload = function() {
- callback(img.height);
- };
- img.src = this.getInput(0).src;
- },
-
- getWidth: function(callback) {
- let img = new Image();
- img.onload = function() {
- callback(img.width);
- };
- img.src = this.getInput(0).src;
- }
+module.exports = {
+ getPreviousStep: function() {
+ return this.getStep(-1);
+ },
+
+ getNextStep: function() {
+ return this.getStep(1);
+ },
+
+ getInput: function(offset) {
+ if (offset + this.getIndex() === 0) offset++;
+ return this.getStep(offset - 1).output;
+ },
+
+ getOutput: function(offset) {
+ return this.getStep(offset).output;
+ },
+
+ getOptions: function() {
+ return this.getStep(0).options;
+ },
+
+ setOptions: function(optionsObj) {
+ let options = this.getStep(0).options;
+ for (let key in optionsObj) {
+ if (options[key]) options[key] = optionsObj[key];
+ }
+ },
+
+ getFormat: function() {
+ return this.getStep(-1).output.format;
+ },
+
+ getHeight: function(callback) {
+ let img = new Image();
+ img.onload = function() {
+ callback(img.height);
+ };
+ img.src = this.getInput(0).src;
+ },
+
+ getWidth: function(callback) {
+ let img = new Image();
+ img.onload = function() {
+ callback(img.width);
+ };
+ img.src = this.getInput(0).src;
+ }
}
},{}]},{},[154]);
diff --git a/dist/image-sequencer.min.js b/dist/image-sequencer.min.js
index b952852e..8a2e28d0 100644
--- a/dist/image-sequencer.min.js
+++ b/dist/image-sequencer.min.js
@@ -1 +1 @@
-!function(){return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o0?r-4:r,f=0;f>16&255,s[u++]=e>>8&255,s[u++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,s[u++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,s[u++]=e>>8&255,s[u++]=255&e);return s},n.fromByteArray=function(t){for(var e,n=t.length,i=n%3,a=[],o=0,s=n-i;os?s:o+16383));1===i?(e=t[n-1],a.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],a.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"="));return a.join("")};for(var r=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=o.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,n){for(var i,a,o=[],s=e;s>18&63]+r[a>>12&63]+r[a>>6&63]+r[63&a]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],2:[function(t,e,n){"use strict";"use restrict";function r(t){var e=32;return(t&=-t)&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}n.INT_BITS=32,n.INT_MAX=2147483647,n.INT_MIN=-1<<31,n.sign=function(t){return(t>0)-(t<0)},n.abs=function(t){var e=t>>31;return(t^e)-e},n.min=function(t,e){return e^(t^e)&-(t65535)<<4,e|=n=((t>>>=e)>255)<<3,e|=n=((t>>>=n)>15)<<2,(e|=n=((t>>>=n)>3)<<1)|(t>>>=n)>>1},n.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},n.popCount=function(t){return 16843009*((t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.countTrailingZeros=r,n.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},n.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},n.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var i=new Array(256);!function(t){for(var e=0;e<256;++e){var n=e,r=e,i=7;for(n>>>=1;n;n>>>=1)r<<=1,r|=1&n,--i;t[e]=r<>>8&255]<<16|i[t>>>16&255]<<8|i[t>>>24&255]},n.interleave2=function(t,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t&=65535)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e&=65535)|e<<8))|e<<4))|e<<2))|e<<1))<<1},n.deinterleave2=function(t,e){return(t=65535&((t=16711935&((t=252645135&((t=858993459&((t=t>>>e&1431655765)|t>>>1))|t>>>2))|t>>>4))|t>>>16))<<16>>16},n.interleave3=function(t,e,n){return t=1227133513&((t=3272356035&((t=251719695&((t=4278190335&((t&=1023)|t<<16))|t<<8))|t<<4))|t<<2),(t|=(e=1227133513&((e=3272356035&((e=251719695&((e=4278190335&((e&=1023)|e<<16))|e<<8))|e<<4))|e<<2))<<1)|(n=1227133513&((n=3272356035&((n=251719695&((n=4278190335&((n&=1023)|n<<16))|n<<8))|n<<4))|n<<2))<<2},n.deinterleave3=function(t,e){return(t=1023&((t=4278190335&((t=251719695&((t=3272356035&((t=t>>>e&1227133513)|t>>>2))|t>>>4))|t>>>8))|t>>>16))<<22>>22},n.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>r(t)+1}},{}],3:[function(t,e,n){(function(t,r,i){!function(t){if("object"==typeof n&&void 0!==e)e.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;"undefined"!=typeof window?i=window:void 0!==r?i=r:"undefined"!=typeof self&&(i=self),i.Promise=t()}}(function(){var e,n,a;return function t(e,n,r){function i(o,s){if(!n[o]){if(!e[o]){var u="function"==typeof _dereq_&&_dereq_;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[o]={exports:{}};e[o][0].call(c.exports,function(t){var n=e[o][1][t];return i(n||t)},c,c.exports,t,e,n,r)}return n[o].exports}for(var a="function"==typeof _dereq_&&_dereq_,o=0;o0;)p(t)}function p(t){var e=t.shift();if("function"!=typeof e)e._settlePromises();else{var n=t.shift(),r=t.shift();e.call(n,r)}}u.prototype.setScheduler=function(t){var e=this._schedule;return this._schedule=t,this._customScheduler=!0,e},u.prototype.hasCustomScheduler=function(){return this._customScheduler},u.prototype.enableTrampoline=function(){this._trampolineEnabled=!0},u.prototype.disableTrampolineIfNecessary=function(){s.hasDevTools&&(this._trampolineEnabled=!1)},u.prototype.haveItemsQueued=function(){return this._isTickUsed||this._haveDrainedQueues},u.prototype.fatalError=function(e,n){n?(t.stderr.write("Fatal "+(e instanceof Error?e.stack:e)+"\n"),t.exit(2)):this.throwLater(e)},u.prototype.throwLater=function(t,e){if(1===arguments.length&&(e=t,t=function(){throw e}),"undefined"!=typeof setTimeout)setTimeout(function(){t(e)},0);else try{this._schedule(function(){t(e)})}catch(t){throw new Error("No async scheduler available\n\n See http://goo.gl/MqrFmX\n")}},s.hasDevTools?(u.prototype.invokeLater=function(t,e,n){this._trampolineEnabled?l.call(this,t,e,n):this._schedule(function(){setTimeout(function(){t.call(e,n)},100)})},u.prototype.invoke=function(t,e,n){this._trampolineEnabled?c.call(this,t,e,n):this._schedule(function(){t.call(e,n)})},u.prototype.settlePromises=function(t){this._trampolineEnabled?f.call(this,t):this._schedule(function(){t._settlePromises()})}):(u.prototype.invokeLater=l,u.prototype.invoke=c,u.prototype.settlePromises=f),u.prototype._drainQueues=function(){h(this._normalQueue),this._reset(),this._haveDrainedQueues=!0,h(this._lateQueue)},u.prototype._queueTick=function(){this._isTickUsed||(this._isTickUsed=!0,this._schedule(this.drainQueues))},u.prototype._reset=function(){this._isTickUsed=!1},n.exports=u,n.exports.firstLineError=i},{"./queue":26,"./schedule":29,"./util":36}],3:[function(t,e,n){"use strict";e.exports=function(t,e,n,r){var i=!1,a=function(t,e){this._reject(e)},o=function(t,e){e.promiseRejectionQueued=!0,e.bindingPromise._then(a,a,null,this,t)},s=function(t,e){0==(50397184&this._bitField)&&this._resolveCallback(e.target)},u=function(t,e){e.promiseRejectionQueued||this._reject(t)};t.prototype.bind=function(a){i||(i=!0,t.prototype._propagateFrom=r.propagateFromFunction(),t.prototype._boundValue=r.boundValueFunction());var l=n(a),c=new t(e);c._propagateFrom(this,1);var f=this._target();if(c._setBoundTo(l),l instanceof t){var h={promiseRejectionQueued:!1,promise:c,target:f,bindingPromise:l};f._then(e,o,void 0,c,h),l._then(s,u,void 0,c,h),c._setOnCancel(l)}else c._resolveCallback(f);return c},t.prototype._setBoundTo=function(t){void 0!==t?(this._bitField=2097152|this._bitField,this._boundTo=t):this._bitField=-2097153&this._bitField},t.prototype._isBound=function(){return 2097152==(2097152&this._bitField)},t.bind=function(e,n){return t.resolve(n).bind(e)}}},{}],4:[function(t,e,n){"use strict";var r;"undefined"!=typeof Promise&&(r=Promise);var i=t("./promise")();i.noConflict=function(){try{Promise===i&&(Promise=r)}catch(t){}return i},e.exports=i},{"./promise":22}],5:[function(t,e,n){"use strict";var r=Object.create;if(r){var i=r(null),a=r(null);i[" size"]=a[" size"]=0}e.exports=function(e){var n,r=t("./util"),i=r.canEvaluate;r.isIdentifier;function a(t,n){var i;if(null!=t&&(i=t[n]),"function"!=typeof i){var a="Object "+r.classString(t)+" has no method '"+r.toString(n)+"'";throw new e.TypeError(a)}return i}function o(t){return a(t,this.pop()).apply(t,this)}function s(t){return t[this]}function u(t){var e=+this;return e<0&&(e=Math.max(0,e+t.length)),t[e]}e.prototype.call=function(t){var e=[].slice.call(arguments,1);return e.push(t),this._then(o,void 0,void 0,e,void 0)},e.prototype.get=function(t){var e;if("number"==typeof t)e=u;else if(i){var r=n(t);e=null!==r?r:s}else e=s;return this._then(e,void 0,void 0,t,void 0)}}},{"./util":36}],6:[function(t,e,n){"use strict";e.exports=function(e,n,r,i){var a=t("./util"),o=a.tryCatch,s=a.errorObj,u=e._async;e.prototype.break=e.prototype.cancel=function(){if(!i.cancellation())return this._warn("cancellation is disabled");for(var t=this,e=t;t._isCancellable();){if(!t._cancelBy(e)){e._isFollowing()?e._followee().cancel():e._cancelBranched();break}var n=t._cancellationParent;if(null==n||!n._isCancellable()){t._isFollowing()?t._followee().cancel():t._cancelBranched();break}t._isFollowing()&&t._followee().cancel(),t._setWillBeCancelled(),e=t,t=n}},e.prototype._branchHasCancelled=function(){this._branchesRemainingToCancel--},e.prototype._enoughBranchesHaveCancelled=function(){return void 0===this._branchesRemainingToCancel||this._branchesRemainingToCancel<=0},e.prototype._cancelBy=function(t){return t===this?(this._branchesRemainingToCancel=0,this._invokeOnCancel(),!0):(this._branchHasCancelled(),!!this._enoughBranchesHaveCancelled()&&(this._invokeOnCancel(),!0))},e.prototype._cancelBranched=function(){this._enoughBranchesHaveCancelled()&&this._cancel()},e.prototype._cancel=function(){this._isCancellable()&&(this._setCancelled(),u.invoke(this._cancelPromises,this,void 0))},e.prototype._cancelPromises=function(){this._length()>0&&this._settlePromises()},e.prototype._unsetOnCancel=function(){this._onCancelField=void 0},e.prototype._isCancellable=function(){return this.isPending()&&!this._isCancelled()},e.prototype.isCancellable=function(){return this.isPending()&&!this.isCancelled()},e.prototype._doInvokeOnCancel=function(t,e){if(a.isArray(t))for(var n=0;n=0)return n[t]}return t.prototype._promiseCreated=function(){},t.prototype._pushContext=function(){},t.prototype._popContext=function(){return null},t._peekContext=t.prototype._peekContext=function(){},r.prototype._pushContext=function(){void 0!==this._trace&&(this._trace._promiseCreated=null,n.push(this._trace))},r.prototype._popContext=function(){if(void 0!==this._trace){var t=n.pop(),e=t._promiseCreated;return t._promiseCreated=null,e}return null},r.CapturedTrace=null,r.create=function(){if(e)return new r},r.deactivateLongStackTraces=function(){},r.activateLongStackTraces=function(){var n=t.prototype._pushContext,a=t.prototype._popContext,o=t._peekContext,s=t.prototype._peekContext,u=t.prototype._promiseCreated;r.deactivateLongStackTraces=function(){t.prototype._pushContext=n,t.prototype._popContext=a,t._peekContext=o,t.prototype._peekContext=s,t.prototype._promiseCreated=u,e=!1},e=!0,t.prototype._pushContext=r.prototype._pushContext,t.prototype._popContext=r.prototype._popContext,t._peekContext=t.prototype._peekContext=i,t.prototype._promiseCreated=function(){var t=this._peekContext();t&&null==t._promiseCreated&&(t._promiseCreated=this)}},r}},{}],9:[function(e,n,r){"use strict";n.exports=function(n,r){var i,a,o,s=n._getDomain,u=n._async,l=e("./errors").Warning,c=e("./util"),f=e("./es5"),h=c.canAttachTrace,p=/[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/,d=/\((?:timers\.js):\d+:\d+\)/,v=/[\/<\(](.+?):(\d+):(\d+)\)?\s*$/,g=null,m=null,_=!1,y=!(0==c.env("BLUEBIRD_DEBUG")),b=!(0==c.env("BLUEBIRD_WARNINGS")||!y&&!c.env("BLUEBIRD_WARNINGS")),w=!(0==c.env("BLUEBIRD_LONG_STACK_TRACES")||!y&&!c.env("BLUEBIRD_LONG_STACK_TRACES")),x=0!=c.env("BLUEBIRD_W_FORGOTTEN_RETURN")&&(b||!!c.env("BLUEBIRD_W_FORGOTTEN_RETURN"));n.prototype.suppressUnhandledRejections=function(){var t=this._target();t._bitField=-1048577&t._bitField|524288},n.prototype._ensurePossibleRejectionHandled=function(){if(0==(524288&this._bitField)){this._setRejectionIsUnhandled();var t=this;setTimeout(function(){t._notifyUnhandledRejection()},1)}},n.prototype._notifyUnhandledRejectionIsHandled=function(){H("rejectionHandled",i,void 0,this)},n.prototype._setReturnedNonUndefined=function(){this._bitField=268435456|this._bitField},n.prototype._returnedNonUndefined=function(){return 0!=(268435456&this._bitField)},n.prototype._notifyUnhandledRejection=function(){if(this._isRejectionUnhandled()){var t=this._settledValue();this._setUnhandledRejectionIsNotified(),H("unhandledRejection",a,t,this)}},n.prototype._setUnhandledRejectionIsNotified=function(){this._bitField=262144|this._bitField},n.prototype._unsetUnhandledRejectionIsNotified=function(){this._bitField=-262145&this._bitField},n.prototype._isUnhandledRejectionNotified=function(){return(262144&this._bitField)>0},n.prototype._setRejectionIsUnhandled=function(){this._bitField=1048576|this._bitField},n.prototype._unsetRejectionIsUnhandled=function(){this._bitField=-1048577&this._bitField,this._isUnhandledRejectionNotified()&&(this._unsetUnhandledRejectionIsNotified(),this._notifyUnhandledRejectionIsHandled())},n.prototype._isRejectionUnhandled=function(){return(1048576&this._bitField)>0},n.prototype._warn=function(t,e,n){return z(t,e,n||this)},n.onPossiblyUnhandledRejection=function(t){var e=s();a="function"==typeof t?null===e?t:c.domainBind(e,t):void 0},n.onUnhandledRejectionHandled=function(t){var e=s();i="function"==typeof t?null===e?t:c.domainBind(e,t):void 0};var k=function(){};n.longStackTraces=function(){if(u.haveItemsQueued()&&!K.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");if(!K.longStackTraces&&Z()){var t=n.prototype._captureStackTrace,e=n.prototype._attachExtraTrace,i=n.prototype._dereferenceTrace;K.longStackTraces=!0,k=function(){if(u.haveItemsQueued()&&!K.longStackTraces)throw new Error("cannot enable long stack traces after promises have been created\n\n See http://goo.gl/MqrFmX\n");n.prototype._captureStackTrace=t,n.prototype._attachExtraTrace=e,n.prototype._dereferenceTrace=i,r.deactivateLongStackTraces(),u.enableTrampoline(),K.longStackTraces=!1},n.prototype._captureStackTrace=D,n.prototype._attachExtraTrace=U,n.prototype._dereferenceTrace=N,r.activateLongStackTraces(),u.disableTrampolineIfNecessary()}},n.hasLongStackTraces=function(){return K.longStackTraces&&Z()};var E=function(){try{if("function"==typeof CustomEvent){var t=new CustomEvent("CustomEvent");return c.global.dispatchEvent(t),function(t,e){var n={detail:e,cancelable:!0};f.defineProperty(n,"promise",{value:e.promise}),f.defineProperty(n,"reason",{value:e.reason});var r=new CustomEvent(t.toLowerCase(),n);return!c.global.dispatchEvent(r)}}if("function"==typeof Event){t=new Event("CustomEvent");return c.global.dispatchEvent(t),function(t,e){var n=new Event(t.toLowerCase(),{cancelable:!0});return n.detail=e,f.defineProperty(n,"promise",{value:e.promise}),f.defineProperty(n,"reason",{value:e.reason}),!c.global.dispatchEvent(n)}}return(t=document.createEvent("CustomEvent")).initCustomEvent("testingtheevent",!1,!0,{}),c.global.dispatchEvent(t),function(t,e){var n=document.createEvent("CustomEvent");return n.initCustomEvent(t.toLowerCase(),!1,!0,e),!c.global.dispatchEvent(n)}}catch(t){}return function(){return!1}}(),S=c.isNode?function(){return t.emit.apply(t,arguments)}:c.global?function(t){var e="on"+t.toLowerCase(),n=c.global[e];return!!n&&(n.apply(c.global,[].slice.call(arguments,1)),!0)}:function(){return!1};function j(t,e){return{promise:e}}var T={promiseCreated:j,promiseFulfilled:j,promiseRejected:j,promiseResolved:j,promiseCancelled:j,promiseChained:function(t,e,n){return{promise:e,child:n}},warning:function(t,e){return{warning:e}},unhandledRejection:function(t,e,n){return{reason:e,promise:n}},rejectionHandled:j},C=function(t){var e=!1;try{e=S.apply(null,arguments)}catch(t){u.throwLater(t),e=!0}var n=!1;try{n=E(t,T[t].apply(null,arguments))}catch(t){u.throwLater(t),n=!0}return n||e};function A(){return!1}function M(t,e,n){var r=this;try{t(e,n,function(t){if("function"!=typeof t)throw new TypeError("onCancel must be a function, got: "+c.toString(t));r._attachCancellationCallback(t)})}catch(t){return t}}function I(t){if(!this._isCancellable())return this;var e=this._onCancel();void 0!==e?c.isArray(e)?e.push(t):this._setOnCancel([e,t]):this._setOnCancel(t)}function R(){return this._onCancelField}function L(t){this._onCancelField=t}function B(){this._cancellationParent=void 0,this._onCancelField=void 0}function F(t,e){if(0!=(1&e)){this._cancellationParent=t;var n=t._branchesRemainingToCancel;void 0===n&&(n=0),t._branchesRemainingToCancel=n+1}0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)}n.config=function(t){if("longStackTraces"in(t=Object(t))&&(t.longStackTraces?n.longStackTraces():!t.longStackTraces&&n.hasLongStackTraces()&&k()),"warnings"in t){var e=t.warnings;K.warnings=!!e,x=K.warnings,c.isObject(e)&&"wForgottenReturn"in e&&(x=!!e.wForgottenReturn)}if("cancellation"in t&&t.cancellation&&!K.cancellation){if(u.haveItemsQueued())throw new Error("cannot enable cancellation after promises are in use");n.prototype._clearCancellationData=B,n.prototype._propagateFrom=F,n.prototype._onCancel=R,n.prototype._setOnCancel=L,n.prototype._attachCancellationCallback=I,n.prototype._execute=M,O=F,K.cancellation=!0}return"monitoring"in t&&(t.monitoring&&!K.monitoring?(K.monitoring=!0,n.prototype._fireEvent=C):!t.monitoring&&K.monitoring&&(K.monitoring=!1,n.prototype._fireEvent=A)),n},n.prototype._fireEvent=A,n.prototype._execute=function(t,e,n){try{t(e,n)}catch(t){return t}},n.prototype._onCancel=function(){},n.prototype._setOnCancel=function(t){},n.prototype._attachCancellationCallback=function(t){},n.prototype._captureStackTrace=function(){},n.prototype._attachExtraTrace=function(){},n.prototype._dereferenceTrace=function(){},n.prototype._clearCancellationData=function(){},n.prototype._propagateFrom=function(t,e){};var O=function(t,e){0!=(2&e)&&t._isBound()&&this._setBoundTo(t._boundTo)};function P(){var t=this._boundTo;return void 0!==t&&t instanceof n?t.isFulfilled()?t.value():void 0:t}function D(){this._trace=new J(this._peekContext())}function U(t,e){if(h(t)){var n=this._trace;if(void 0!==n&&e&&(n=n._parent),void 0!==n)n.attachExtraTrace(t);else if(!t.__stackCleaned__){var r=V(t);c.notEnumerableProp(t,"stack",r.message+"\n"+r.stack.join("\n")),c.notEnumerableProp(t,"__stackCleaned__",!0)}}}function N(){this._trace=void 0}function z(t,e,r){if(K.warnings){var i,a=new l(t);if(e)r._attachExtraTrace(a);else if(K.longStackTraces&&(i=n._peekContext()))i.attachExtraTrace(a);else{var o=V(a);a.stack=o.message+"\n"+o.stack.join("\n")}C("warning",a)||G(a,"",!0)}}function q(t){for(var e=[],n=0;n0?function(t){for(var e=t.stack.replace(/\s+$/g,"").split("\n"),n=0;n0&&"SyntaxError"!=t.name&&(e=e.slice(n)),e}(t):[" (No stack trace)"],{message:n,stack:"SyntaxError"==t.name?e:q(e)}}function G(t,e,n){if("undefined"!=typeof console){var r;if(c.isObject(t)){var i=t.stack;r=e+m(i,t)}else r=e+String(t);"function"==typeof o?o(r,n):"function"!=typeof console.log&&"object"!=typeof console.log||console.log(r)}}function H(t,e,n,r){var i=!1;try{"function"==typeof e&&(i=!0,"rejectionHandled"===t?e(r):e(n,r))}catch(t){u.throwLater(t)}"unhandledRejection"===t?C(t,n,r)||i||G(n,"Unhandled rejection "):C(t,r)}function W(t){var e;if("function"==typeof t)e="[function "+(t.name||"anonymous")+"]";else{e=t&&"function"==typeof t.toString?t.toString():c.toString(t);if(/\[object [a-zA-Z0-9$_]+\]/.test(e))try{e=JSON.stringify(t)}catch(t){}0===e.length&&(e="(empty array)")}return"(<"+function(t){if(t.length<41)return t;return t.substr(0,38)+"..."}(e)+">, no stack trace)"}function Z(){return"function"==typeof Q}var Y=function(){return!1},X=/[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/;function $(t){var e=t.match(X);if(e)return{fileName:e[1],line:parseInt(e[2],10)}}function J(t){this._parent=t,this._promisesCreated=0;var e=this._length=1+(void 0===t?0:t._length);Q(this,J),e>32&&this.uncycle()}c.inherits(J,Error),r.CapturedTrace=J,J.prototype.uncycle=function(){var t=this._length;if(!(t<2)){for(var e=[],n={},r=0,i=this;void 0!==i;++r)e.push(i),i=i._parent;for(r=(t=this._length=r)-1;r>=0;--r){var a=e[r].stack;void 0===n[a]&&(n[a]=r)}for(r=0;r0&&(e[o-1]._parent=void 0,e[o-1]._length=1),e[r]._parent=void 0,e[r]._length=1;var s=r>0?e[r-1]:this;o=0;--l)e[l]._length=u,u++;return}}}},J.prototype.attachExtraTrace=function(t){if(!t.__stackCleaned__){this.uncycle();for(var e=V(t),n=e.message,r=[e.stack],i=this;void 0!==i;)r.push(q(i.stack.split("\n"))),i=i._parent;!function(t){for(var e=t[0],n=1;n=0;--s)if(r[s]===a){o=s;break}for(s=o;s>=0;--s){var u=r[s];if(e[i]!==u)break;e.pop(),i--}e=r}}(r),function(t){for(var e=0;e=0)return g=/@/,m=e,_=!0,function(t){t.stack=(new Error).stack};try{throw new Error}catch(t){r="stack"in t}return"stack"in i||!r||"number"!=typeof Error.stackTraceLimit?(m=function(t,e){return"string"==typeof t?t:"object"!=typeof e&&"function"!=typeof e||void 0===e.name||void 0===e.message?W(e):e.toString()},null):(g=t,m=e,function(t){Error.stackTraceLimit+=6;try{throw new Error}catch(e){t.stack=e.stack}Error.stackTraceLimit-=6})}();"undefined"!=typeof console&&void 0!==console.warn&&(o=function(t){console.warn(t)},c.isNode&&t.stderr.isTTY?o=function(t,e){var n=e?"[33m":"[31m";console.warn(n+t+"[0m\n")}:c.isNode||"string"!=typeof(new Error).stack||(o=function(t,e){console.warn("%c"+t,e?"color: darkorange":"color: red")}));var K={warnings:b,longStackTraces:!1,cancellation:!1,monitoring:!1};return w&&n.longStackTraces(),{longStackTraces:function(){return K.longStackTraces},warnings:function(){return K.warnings},cancellation:function(){return K.cancellation},monitoring:function(){return K.monitoring},propagateFromFunction:function(){return O},boundValueFunction:function(){return P},checkForgottenReturns:function(t,e,n,r,i){if(void 0===t&&null!==e&&x){if(void 0!==i&&i._returnedNonUndefined())return;if(0==(65535&r._bitField))return;n&&(n+=" ");var a="",o="";if(e._trace){for(var s=e._trace.stack.split("\n"),u=q(s),l=u.length-1;l>=0;--l){var c=u[l];if(!d.test(c)){var f=c.match(v);f&&(a="at "+f[1]+":"+f[2]+":"+f[3]+" ");break}}if(u.length>0){var h=u[0];for(l=0;l0&&(o="\n"+s[l-1]);break}}}var p="a promise was created in a "+n+"handler "+a+"but was not returned from it, see http://goo.gl/rRqMUw"+o;r._warn(p,!0,e)}},setBounds:function(t,e){if(Z()){for(var n,r,i=t.stack.split("\n"),a=e.stack.split("\n"),o=-1,s=-1,u=0;u=s||(Y=function(t){if(p.test(t))return!0;var e=$(t);return!!(e&&e.fileName===n&&o<=e.line&&e.line<=s)})}},warn:z,deprecated:function(t,e){var n=t+" is deprecated and will be removed in a future version.";return e&&(n+=" Use "+e+" instead."),z(n)},CapturedTrace:J,fireDomEvent:E,fireGlobalEvent:S}}},{"./errors":12,"./es5":13,"./util":36}],10:[function(t,e,n){"use strict";e.exports=function(t){function e(){return this.value}function n(){throw this.reason}t.prototype.return=t.prototype.thenReturn=function(n){return n instanceof t&&n.suppressUnhandledRejections(),this._then(e,void 0,void 0,{value:n},void 0)},t.prototype.throw=t.prototype.thenThrow=function(t){return this._then(n,void 0,void 0,{reason:t},void 0)},t.prototype.catchThrow=function(t){if(arguments.length<=1)return this._then(void 0,n,void 0,{reason:t},void 0);var e=arguments[1];return this.caught(t,function(){throw e})},t.prototype.catchReturn=function(n){if(arguments.length<=1)return n instanceof t&&n.suppressUnhandledRejections(),this._then(void 0,e,void 0,{value:n},void 0);var r=arguments[1];r instanceof t&&r.suppressUnhandledRejections();return this.caught(n,function(){return r})}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t,e){var n=t.reduce,r=t.all;function i(){return r(this)}t.prototype.each=function(t){return n(this,t,e,0)._then(i,void 0,void 0,this,void 0)},t.prototype.mapSeries=function(t){return n(this,t,e,e)},t.each=function(t,r){return n(t,r,e,0)._then(i,void 0,void 0,t,void 0)},t.mapSeries=function(t,r){return n(t,r,e,e)}}},{}],12:[function(t,e,n){"use strict";var r,i,a=t("./es5"),o=a.freeze,s=t("./util"),u=s.inherits,l=s.notEnumerableProp;function c(t,e){function n(r){if(!(this instanceof n))return new n(r);l(this,"message","string"==typeof r?r:e),l(this,"name",t),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):Error.call(this)}return u(n,Error),n}var f=c("Warning","warning"),h=c("CancellationError","cancellation error"),p=c("TimeoutError","timeout error"),d=c("AggregateError","aggregate error");try{r=TypeError,i=RangeError}catch(t){r=c("TypeError","type error"),i=c("RangeError","range error")}for(var v="join pop push shift unshift slice filter forEach some every map indexOf lastIndexOf reduce reduceRight sort reverse".split(" "),g=0;g1?t.cancelPromise._reject(e):t.cancelPromise._cancel(),t.cancelPromise=null,!0)}function f(){return p.call(this,this.promise._target()._settledValue())}function h(t){if(!c(this,t))return o.e=t,o}function p(t){var i=this.promise,s=this.handler;if(!this.called){this.called=!0;var u=this.isFinallyHandler()?s.call(i._boundValue()):s.call(i._boundValue(),t);if(u===r)return u;if(void 0!==u){i._setReturnedNonUndefined();var p=n(u,i);if(p instanceof e){if(null!=this.cancelPromise){if(p._isCancelled()){var d=new a("late cancellation observer");return i._attachExtraTrace(d),o.e=d,o}p.isPending()&&p._attachCancellationCallback(new l(this))}return p._then(f,h,void 0,this,void 0)}}}return i.isRejected()?(c(this),o.e=t,o):(c(this),t)}return u.prototype.isFinallyHandler=function(){return 0===this.type},l.prototype._resultCancelled=function(){c(this.finallyHandler)},e.prototype._passThrough=function(t,e,n,r){return"function"!=typeof t?this.then():this._then(n,r,void 0,new u(this,e,t),void 0)},e.prototype.lastly=e.prototype.finally=function(t){return this._passThrough(t,0,p,p)},e.prototype.tap=function(t){return this._passThrough(t,1,p)},e.prototype.tapCatch=function(t){var n=arguments.length;if(1===n)return this._passThrough(t,1,void 0,p);var r,a=new Array(n-1),o=0;for(r=0;r0&&"function"==typeof arguments[e]&&(t=arguments[e]);var r=[].slice.call(arguments);t&&r.pop();var i=new n(r).promise();return void 0!==t?i.spread(t):i}}},{"./util":36}],18:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a,o){var s=e._getDomain,u=t("./util"),l=u.tryCatch,c=u.errorObj,f=e._async;function h(t,e,n,r){this.constructor$(t),this._promise._captureStackTrace();var i=s();this._callback=null===i?e:u.domainBind(i,e),this._preservedValues=r===a?new Array(this.length()):null,this._limit=n,this._inFlight=0,this._queue=[],f.invoke(this._asyncInit,this,void 0)}function p(t,n,i,a){if("function"!=typeof n)return r("expecting a function but got "+u.classString(n));var o=0;if(void 0!==i){if("object"!=typeof i||null===i)return e.reject(new TypeError("options argument must be an object but it is "+u.classString(i)));if("number"!=typeof i.concurrency)return e.reject(new TypeError("'concurrency' must be a number but it is "+u.classString(i.concurrency)));o=i.concurrency}return new h(t,n,o="number"==typeof o&&isFinite(o)&&o>=1?o:0,a).promise()}u.inherits(h,n),h.prototype._asyncInit=function(){this._init$(void 0,-2)},h.prototype._init=function(){},h.prototype._promiseFulfilled=function(t,n){var r=this._values,a=this.length(),s=this._preservedValues,u=this._limit;if(n<0){if(r[n=-1*n-1]=t,u>=1&&(this._inFlight--,this._drainQueue(),this._isResolved()))return!0}else{if(u>=1&&this._inFlight>=u)return r[n]=t,this._queue.push(n),!1;null!==s&&(s[n]=t);var f=this._promise,h=this._callback,p=f._boundValue();f._pushContext();var d=l(h).call(p,t,n,a),v=f._popContext();if(o.checkForgottenReturns(d,v,null!==s?"Promise.filter":"Promise.map",f),d===c)return this._reject(d.e),!0;var g=i(d,this._promise);if(g instanceof e){var m=(g=g._target())._bitField;if(0==(50397184&m))return u>=1&&this._inFlight++,r[n]=g,g._proxy(this,-1*(n+1)),!1;if(0==(33554432&m))return 0!=(16777216&m)?(this._reject(g._reason()),!0):(this._cancel(),!0);d=g._value()}r[n]=d}return++this._totalResolved>=a&&(null!==s?this._filter(r,s):this._resolve(r),!0)},h.prototype._drainQueue=function(){for(var t=this._queue,e=this._limit,n=this._values;t.length>0&&this._inFlight1){a.deprecated("calling Promise.try with more than 1 argument");var l=arguments[1],c=arguments[2];r=o.isArray(l)?s(t).apply(c,l):s(t).call(c,l)}else r=s(t)();var f=u._popContext();return a.checkForgottenReturns(r,f,"Promise.try",u),u._resolveFromSyncValue(r),u},e.prototype._resolveFromSyncValue=function(t){t===o.errorObj?this._rejectCallback(t.e,!1):this._resolveCallback(t,!0)}}},{"./util":36}],20:[function(t,e,n){"use strict";var r=t("./util"),i=r.maybeWrapAsError,a=t("./errors").OperationalError,o=t("./es5");var s=/^(?:name|message|stack|cause)$/;function u(t){var e;if(function(t){return t instanceof Error&&o.getPrototypeOf(t)===Error.prototype}(t)){(e=new a(t)).name=t.name,e.message=t.message,e.stack=t.stack;for(var n=o.keys(t),i=0;i1){var n,r=new Array(e-1),i=0;for(n=0;n0&&"function"!=typeof t&&"function"!=typeof e){var n=".then() only accepts functions but was passed: "+l.classString(t);arguments.length>1&&(n+=", "+l.classString(e)),this._warn(n)}return this._then(t,e,void 0,void 0,void 0)},A.prototype.done=function(t,e){this._then(t,e,void 0,void 0,void 0)._setIsFinal()},A.prototype.spread=function(t){return"function"!=typeof t?a("expecting a function but got "+l.classString(t)):this.all()._then(t,void 0,void 0,m,void 0)},A.prototype.toJSON=function(){var t={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};return this.isFulfilled()?(t.fulfillmentValue=this.value(),t.isFulfilled=!0):this.isRejected()&&(t.rejectionReason=this.reason(),t.isRejected=!0),t},A.prototype.all=function(){return arguments.length>0&&this._warn(".all() was passed arguments but it does not take any"),new b(this).promise()},A.prototype.error=function(t){return this.caught(l.originatesFromRejection,t)},A.getNewLibraryCopy=n.exports,A.is=function(t){return t instanceof A},A.fromNode=A.fromCallback=function(t){var e=new A(g);e._captureStackTrace();var n=arguments.length>1&&!!Object(arguments[1]).multiArgs,r=C(t)(j(e,n));return r===T&&e._rejectCallback(r.e,!0),e._isFateSealed()||e._setAsyncGuaranteed(),e},A.all=function(t){return new b(t).promise()},A.cast=function(t){var e=y(t);return e instanceof A||((e=new A(g))._captureStackTrace(),e._setFulfilled(),e._rejectionHandler0=t),e},A.resolve=A.fulfilled=A.cast,A.reject=A.rejected=function(t){var e=new A(g);return e._captureStackTrace(),e._rejectCallback(t,!0),e},A.setScheduler=function(t){if("function"!=typeof t)throw new d("expecting a function but got "+l.classString(t));return h.setScheduler(t)},A.prototype._then=function(t,e,n,r,i){var a=void 0!==i,o=a?i:new A(g),u=this._target(),c=u._bitField;a||(o._propagateFrom(this,3),o._captureStackTrace(),void 0===r&&0!=(2097152&this._bitField)&&(r=0!=(50397184&c)?this._boundValue():u===this?void 0:this._boundTo),this._fireEvent("promiseChained",this,o));var f=s();if(0!=(50397184&c)){var p,d,m=u._settlePromiseCtx;0!=(33554432&c)?(d=u._rejectionHandler0,p=t):0!=(16777216&c)?(d=u._fulfillmentHandler0,p=e,u._unsetRejectionIsUnhandled()):(m=u._settlePromiseLateCancellationObserver,d=new v("late cancellation observer"),u._attachExtraTrace(d),p=e),h.invoke(m,u,{handler:null===f?p:"function"==typeof p&&l.domainBind(f,p),promise:o,receiver:r,value:d})}else u._addCallbacks(t,e,o,r,f);return o},A.prototype._length=function(){return 65535&this._bitField},A.prototype._isFateSealed=function(){return 0!=(117506048&this._bitField)},A.prototype._isFollowing=function(){return 67108864==(67108864&this._bitField)},A.prototype._setLength=function(t){this._bitField=-65536&this._bitField|65535&t},A.prototype._setFulfilled=function(){this._bitField=33554432|this._bitField,this._fireEvent("promiseFulfilled",this)},A.prototype._setRejected=function(){this._bitField=16777216|this._bitField,this._fireEvent("promiseRejected",this)},A.prototype._setFollowing=function(){this._bitField=67108864|this._bitField,this._fireEvent("promiseResolved",this)},A.prototype._setIsFinal=function(){this._bitField=4194304|this._bitField},A.prototype._isFinal=function(){return(4194304&this._bitField)>0},A.prototype._unsetCancelled=function(){this._bitField=-65537&this._bitField},A.prototype._setCancelled=function(){this._bitField=65536|this._bitField,this._fireEvent("promiseCancelled",this)},A.prototype._setWillBeCancelled=function(){this._bitField=8388608|this._bitField},A.prototype._setAsyncGuaranteed=function(){h.hasCustomScheduler()||(this._bitField=134217728|this._bitField)},A.prototype._receiverAt=function(t){var e=0===t?this._receiver0:this[4*t-4+3];if(e!==u)return void 0===e&&this._isBound()?this._boundValue():e},A.prototype._promiseAt=function(t){return this[4*t-4+2]},A.prototype._fulfillmentHandlerAt=function(t){return this[4*t-4+0]},A.prototype._rejectionHandlerAt=function(t){return this[4*t-4+1]},A.prototype._boundValue=function(){},A.prototype._migrateCallback0=function(t){t._bitField;var e=t._fulfillmentHandler0,n=t._rejectionHandler0,r=t._promise0,i=t._receiverAt(0);void 0===i&&(i=u),this._addCallbacks(e,n,r,i,null)},A.prototype._migrateCallbackAt=function(t,e){var n=t._fulfillmentHandlerAt(e),r=t._rejectionHandlerAt(e),i=t._promiseAt(e),a=t._receiverAt(e);void 0===a&&(a=u),this._addCallbacks(n,r,i,a,null)},A.prototype._addCallbacks=function(t,e,n,r,i){var a=this._length();if(a>=65531&&(a=0,this._setLength(0)),0===a)this._promise0=n,this._receiver0=r,"function"==typeof t&&(this._fulfillmentHandler0=null===i?t:l.domainBind(i,t)),"function"==typeof e&&(this._rejectionHandler0=null===i?e:l.domainBind(i,e));else{var o=4*a-4;this[o+2]=n,this[o+3]=r,"function"==typeof t&&(this[o+0]=null===i?t:l.domainBind(i,t)),"function"==typeof e&&(this[o+1]=null===i?e:l.domainBind(i,e))}return this._setLength(a+1),a},A.prototype._proxy=function(t,e){this._addCallbacks(void 0,void 0,e,t,null)},A.prototype._resolveCallback=function(t,e){if(0==(117506048&this._bitField)){if(t===this)return this._rejectCallback(r(),!1);var n=y(t,this);if(!(n instanceof A))return this._fulfill(t);e&&this._propagateFrom(n,2);var i=n._target();if(i!==this){var a=i._bitField;if(0==(50397184&a)){var o=this._length();o>0&&i._migrateCallback0(this);for(var s=1;s>>16)){if(t===this){var n=r();return this._attachExtraTrace(n),this._reject(n)}this._setFulfilled(),this._rejectionHandler0=t,(65535&e)>0&&(0!=(134217728&e)?this._settlePromises():h.settlePromises(this),this._dereferenceTrace())}},A.prototype._reject=function(t){var e=this._bitField;if(!((117506048&e)>>>16)){if(this._setRejected(),this._fulfillmentHandler0=t,this._isFinal())return h.fatalError(t,l.isNode);(65535&e)>0?h.settlePromises(this):this._ensurePossibleRejectionHandled()}},A.prototype._fulfillPromises=function(t,e){for(var n=1;n0){if(0!=(16842752&t)){var n=this._fulfillmentHandler0;this._settlePromise0(this._rejectionHandler0,n,t),this._rejectPromises(e,n)}else{var r=this._rejectionHandler0;this._settlePromise0(this._fulfillmentHandler0,r,t),this._fulfillPromises(e,r)}this._setLength(0)}this._clearCancellationData()},A.prototype._settledValue=function(){var t=this._bitField;return 0!=(33554432&t)?this._rejectionHandler0:0!=(16777216&t)?this._fulfillmentHandler0:void 0},A.defer=A.pending=function(){return k.deprecated("Promise.defer","new Promise"),{promise:new A(g),resolve:M,reject:I}},l.notEnumerableProp(A,"_makeSelfResolutionError",r),e("./method")(A,g,y,a,k),e("./bind")(A,g,y,k),e("./cancel")(A,b,a,k),e("./direct_resolve")(A),e("./synchronous_inspection")(A),e("./join")(A,b,y,g,h,s),A.Promise=A,A.version="3.5.2",e("./map.js")(A,b,a,y,g,k),e("./call_get.js")(A),e("./using.js")(A,a,y,x,g,k),e("./timers.js")(A,g,k),e("./generators.js")(A,a,g,y,o,k),e("./nodeify.js")(A),e("./promisify.js")(A,g),e("./props.js")(A,b,y,a),e("./race.js")(A,g,y,a),e("./reduce.js")(A,b,a,y,g,k),e("./settle.js")(A,b,k),e("./some.js")(A,b,a),e("./filter.js")(A,g),e("./each.js")(A,g),e("./any.js")(A),l.toFastProperties(A),l.toFastProperties(A.prototype),R({a:1}),R({b:2}),R({c:3}),R(1),R(function(){}),R(void 0),R(!1),R(new A(g)),k.setBounds(f.firstLineError,l.lastLineError),A}},{"./any.js":1,"./async":2,"./bind":3,"./call_get.js":5,"./cancel":6,"./catch_filter":7,"./context":8,"./debuggability":9,"./direct_resolve":10,"./each.js":11,"./errors":12,"./es5":13,"./filter.js":14,"./finally":15,"./generators.js":16,"./join":17,"./map.js":18,"./method":19,"./nodeback":20,"./nodeify.js":21,"./promise_array":23,"./promisify.js":24,"./props.js":25,"./race.js":27,"./reduce.js":28,"./settle.js":30,"./some.js":31,"./synchronous_inspection":32,"./thenables":33,"./timers.js":34,"./using.js":35,"./util":36}],23:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a){var o=t("./util");o.isArray;function s(t){var r=this._promise=new e(n);t instanceof e&&r._propagateFrom(t,3),r._setOnCancel(this),this._values=t,this._length=0,this._totalResolved=0,this._init(void 0,-2)}return o.inherits(s,a),s.prototype.length=function(){return this._length},s.prototype.promise=function(){return this._promise},s.prototype._init=function t(n,a){var s=r(this._values,this._promise);if(s instanceof e){var u=(s=s._target())._bitField;if(this._values=s,0==(50397184&u))return this._promise._setAsyncGuaranteed(),s._then(t,this._reject,void 0,this,a);if(0==(33554432&u))return 0!=(16777216&u)?this._reject(s._reason()):this._cancel();s=s._value()}if(null!==(s=o.asArray(s)))0!==s.length?this._iterate(s):-5===a?this._resolveEmptyArray():this._resolve(function(t){switch(t){case-2:return[];case-3:return{};case-6:return new Map}}(a));else{var l=i("expecting an array or an iterable object but got "+o.classString(s)).reason();this._promise._rejectCallback(l,!1)}},s.prototype._iterate=function(t){var n=this.getActualLength(t.length);this._length=n,this._values=this.shouldCopyValues()?new Array(n):this._values;for(var i=this._promise,a=!1,o=null,s=0;s=this._length&&(this._resolve(this._values),!0)},s.prototype._promiseCancelled=function(){return this._cancel(),!0},s.prototype._promiseRejected=function(t){return this._totalResolved++,this._reject(t),!0},s.prototype._resultCancelled=function(){if(!this._isResolved()){var t=this._values;if(this._cancel(),t instanceof e)t.cancel();else for(var n=0;n=this._length){var n;if(this._isMap)n=function(t){for(var e=new a,n=t.length/2|0,r=0;r>1},e.prototype.props=function(){return f(this)},e.props=function(t){return f(t)}}},{"./es5":13,"./util":36}],26:[function(t,e,n){"use strict";function r(t){this._capacity=t,this._length=0,this._front=0}r.prototype._willBeOverCapacity=function(t){return this._capacity=this._length&&(this._resolve(this._values),!0)},a.prototype._promiseFulfilled=function(t,e){var n=new i;return n._bitField=33554432,n._settledValueField=t,this._promiseResolved(e,n)},a.prototype._promiseRejected=function(t,e){var n=new i;return n._bitField=16777216,n._settledValueField=t,this._promiseResolved(e,n)},e.settle=function(t){return r.deprecated(".settle()",".reflect()"),new a(t).promise()},e.prototype.settle=function(){return e.settle(this)}}},{"./util":36}],31:[function(t,e,n){"use strict";e.exports=function(e,n,r){var i=t("./util"),a=t("./errors").RangeError,o=t("./errors").AggregateError,s=i.isArray,u={};function l(t){this.constructor$(t),this._howMany=0,this._unwrap=!1,this._initialized=!1}function c(t,e){if((0|e)!==e||e<0)return r("expecting a positive integer\n\n See http://goo.gl/MqrFmX\n");var n=new l(t),i=n.promise();return n.setHowMany(e),n.init(),i}i.inherits(l,n),l.prototype._init=function(){if(this._initialized)if(0!==this._howMany){this._init$(void 0,-5);var t=s(this._values);!this._isResolved()&&t&&this._howMany>this._canPossiblyFulfill()&&this._reject(this._getRangeError(this.length()))}else this._resolve([])},l.prototype.init=function(){this._initialized=!0,this._init()},l.prototype.setUnwrap=function(){this._unwrap=!0},l.prototype.howMany=function(){return this._howMany},l.prototype.setHowMany=function(t){this._howMany=t},l.prototype._promiseFulfilled=function(t){return this._addFulfilled(t),this._fulfilled()===this.howMany()&&(this._values.length=this.howMany(),1===this.howMany()&&this._unwrap?this._resolve(this._values[0]):this._resolve(this._values),!0)},l.prototype._promiseRejected=function(t){return this._addRejected(t),this._checkOutcome()},l.prototype._promiseCancelled=function(){return this._values instanceof e||null==this._values?this._cancel():(this._addRejected(u),this._checkOutcome())},l.prototype._checkOutcome=function(){if(this.howMany()>this._canPossiblyFulfill()){for(var t=new o,e=this.length();e0?this._reject(t):this._cancel(),!0}return!1},l.prototype._fulfilled=function(){return this._totalResolved},l.prototype._rejected=function(){return this._values.length-this.length()},l.prototype._addRejected=function(t){this._values.push(t)},l.prototype._addFulfilled=function(t){this._values[this._totalResolved++]=t},l.prototype._canPossiblyFulfill=function(){return this.length()-this._rejected()},l.prototype._getRangeError=function(t){var e="Input array must contain at least "+this._howMany+" items but contains only "+t+" items";return new a(e)},l.prototype._resolveEmptyArray=function(){this._reject(this._getRangeError(0))},e.some=function(t,e){return c(t,e)},e.prototype.some=function(t){return c(this,t)},e._SomePromiseArray=l}},{"./errors":12,"./util":36}],32:[function(t,e,n){"use strict";e.exports=function(t){function e(t){void 0!==t?(t=t._target(),this._bitField=t._bitField,this._settledValueField=t._isFateSealed()?t._settledValue():void 0):(this._bitField=0,this._settledValueField=void 0)}e.prototype._settledValue=function(){return this._settledValueField};var n=e.prototype.value=function(){if(!this.isFulfilled())throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},r=e.prototype.error=e.prototype.reason=function(){if(!this.isRejected())throw new TypeError("cannot get rejection reason of a non-rejected promise\n\n See http://goo.gl/MqrFmX\n");return this._settledValue()},i=e.prototype.isFulfilled=function(){return 0!=(33554432&this._bitField)},a=e.prototype.isRejected=function(){return 0!=(16777216&this._bitField)},o=e.prototype.isPending=function(){return 0==(50397184&this._bitField)},s=e.prototype.isResolved=function(){return 0!=(50331648&this._bitField)};e.prototype.isCancelled=function(){return 0!=(8454144&this._bitField)},t.prototype.__isCancelled=function(){return 65536==(65536&this._bitField)},t.prototype._isCancelled=function(){return this._target().__isCancelled()},t.prototype.isCancelled=function(){return 0!=(8454144&this._target()._bitField)},t.prototype.isPending=function(){return o.call(this._target())},t.prototype.isRejected=function(){return a.call(this._target())},t.prototype.isFulfilled=function(){return i.call(this._target())},t.prototype.isResolved=function(){return s.call(this._target())},t.prototype.value=function(){return n.call(this._target())},t.prototype.reason=function(){var t=this._target();return t._unsetRejectionIsUnhandled(),r.call(t)},t.prototype._value=function(){return this._settledValue()},t.prototype._reason=function(){return this._unsetRejectionIsUnhandled(),this._settledValue()},t.PromiseInspection=e}},{}],33:[function(t,e,n){"use strict";e.exports=function(e,n){var r=t("./util"),i=r.errorObj,a=r.isObject;var o={}.hasOwnProperty;return function(t,s){if(a(t)){if(t instanceof e)return t;var u=function(t){try{return function(t){return t.then}(t)}catch(t){return i.e=t,i}}(t);if(u===i){s&&s._pushContext();var l=e.reject(u.e);return s&&s._popContext(),l}if("function"==typeof u)return function(t){try{return o.call(t,"_promise0")}catch(t){return!1}}(t)?(l=new e(n),t._then(l._fulfill,l._reject,void 0,l,null),l):function(t,a,o){var s=new e(n),u=s;o&&o._pushContext(),s._captureStackTrace(),o&&o._popContext();var l=!0,c=r.tryCatch(a).call(t,function(t){s&&(s._resolveCallback(t),s=null)},function(t){s&&(s._rejectCallback(t,l,!0),s=null)});return l=!1,s&&c===i&&(s._rejectCallback(c.e,!0,!0),s=null),u}(t,u,s)}return t}}},{"./util":36}],34:[function(t,e,n){"use strict";e.exports=function(e,n,r){var i=t("./util"),a=e.TimeoutError;function o(t){this.handle=t}o.prototype._resultCancelled=function(){clearTimeout(this.handle)};var s=function(t){return u(+this).thenReturn(t)},u=e.delay=function(t,i){var a,u;return void 0!==i?(a=e.resolve(i)._then(s,null,null,t,void 0),r.cancellation()&&i instanceof e&&a._setOnCancel(i)):(a=new e(n),u=setTimeout(function(){a._fulfill()},+t),r.cancellation()&&a._setOnCancel(new o(u)),a._captureStackTrace()),a._setAsyncGuaranteed(),a};e.prototype.delay=function(t){return u(t,this)};function l(t){return clearTimeout(this.handle),t}function c(t){throw clearTimeout(this.handle),t}e.prototype.timeout=function(t,e){var n,s;t=+t;var u=new o(setTimeout(function(){n.isPending()&&function(t,e,n){var r;r="string"!=typeof e?e instanceof Error?e:new a("operation timed out"):new a(e),i.markAsOriginatingFromRejection(r),t._attachExtraTrace(r),t._reject(r),null!=n&&n.cancel()}(n,e,s)},t));return r.cancellation()?(s=this.then(),(n=s._then(l,c,void 0,u,void 0))._setOnCancel(u)):n=this._then(l,c,void 0,u,void 0),n}}},{"./util":36}],35:[function(t,e,n){"use strict";e.exports=function(e,n,r,i,a,o){var s=t("./util"),u=t("./errors").TypeError,l=t("./util").inherits,c=s.errorObj,f=s.tryCatch,h={};function p(t){setTimeout(function(){throw t},0)}function d(t,n){var i=0,o=t.length,s=new e(a);return function a(){if(i>=o)return s._fulfill();var u=function(t){var e=r(t);return e!==t&&"function"==typeof t._isDisposable&&"function"==typeof t._getDisposer&&t._isDisposable()&&e._setDisposable(t._getDisposer()),e}(t[i++]);if(u instanceof e&&u._isDisposable()){try{u=r(u._getDisposer().tryDispose(n),t.promise)}catch(t){return p(t)}if(u instanceof e)return u._then(a,p,null,null,null)}a()}(),s}function v(t,e,n){this._data=t,this._promise=e,this._context=n}function g(t,e,n){this.constructor$(t,e,n)}function m(t){return v.isDisposer(t)?(this.resources[this.index]._setDisposable(t),t.promise()):t}function _(t){this.length=t,this.promise=null,this[t-1]=null}v.prototype.data=function(){return this._data},v.prototype.promise=function(){return this._promise},v.prototype.resource=function(){return this.promise().isFulfilled()?this.promise().value():h},v.prototype.tryDispose=function(t){var e=this.resource(),n=this._context;void 0!==n&&n._pushContext();var r=e!==h?this.doDispose(e,t):null;return void 0!==n&&n._popContext(),this._promise._unsetDisposable(),this._data=null,r},v.isDisposer=function(t){return null!=t&&"function"==typeof t.resource&&"function"==typeof t.tryDispose},l(g,v),g.prototype.doDispose=function(t,e){return this.data().call(t,t,e)},_.prototype._resultCancelled=function(){for(var t=this.length,n=0;n0},e.prototype._getDisposer=function(){return this._disposer},e.prototype._unsetDisposable=function(){this._bitField=-131073&this._bitField,this._disposer=void 0},e.prototype.disposer=function(t){if("function"==typeof t)return new g(t,this,i());throw new u}}},{"./errors":12,"./util":36}],36:[function(e,n,i){"use strict";var a=e("./es5"),o="undefined"==typeof navigator,s={e:{}},u,l="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==r?r:void 0!==this?this:null;function c(){try{var t=u;return u=null,t.apply(this,arguments)}catch(t){return s.e=t,s}}function f(t){return u=t,c}var h=function(t,e){var n={}.hasOwnProperty;function r(){for(var r in this.constructor=t,this.constructor$=e,e.prototype)n.call(e.prototype,r)&&"$"!==r.charAt(r.length-1)&&(this[r+"$"]=e.prototype[r])}return r.prototype=e.prototype,t.prototype=new r,t.prototype};function p(t){return null==t||!0===t||!1===t||"string"==typeof t||"number"==typeof t}function d(t){return"function"==typeof t||"object"==typeof t&&null!==t}function v(t){return p(t)?new Error(T(t)):t}function g(t,e){var n,r=t.length,i=new Array(r+1);for(n=0;n1,r=e.length>0&&!(1===e.length&&"constructor"===e[0]),i=w.test(t+"")&&a.names(t).length>0;if(n||r||i)return!0}return!1}catch(t){return!1}}function k(t){function e(){}e.prototype=t;var n=new e;function r(){return typeof n.foo}return r(),r(),t}var E=/^[a-z$_][a-z$_0-9]*$/i;function S(t){return E.test(t)}function j(t,e,n){for(var r=new Array(t),i=0;i10||V[0]>0),q.isNode&&q.toFastProperties(t);try{throw new Error}catch(t){q.lastLineError=t}n.exports=q},{"./es5":13}]},{},[4])(4)}),"undefined"!=typeof window&&null!==window?window.P=window.Promise:"undefined"!=typeof self&&null!==self&&(self.P=self.Promise)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{_process:117,timers:142}],4:[function(t,e,n){},{}],5:[function(t,e,n){(function(n){var r=t("tty"),i=t("./lib/encode"),a=t("stream").Stream,o=e.exports=function(){var t=null;function e(e){if(t)throw new Error("multiple inputs specified");t=e}var i=null;function a(t){if(i)throw new Error("multiple outputs specified");i=t}for(var o=0;o0&&this.down(e),t>0?this.right(t):t<0&&this.left(-t),this},s.prototype.up=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"A")),this},s.prototype.down=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"B")),this},s.prototype.right=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"C")),this},s.prototype.left=function(t){return void 0===t&&(t=1),this.write(i("["+Math.floor(t)+"D")),this},s.prototype.column=function(t){return this.write(i("["+Math.floor(t)+"G")),this},s.prototype.push=function(t){return this.write(i(t?"7":"[s")),this},s.prototype.pop=function(t){return this.write(i(t?"8":"[u")),this},s.prototype.erase=function(t){return"end"===t||"$"===t?this.write(i("[K")):"start"===t||"^"===t?this.write(i("[1K")):"line"===t?this.write(i("[2K")):"down"===t?this.write(i("[J")):"up"===t?this.write(i("[1J")):"screen"===t?this.write(i("[1J")):this.emit("error",new Error("Unknown erase type: "+t)),this},s.prototype.display=function(t){var e={reset:0,bright:1,dim:2,underscore:4,blink:5,reverse:7,hidden:8}[t];return void 0===e&&this.emit("error",new Error("Unknown attribute: "+t)),this.write(i("["+e+"m")),this},s.prototype.foreground=function(t){if("number"==typeof t)(t<0||t>=256)&&this.emit("error",new Error("Color out of range: "+t)),this.write(i("[38;5;"+t+"m"));else{var e={black:30,red:31,green:32,yellow:33,blue:34,magenta:35,cyan:36,white:37}[t.toLowerCase()];e||this.emit("error",new Error("Unknown color: "+t)),this.write(i("["+e+"m"))}return this},s.prototype.background=function(t){if("number"==typeof t)(t<0||t>=256)&&this.emit("error",new Error("Color out of range: "+t)),this.write(i("[48;5;"+t+"m"));else{var e={black:40,red:41,green:42,yellow:43,blue:44,magenta:45,cyan:46,white:47}[t.toLowerCase()];e||this.emit("error",new Error("Unknown color: "+t)),this.write(i("["+e+"m"))}return this},s.prototype.cursor=function(t){return this.write(i(t?"[?25h":"[?25l")),this};var u=o.extractCodes=function(t){for(var e=[],n=-1,r=0;r=0&&e.push(t.slice(n,r)),n=r):n>=0&&r===t.length-1&&e.push(t.slice(n));return e}}).call(this,t("_process"))},{"./lib/encode":6,_process:117,stream:139,tty:143}],6:[function(t,e,n){(function(t){var n=(e.exports=function(e){return new t([27].concat(function t(e){return"string"==typeof e?e.split("").map(n):Array.isArray(e)?e.reduce(function(e,n){return e.concat(t(n))},[]):void 0}(e)))}).ord=function(t){return t.charCodeAt(0)}}).call(this,t("buffer").Buffer)},{buffer:47}],7:[function(t,e,n){(function(n){"use strict";var r=t("readable-stream").Readable,i=t("util");function a(t,e){if(!(this instanceof a))return new a(t,e);r.call(this,e),null!==t&&void 0!==t||(t=String(t)),this._obj=t}e.exports=a,i.inherits(a,r),a.prototype._read=function(t){var e=this._obj;"string"==typeof e?this.push(new n(e)):n.isBuffer(e)?this.push(e):this.push(new n(JSON.stringify(e))),this.push(null)}}).call(this,t("buffer").Buffer)},{buffer:47,"readable-stream":13,util:150}],8:[function(t,e,n){(function(n){e.exports=s;var r=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e},i=t("core-util-is");i.inherits=t("inherits");var a=t("./_stream_readable"),o=t("./_stream_writable");function s(t){if(!(this instanceof s))return new s(t);a.call(this,t),o.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",u)}function u(){this.allowHalfOpen||this._writableState.ended||n.nextTick(this.end.bind(this))}i.inherits(s,a),function(t,e){for(var n=0,r=t.length;n0?d(t):b(t)}(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!o){var u=new Error("stream.push() after EOF");t.emit("error",u)}else if(e.endEmitted&&o){u=new Error("stream.unshift() after end event");t.emit("error",u)}else!e.decoder||o||a||(r=e.decoder.write(r)),e.length+=e.objectMode?1:r.length,o?e.buffer.unshift(r):(e.reading=!1,e.buffer.push(r)),e.needReadable&&d(t),function(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(function(){!function(t,e){var n=e.length;for(;!e.reading&&!e.flowing&&!e.ended&&e.lengthe.highWaterMark&&(e.highWaterMark=function(t){if(t>=h)t=h;else{t--;for(var e=1;e<32;e<<=1)t|=t>>e;t++}return t}(t)),t>e.length?e.ended?e.length:(e.needReadable=!0,0):t)}function d(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,e.sync?n.nextTick(function(){v(t)}):v(t))}function v(t){t.emit("readable")}function g(t){var e,n=t._readableState;function r(t,r,i){!1===t.write(e)&&n.awaitDrain++}for(n.awaitDrain=0;n.pipesCount&&null!==(e=t.read());)if(1===n.pipesCount?r(n.pipes):w(n.pipes,r),t.emit("data",e),n.awaitDrain>0)return;if(0===n.pipesCount)return n.flowing=!1,void(a.listenerCount(t,"data")>0&&_(t));n.ranOut=!0}function m(){this._readableState.ranOut&&(this._readableState.ranOut=!1,g(this))}function _(t,e){if(t._readableState.flowing)throw new Error("Cannot switch to old mode now.");var r=e||!1,i=!1;t.readable=!0,t.pipe=s.prototype.pipe,t.on=t.addListener=s.prototype.on,t.on("readable",function(){var e;for(i=!0;!r&&null!==(e=t.read());)t.emit("data",e);null===e&&(i=!1,t._readableState.needReadable=!0)}),t.pause=function(){r=!0,this.emit("pause")},t.resume=function(){r=!1,i?n.nextTick(function(){t.emit("readable")}):this.read(0),this.emit("resume")},t.emit("readable")}function y(t,e){var n,r=e.buffer,a=e.length,o=!!e.decoder,s=!!e.objectMode;if(0===r.length)return null;if(0===a)n=null;else if(s)n=r.shift();else if(!t||t>=a)n=o?r.join(""):i.concat(r,a),r.length=0;else{if(t0)throw new Error("endReadable called on non-empty stream");!e.endEmitted&&e.calledRead&&(e.ended=!0,n.nextTick(function(){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}))}function w(t,e){for(var n=0,r=t.length;n0)&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return d(this),null;if(0===(t=p(t,e))&&e.ended)return n=null,e.length>0&&e.decoder&&(n=y(t,e),e.length-=n.length),0===e.length&&b(this),n;var i=e.needReadable;return e.length-t<=e.highWaterMark&&(i=!0),(e.ended||e.reading)&&(i=!1),i&&(e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1),i&&!e.reading&&(t=p(r,e)),null===(n=t>0?y(t,e):null)&&(e.needReadable=!0,t=0),e.length-=t,0!==e.length||e.ended||(e.needReadable=!0),e.ended&&!e.endEmitted&&0===e.length&&b(this),n},c.prototype._read=function(t){this.emit("error",new Error("not implemented"))},c.prototype.pipe=function(t,e){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1;var s=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?l:f;function u(t){t===i&&f()}function l(){t.end()}o.endEmitted?n.nextTick(s):i.once("end",s),t.on("unpipe",u);var c=function(t){return function(){var e=t._readableState;e.awaitDrain--,0===e.awaitDrain&&g(t)}}(i);function f(){t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",u),i.removeListener("end",l),i.removeListener("end",f),t._writableState&&!t._writableState.needDrain||c()}function h(e){v(),t.removeListener("error",h),0===a.listenerCount(t,"error")&&t.emit("error",e)}function p(){t.removeListener("finish",d),v()}function d(){t.removeListener("close",p),v()}function v(){i.unpipe(t)}return t.on("drain",c),t._events&&t._events.error?r(t._events.error)?t._events.error.unshift(h):t._events.error=[h,t._events.error]:t.on("error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",i),o.flowing||(this.on("readable",m),o.flowing=!0,n.nextTick(function(){g(i)})),t},c.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,this.removeListener("readable",m),e.flowing=!1,t&&t.emit("unpipe",this),this);if(!t){var n=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,this.removeListener("readable",m),e.flowing=!1;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)e.scalarArgs.push(i),e.shimArgs.push("scalar"+i);else if("index"===a){if(e.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(e.shapeArgs.push(i),in.length)throw new Error("cwise: Too many arguments in pre() block");if(e.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(e.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return e.debug=!!t.printCode||!!t.debug,e.funcName=t.funcName||"cwise",e.blockSize=t.blockSize||64,r(e)}},{"./lib/thunk.js":17}],16:[function(t,e,n){"use strict";var r=t("uniq");function i(t,e,n){var r,i,a=t.length,o=e.arrayArgs.length,s=e.indexArgs.length>0,u=[],l=[],c=0,f=0;for(r=0;r0&&u.push("var "+l.join(",")),r=a-1;r>=0;--r)c=t[r],u.push(["for(i",r,"=0;i",r,"0&&u.push(["index[",f,"]-=s",f].join("")),u.push(["++index[",c,"]"].join(""))),u.push("}")}return u.join("\n")}function a(t,e,n){for(var r=t.body,i=[],a=[],o=0;o0&&_.push("shape=SS.slice(0)"),t.indexArgs.length>0){var y=new Array(n);for(u=0;u0&&m.push("var "+_.join(",")),u=0;u3&&m.push(a(t.pre,t,s));var k=a(t.body,t,s),E=function(t){for(var e=0,n=t[0].length;e0,l=[],c=0;c0;){"].join("")),l.push(["if(j",c,"<",s,"){"].join("")),l.push(["s",e[c],"=j",c].join("")),l.push(["j",c,"=0"].join("")),l.push(["}else{s",e[c],"=",s].join("")),l.push(["j",c,"-=",s,"}"].join("")),u&&l.push(["index[",e[c],"]=j",c].join(""));for(c=0;c3&&m.push(a(t.post,t,s)),t.debug&&console.log("-----Generated cwise routine for ",e,":\n"+m.join("\n")+"\n----------");var S=[t.funcName||"unnamed","_cwise_loop_",o[0].join("s"),"m",E,function(t){for(var e=new Array(t.length),n=!0,r=0;r0&&(n=n&&e[r]===e[r-1])}return n?e[0]:e.join("")}(s)].join("");return new Function(["function ",S,"(",g.join(","),"){",m.join("\n"),"} return ",S].join(""))()}},{uniq:146}],17:[function(t,e,n){"use strict";var r=t("./compile.js");e.exports=function(t){var e=["'use strict'","var CACHED={}"],n=[],i=t.funcName+"_cwise_thunk";e.push(["return function ",i,"(",t.shimArgs.join(","),"){"].join(""));for(var a=[],o=[],s=[["array",t.arrayArgs[0],".shape.slice(",Math.max(0,t.arrayBlockIndices[0]),t.arrayBlockIndices[0]<0?","+t.arrayBlockIndices[0]+")":")"].join("")],u=[],l=[],c=0;c0&&(u.push("array"+t.arrayArgs[0]+".shape.length===array"+f+".shape.length+"+(Math.abs(t.arrayBlockIndices[0])-Math.abs(t.arrayBlockIndices[c]))),l.push("array"+t.arrayArgs[0]+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[0])+"]===array"+f+".shape[shapeIndex+"+Math.max(0,t.arrayBlockIndices[c])+"]"))}for(t.arrayArgs.length>1&&(e.push("if (!("+u.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same dimensionality!')"),e.push("for(var shapeIndex=array"+t.arrayArgs[0]+".shape.length-"+Math.abs(t.arrayBlockIndices[0])+"; shapeIndex--\x3e0;) {"),e.push("if (!("+l.join(" && ")+")) throw new Error('cwise: Arrays do not all have the same shape!')"),e.push("}")),c=0;c0)return function(t,e){var n,r;for(n=new Array(t),r=0;r 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],24:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tfloat correctionRadius = 0.5;\n\tfloat distance = sqrt(vPosition.x * vPosition.x + vPosition.y * vPosition.y) / correctionRadius;\n\tfloat theta = 1.0;\n\tif(distance != 0.0){\n\t\ttheta = atan(distance);\n\t}\n\tvec2 vMapping = theta * vPosition.xy;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\t\t\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],25:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec3 uLensS;\nuniform vec2 uLensF;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord * vec2(1.0, -1.0)/ 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tfloat scale = uLensS.z;\n\tvec3 vPos = vPosition;\n\tfloat Fx = uLensF.x;\n\tfloat Fy = uLensF.y;\n\tvec2 vMapping = vPos.xy;\n\tvMapping.x = vMapping.x + ((pow(vPos.y, 2.0)/scale)*vPos.x/scale)*-Fx;\n\tvMapping.y = vMapping.y + ((pow(vPos.x, 2.0)/scale)*vPos.y/scale)*-Fy;\n\tvMapping = vMapping * uLensS.xy;\n\tvMapping = GLCoord2TextureCoord(vMapping/scale);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t}\n\tgl_FragColor = texture;\n}\n"},{}],26:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tvec2 vMapping = vec2(vTextureCoord.x, 1.0 - vTextureCoord.y);\n\tvMapping = TextureCoord2GLCoord(vMapping);\n\t//TODO insert Code\n\tfloat F = uLens.x/ uLens.w;\n\tfloat seta = length(vMapping) / F;\n\tvMapping = sin(seta) * F / length(vMapping) * vMapping;\n\tvMapping *= uLens.w * 1.414;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],27:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 uLens;\nuniform vec2 uFov;\nuniform sampler2D uSampler;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvec2 TextureCoord2GLCoord(vec2 textureCoord) {\n\treturn (textureCoord - vec2(0.5, 0.5)) * 2.0;\n}\nvec2 GLCoord2TextureCoord(vec2 glCoord) {\n\treturn glCoord / 2.0 + vec2(0.5, 0.5);\n}\nvoid main(void){\n\tvec2 vMapping = vec2(vTextureCoord.x, 1.0 - vTextureCoord.y);\n\tvMapping = TextureCoord2GLCoord(vMapping);\n\t//TOD insert Code\n\tfloat F = uLens.x/ uLens.w;\n\tfloat seta = length(vMapping) / F;\n\tvMapping = sin(seta) * F / length(vMapping) * vMapping;\n\tvMapping *= uLens.w * 1.414;\n\tvMapping = GLCoord2TextureCoord(vMapping);\n\tvec4 texture = texture2D(uSampler, vMapping);\n\tif(vMapping.x > 0.99 || vMapping.x < 0.01 || vMapping.y > 0.99 || vMapping.y < 0.01){\n\t\ttexture = vec4(0.0, 0.0, 0.0, 1.0);\n\t} \n\tgl_FragColor = texture;\n}\n"},{}],28:[function(t,e,n){e.exports="#ifdef GL_ES\nprecision highp float;\n#endif\nattribute vec3 aVertexPosition;\nattribute vec2 aTextureCoord;\nvarying vec3 vPosition;\nvarying vec2 vTextureCoord;\nvoid main(void){\n\tvPosition = aVertexPosition;\n\tvTextureCoord = aTextureCoord;\n\tgl_Position = vec4(vPosition,1.0);\n}\n"},{}],29:[function(t,e,n){(function(n,r){"use strict";var i=t("path"),a=t("ndarray"),o=t("omggif").GifReader,s=(t("ndarray-pack"),t("through"),t("data-uri-to-buffer"));function u(t,e){var n;try{n=new o(t)}catch(t){return void e(t)}if(n.numFrames()>0){var r=[n.numFrames(),n.height,n.width,4],i=new Uint8Array(r[0]*r[1]*r[2]*r[3]),s=a(i,r);try{for(var u=0;u=0&&(this.dispose=t)},u.prototype.setRepeat=function(t){this.repeat=t},u.prototype.setTransparent=function(t){this.transparent=t},u.prototype.analyzeImage=function(t){this.setImagePixels(this.removeAlphaChannel(t)),this.analyzePixels()},u.prototype.writeImageInfo=function(){this.firstFrame&&(this.writeLSD(),this.writePalette(),this.repeat>=0&&this.writeNetscapeExt()),this.writeGraphicCtrlExt(),this.writeImageDesc(),this.firstFrame||this.writePalette(),this.firstFrame=!1},u.prototype.outputImage=function(){this.writePixels()},u.prototype.addFrame=function(t){this.emit("frame#start"),this.analyzeImage(t),this.writeImageInfo(),this.outputImage(),this.emit("frame#stop")},u.prototype.finish=function(){this.emit("finish#start"),this.writeByte(59),this.emit("finish#stop")},u.prototype.setQuality=function(t){t<1&&(t=1),this.sample=t},u.prototype.writeHeader=function(){this.emit("writeHeader#start"),this.writeUTFBytes("GIF89a"),this.emit("writeHeader#stop")},u.prototype.analyzePixels=function(){var t=this.pixels.length/3;this.indexedPixels=new Uint8Array(t);var e=new a(this.pixels,this.sample);e.buildColormap(),this.colorTab=e.getColormap();for(var n=0,r=0;r>16,n=(65280&t)>>8,r=255&t,i=0,a=16777216,o=this.colorTab.length,s=0;s=0&&(e=7&dispose),e<<=2,this.writeByte(0|e|t),this.writeShort(this.delay),this.writeByte(this.transIndex),this.writeByte(0)},u.prototype.writeImageDesc=function(){this.writeByte(44),this.writeShort(0),this.writeShort(0),this.writeShort(this.width),this.writeShort(this.height),this.firstFrame?this.writeByte(0):this.writeByte(128|this.palSize)},u.prototype.writeLSD=function(){this.writeShort(this.width),this.writeShort(this.height),this.writeByte(240|this.palSize),this.writeByte(0),this.writeByte(0)},u.prototype.writeNetscapeExt=function(){this.writeByte(33),this.writeByte(255),this.writeByte(11),this.writeUTFBytes("NETSCAPE2.0"),this.writeByte(3),this.writeByte(1),this.writeShort(this.repeat),this.writeByte(0)},u.prototype.writePalette=function(){this.writeBytes(this.colorTab);for(var t=768-this.colorTab.length,e=0;e>8&255)},u.prototype.writePixels=function(){new o(this.width,this.height,this.indexedPixels,this.colorDepth).encode(this)},u.prototype.stream=function(){return this},u.ByteCapacitor=s,e.exports=u}).call(this,t("buffer").Buffer)},{"./LZWEncoder.js":32,"./TypedNeuQuant.js":33,assert:40,buffer:47,events:48,"readable-stream":39,util:150}],32:[function(t,e,n){var r=-1,i=12,a=5003,o=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];e.exports=function(t,e,n,s){var u,l,c,f,h,p,d,v,g,m=Math.max(2,s),_=new Uint8Array(256),y=new Int32Array(a),b=new Int32Array(a),w=0,x=0,k=!1;function E(t,e){_[l++]=t,l>=254&&T(e)}function S(t){j(a),x=v+2,k=!0,M(v,t)}function j(t){for(var e=0;e0&&(t.writeByte(l),t.writeBytes(_,0,l),l=0)}function C(t){return(1<0?u|=t<=8;)E(255&u,e),u>>=8,w-=8;if((x>c||k)&&(k?(c=C(p=d),k=!1):c=++p==i?1<0;)E(255&u,e),u>>=8,w-=8;T(e)}}this.encode=function(n){n.writeByte(m),f=t*e,h=0,function(t,e){var n,o,s,u,f,h,m;for(k=!1,c=C(p=d=t),g=1+(v=1<=0){f=h-s,0===s&&(f=1);do{if((s-=f)<0&&(s+=h),y[s]===n){u=b[s];continue t}}while(y[s]>=0)}M(u,e),u=o,x<1<>c,h=u<>3)*(1<