Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

img.js

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

img.js - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

2

bower.json
{
"name": "img.js",
"description": "A JavaScript library for bitmap graphics.",
"version": "0.1.4",
"version": "0.1.5",
"main": "dist/img.js",

@@ -6,0 +6,0 @@ "keywords": [

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.img = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function (process){
!function(){function n(n){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,n.apply(t,arguments)}}var t,e,r={};t=this,null!=t&&(e=t.async),r.noConflict=function(){return t.async=e,r};var u=function(n,t){if(n.forEach)return n.forEach(t);for(var e=0;e<n.length;e+=1)t(n[e],e,n)},i=function(n,t){if(n.map)return n.map(t);var e=[];return u(n,function(n,r,u){e.push(t(n,r,u))}),e},c=function(n,t,e){return n.reduce?n.reduce(t,e):(u(n,function(n,r,u){e=t(e,n,r,u)}),e)},o=function(n){if(Object.keys)return Object.keys(n);var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(e);return t};"undefined"!=typeof process&&process.nextTick?(r.nextTick=process.nextTick,"undefined"!=typeof setImmediate?r.setImmediate=function(n){setImmediate(n)}:r.setImmediate=r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(n){setImmediate(n)},r.setImmediate=r.nextTick):(r.nextTick=function(n){setTimeout(n,0)},r.setImmediate=r.nextTick),r.each=function(t,e,r){if(r=r||function(){},!t.length)return r();var i=0;u(t,function(u){e(u,n(function(n){n?(r(n),r=function(){}):(i+=1,i>=t.length&&r(null))}))})},r.forEach=r.each,r.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)return e();var r=0,u=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e(null):u())})};u()},r.forEachSeries=r.eachSeries,r.eachLimit=function(n,t,e,r){var u=a(t);u.apply(null,[n,e,r])},r.forEachLimit=r.eachLimit;var a=function(n){return function(t,e,r){if(r=r||function(){},!t.length||0>=n)return r();var u=0,i=0,c=0;!function o(){if(u>=t.length)return r();for(;n>c&&i<t.length;)i+=1,c+=1,e(t[i-1],function(n){n?(r(n),r=function(){}):(u+=1,c-=1,u>=t.length?r():o())})}()}},l=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.each].concat(t))}},f=function(n,t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a(n)].concat(e))}},s=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.eachSeries].concat(t))}},p=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e,r){u[n.index]=r,t(e)})},function(n){r(n,u)})};r.map=l(p),r.mapSeries=s(p),r.mapLimit=function(n,t,e,r){return m(t)(n,e,r)};var m=function(n){return f(n,p)};r.reduce=function(n,t,e,u){r.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){u(n,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(n,t,e,u){var c=i(n,function(n){return n}).reverse();r.reduce(c,t,e,u)},r.foldr=r.reduceRight;var y=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.filter=l(y),r.filterSeries=s(y),r.select=r.filter,r.selectSeries=r.filterSeries;var v=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.reject=l(v),r.rejectSeries=s(v);var h=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(n){r()})};r.detect=l(h),r.detectSeries=s(h),r.some=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(n){e(!1)})},r.any=r.some,r.every=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(n){e(!0)})},r.all=r.every,r.sortBy=function(n,t,e){r.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);var r=function(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0};e(null,i(t.sort(r),function(n){return n.value}))})},r.auto=function(n,t){t=t||function(){};var e=o(n);if(!e.length)return t(null);var i={},a=[],l=function(n){a.unshift(n)},f=function(n){for(var t=0;t<a.length;t+=1)if(a[t]===n)return void a.splice(t,1)},s=function(){u(a.slice(0),function(n){n()})};l(function(){o(i).length===e.length&&(t(null,i),t=function(){})}),u(e,function(e){var a=n[e]instanceof Function?[n[e]]:n[e],p=function(n){var c=Array.prototype.slice.call(arguments,1);if(c.length<=1&&(c=c[0]),n){var a={};u(o(i),function(n){a[n]=i[n]}),a[e]=c,t(n,a),t=function(){}}else i[e]=c,r.setImmediate(s)},m=a.slice(0,Math.abs(a.length-1))||[],y=function(){return c(m,function(n,t){return n&&i.hasOwnProperty(t)},!0)&&!i.hasOwnProperty(e)};if(y())a[a.length-1](p,i);else{var v=function(){y()&&(f(v),a[a.length-1](p,i))};l(v)}})},r.waterfall=function(n,t){if(t=t||function(){},n.constructor!==Array){var e=new Error("First argument to waterfall must be an array of functions");return t(e)}if(!n.length)return t();var u=function(n){return function(e){if(e)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),c=n.next();i.push(c?u(c):t),r.setImmediate(function(){n.apply(null,i)})}}};u(r.iterator(n))()};var d=function(n,t,e){if(e=e||function(){},t.constructor===Array)n.map(t,function(n,t){n&&n(function(n){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),t.call(null,n,e)})},e);else{var r={};n.each(o(t),function(n,e){t[n](function(t){var u=Array.prototype.slice.call(arguments,1);u.length<=1&&(u=u[0]),r[n]=u,e(t)})},function(n){e(n,r)})}};r.parallel=function(n,t){d({map:r.map,each:r.each},n,t)},r.parallelLimit=function(n,t,e){d({map:m(t),each:a(t)},n,e)},r.series=function(n,t){if(t=t||function(){},n.constructor===Array)r.mapSeries(n,function(n,t){n&&n(function(n){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),t.call(null,n,e)})},t);else{var e={};r.eachSeries(o(n),function(t,r){n[t](function(n){var u=Array.prototype.slice.call(arguments,1);u.length<=1&&(u=u[0]),e[t]=u,r(n)})},function(n){t(n,e)})}},r.iterator=function(n){var t=function(e){var r=function(){return n.length&&n[e].apply(null,arguments),r.next()};return r.next=function(){return e<n.length-1?t(e+1):null},r};return t(0)},r.apply=function(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t.concat(Array.prototype.slice.call(arguments)))}};var g=function(n,t,e,r){var u=[];n(t,function(n,t){e(n,function(n,e){u=u.concat(e||[]),t(n)})},function(n){r(n,u)})};r.concat=l(g),r.concatSeries=s(g),r.whilst=function(n,t,e){n()?t(function(u){return u?e(u):void r.whilst(n,t,e)}):e()},r.doWhilst=function(n,t,e){n(function(u){return u?e(u):void(t()?r.doWhilst(n,t,e):e())})},r.until=function(n,t,e){n()?e():t(function(u){return u?e(u):void r.until(n,t,e)})},r.doUntil=function(n,t,e){n(function(u){return u?e(u):void(t()?e():r.doUntil(n,t,e))})},r.queue=function(t,e){function i(n,t,i,c){t.constructor!==Array&&(t=[t]),u(t,function(t){var u={data:t,callback:"function"==typeof c?c:null};i?n.tasks.unshift(u):n.tasks.push(u),n.saturated&&n.tasks.length===e&&n.saturated(),r.setImmediate(n.process)})}void 0===e&&(e=1);var c=0,o={tasks:[],concurrency:e,saturated:null,empty:null,drain:null,push:function(n,t){i(o,n,!1,t)},unshift:function(n,t){i(o,n,!0,t)},process:function(){if(c<o.concurrency&&o.tasks.length){var e=o.tasks.shift();o.empty&&0===o.tasks.length&&o.empty(),c+=1;var r=function(){c-=1,e.callback&&e.callback.apply(e,arguments),o.drain&&o.tasks.length+c===0&&o.drain(),o.process()},u=n(r);t(e.data,u)}},length:function(){return o.tasks.length},running:function(){return c}};return o},r.cargo=function(n,t){var e=!1,c=[],o={tasks:c,payload:t,saturated:null,empty:null,drain:null,push:function(n,e){n.constructor!==Array&&(n=[n]),u(n,function(n){c.push({data:n,callback:"function"==typeof e?e:null}),o.saturated&&c.length===t&&o.saturated()}),r.setImmediate(o.process)},process:function a(){if(!e){if(0===c.length)return void(o.drain&&o.drain());var r="number"==typeof t?c.splice(0,t):c.splice(0),l=i(r,function(n){return n.data});o.empty&&o.empty(),e=!0,n(l,function(){e=!1;var n=arguments;u(r,function(t){t.callback&&t.callback.apply(null,n)}),a()})}},length:function(){return c.length},running:function(){return e}};return o};var k=function(n){return function(t){var e=Array.prototype.slice.call(arguments,1);t.apply(null,e.concat([function(t){var e=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[n]&&u(e,function(t){console[n](t)}))}]))}};r.log=k("log"),r.dir=k("dir"),r.memoize=function(n,t){var e={},r={};t=t||function(n){return n};var u=function(){var u=Array.prototype.slice.call(arguments),i=u.pop(),c=t.apply(null,u);c in e?i.apply(null,e[c]):c in r?r[c].push(i):(r[c]=[i],n.apply(null,u.concat([function(){e[c]=arguments;var n=r[c];delete r[c];for(var t=0,u=n.length;u>t;t++)n[t].apply(null,arguments)}])))};return u.memo=e,u.unmemoized=n,u},r.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},r.times=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.map(u,t,e)},r.timesSeries=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.mapSeries(u,t,e)},r.compose=function(){var n=Array.prototype.reverse.call(arguments);return function(){var t=this,e=Array.prototype.slice.call(arguments),u=e.pop();r.reduce(n,e,function(n,e,r){e.apply(t,n.concat([function(){var n=arguments[0],t=Array.prototype.slice.call(arguments,1);r(n,t)}]))},function(n,e){u.apply(t,[n].concat(e))})}};var A=function(n,t){var e=function(){var e=this,r=Array.prototype.slice.call(arguments),u=r.pop();return n(t,function(n,t){n.apply(e,r.concat([t]))},u)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};r.applyEach=l(A),r.applyEachSeries=s(A),r.forever=function(n,t){function e(r){if(r){if(t)return t(r);throw r}n(e)}e()},"undefined"!=typeof define&&define.amd?define([],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:t.async=r}();
!function(){function n(n){var e=!1;return function(){if(e)throw new Error("Callback was already called.");e=!0,n.apply(t,arguments)}}var t,e,r={};t=this,null!=t&&(e=t.async),r.noConflict=function(){return t.async=e,r};var u=function(n,t){if(n.forEach)return n.forEach(t);for(var e=0;e<n.length;e+=1)t(n[e],e,n)},i=function(n,t){if(n.map)return n.map(t);var e=[];return u(n,function(n,r,u){e.push(t(n,r,u))}),e},c=function(n,t,e){return n.reduce?n.reduce(t,e):(u(n,function(n,r,u){e=t(e,n,r,u)}),e)},o=function(n){if(Object.keys)return Object.keys(n);var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(e);return t};"undefined"!=typeof process&&process.nextTick?(r.nextTick=process.nextTick,"undefined"!=typeof setImmediate?r.setImmediate=function(n){setImmediate(n)}:r.setImmediate=r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(n){setImmediate(n)},r.setImmediate=r.nextTick):(r.nextTick=function(n){setTimeout(n,0)},r.setImmediate=r.nextTick),r.each=function(t,e,r){if(r=r||function(){},!t.length)return r();var i=0;u(t,function(u){e(u,n(function(n){n?(r(n),r=function(){}):(i+=1,i>=t.length&&r(null))}))})},r.forEach=r.each,r.eachSeries=function(n,t,e){if(e=e||function(){},!n.length)return e();var r=0,u=function(){t(n[r],function(t){t?(e(t),e=function(){}):(r+=1,r>=n.length?e(null):u())})};u()},r.forEachSeries=r.eachSeries,r.eachLimit=function(n,t,e,r){var u=a(t);u.apply(null,[n,e,r])},r.forEachLimit=r.eachLimit;var a=function(n){return function(t,e,r){if(r=r||function(){},!t.length||0>=n)return r();var u=0,i=0,c=0;!function o(){if(u>=t.length)return r();for(;n>c&&i<t.length;)i+=1,c+=1,e(t[i-1],function(n){n?(r(n),r=function(){}):(u+=1,c-=1,u>=t.length?r():o())})}()}},l=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.each].concat(t))}},f=function(n,t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a(n)].concat(e))}},s=function(n){return function(){var t=Array.prototype.slice.call(arguments);return n.apply(null,[r.eachSeries].concat(t))}},p=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e,r){u[n.index]=r,t(e)})},function(n){r(n,u)})};r.map=l(p),r.mapSeries=s(p),r.mapLimit=function(n,t,e,r){return m(t)(n,e,r)};var m=function(n){return f(n,p)};r.reduce=function(n,t,e,u){r.eachSeries(n,function(n,r){e(t,n,function(n,e){t=e,r(n)})},function(n){u(n,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(n,t,e,u){var c=i(n,function(n){return n}).reverse();r.reduce(c,t,e,u)},r.foldr=r.reduceRight;var y=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e&&u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.filter=l(y),r.filterSeries=s(y),r.select=r.filter,r.selectSeries=r.filterSeries;var v=function(n,t,e,r){var u=[];t=i(t,function(n,t){return{index:t,value:n}}),n(t,function(n,t){e(n.value,function(e){e||u.push(n),t()})},function(n){r(i(u.sort(function(n,t){return n.index-t.index}),function(n){return n.value}))})};r.reject=l(v),r.rejectSeries=s(v);var h=function(n,t,e,r){n(t,function(n,t){e(n,function(e){e?(r(n),r=function(){}):t()})},function(n){r()})};r.detect=l(h),r.detectSeries=s(h),r.some=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n&&(e(!0),e=function(){}),r()})},function(n){e(!1)})},r.any=r.some,r.every=function(n,t,e){r.each(n,function(n,r){t(n,function(n){n||(e(!1),e=function(){}),r()})},function(n){e(!0)})},r.all=r.every,r.sortBy=function(n,t,e){r.map(n,function(n,e){t(n,function(t,r){t?e(t):e(null,{value:n,criteria:r})})},function(n,t){if(n)return e(n);var r=function(n,t){var e=n.criteria,r=t.criteria;return r>e?-1:e>r?1:0};e(null,i(t.sort(r),function(n){return n.value}))})},r.auto=function(n,t){t=t||function(){};var e=o(n);if(!e.length)return t(null);var i={},a=[],l=function(n){a.unshift(n)},f=function(n){for(var t=0;t<a.length;t+=1)if(a[t]===n)return void a.splice(t,1)},s=function(){u(a.slice(0),function(n){n()})};l(function(){o(i).length===e.length&&(t(null,i),t=function(){})}),u(e,function(e){var a=n[e]instanceof Function?[n[e]]:n[e],p=function(n){var c=Array.prototype.slice.call(arguments,1);if(c.length<=1&&(c=c[0]),n){var a={};u(o(i),function(n){a[n]=i[n]}),a[e]=c,t(n,a),t=function(){}}else i[e]=c,r.setImmediate(s)},m=a.slice(0,Math.abs(a.length-1))||[],y=function(){return c(m,function(n,t){return n&&i.hasOwnProperty(t)},!0)&&!i.hasOwnProperty(e)};if(y())a[a.length-1](p,i);else{var v=function(){y()&&(f(v),a[a.length-1](p,i))};l(v)}})},r.waterfall=function(n,t){if(t=t||function(){},n.constructor!==Array){var e=new Error("First argument to waterfall must be an array of functions");return t(e)}if(!n.length)return t();var u=function(n){return function(e){if(e)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),c=n.next();c?i.push(u(c)):i.push(t),r.setImmediate(function(){n.apply(null,i)})}}};u(r.iterator(n))()};var d=function(n,t,e){if(e=e||function(){},t.constructor===Array)n.map(t,function(n,t){n&&n(function(n){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),t.call(null,n,e)})},e);else{var r={};n.each(o(t),function(n,e){t[n](function(t){var u=Array.prototype.slice.call(arguments,1);u.length<=1&&(u=u[0]),r[n]=u,e(t)})},function(n){e(n,r)})}};r.parallel=function(n,t){d({map:r.map,each:r.each},n,t)},r.parallelLimit=function(n,t,e){d({map:m(t),each:a(t)},n,e)},r.series=function(n,t){if(t=t||function(){},n.constructor===Array)r.mapSeries(n,function(n,t){n&&n(function(n){var e=Array.prototype.slice.call(arguments,1);e.length<=1&&(e=e[0]),t.call(null,n,e)})},t);else{var e={};r.eachSeries(o(n),function(t,r){n[t](function(n){var u=Array.prototype.slice.call(arguments,1);u.length<=1&&(u=u[0]),e[t]=u,r(n)})},function(n){t(n,e)})}},r.iterator=function(n){var t=function(e){var r=function(){return n.length&&n[e].apply(null,arguments),r.next()};return r.next=function(){return e<n.length-1?t(e+1):null},r};return t(0)},r.apply=function(n){var t=Array.prototype.slice.call(arguments,1);return function(){return n.apply(null,t.concat(Array.prototype.slice.call(arguments)))}};var g=function(n,t,e,r){var u=[];n(t,function(n,t){e(n,function(n,e){u=u.concat(e||[]),t(n)})},function(n){r(n,u)})};r.concat=l(g),r.concatSeries=s(g),r.whilst=function(n,t,e){n()?t(function(u){return u?e(u):void r.whilst(n,t,e)}):e()},r.doWhilst=function(n,t,e){n(function(u){return u?e(u):void(t()?r.doWhilst(n,t,e):e())})},r.until=function(n,t,e){n()?e():t(function(u){return u?e(u):void r.until(n,t,e)})},r.doUntil=function(n,t,e){n(function(u){return u?e(u):void(t()?e():r.doUntil(n,t,e))})},r.queue=function(t,e){function i(n,t,i,c){t.constructor!==Array&&(t=[t]),u(t,function(t){var u={data:t,callback:"function"==typeof c?c:null};i?n.tasks.unshift(u):n.tasks.push(u),n.saturated&&n.tasks.length===e&&n.saturated(),r.setImmediate(n.process)})}void 0===e&&(e=1);var c=0,o={tasks:[],concurrency:e,saturated:null,empty:null,drain:null,push:function(n,t){i(o,n,!1,t)},unshift:function(n,t){i(o,n,!0,t)},process:function(){if(c<o.concurrency&&o.tasks.length){var e=o.tasks.shift();o.empty&&0===o.tasks.length&&o.empty(),c+=1;var r=function(){c-=1,e.callback&&e.callback.apply(e,arguments),o.drain&&o.tasks.length+c===0&&o.drain(),o.process()},u=n(r);t(e.data,u)}},length:function(){return o.tasks.length},running:function(){return c}};return o},r.cargo=function(n,t){var e=!1,c=[],o={tasks:c,payload:t,saturated:null,empty:null,drain:null,push:function(n,e){n.constructor!==Array&&(n=[n]),u(n,function(n){c.push({data:n,callback:"function"==typeof e?e:null}),o.saturated&&c.length===t&&o.saturated()}),r.setImmediate(o.process)},process:function a(){if(!e){if(0===c.length)return void(o.drain&&o.drain());var r="number"==typeof t?c.splice(0,t):c.splice(0),l=i(r,function(n){return n.data});o.empty&&o.empty(),e=!0,n(l,function(){e=!1;var n=arguments;u(r,function(t){t.callback&&t.callback.apply(null,n)}),a()})}},length:function(){return c.length},running:function(){return e}};return o};var k=function(n){return function(t){var e=Array.prototype.slice.call(arguments,1);t.apply(null,e.concat([function(t){var e=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[n]&&u(e,function(t){console[n](t)}))}]))}};r.log=k("log"),r.dir=k("dir"),r.memoize=function(n,t){var e={},r={};t=t||function(n){return n};var u=function(){var u=Array.prototype.slice.call(arguments),i=u.pop(),c=t.apply(null,u);c in e?i.apply(null,e[c]):c in r?r[c].push(i):(r[c]=[i],n.apply(null,u.concat([function(){e[c]=arguments;var n=r[c];delete r[c];for(var t=0,u=n.length;u>t;t++)n[t].apply(null,arguments)}])))};return u.memo=e,u.unmemoized=n,u},r.unmemoize=function(n){return function(){return(n.unmemoized||n).apply(null,arguments)}},r.times=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.map(u,t,e)},r.timesSeries=function(n,t,e){for(var u=[],i=0;n>i;i++)u.push(i);return r.mapSeries(u,t,e)},r.compose=function(){var n=Array.prototype.reverse.call(arguments);return function(){var t=this,e=Array.prototype.slice.call(arguments),u=e.pop();r.reduce(n,e,function(n,e,r){e.apply(t,n.concat([function(){var n=arguments[0],t=Array.prototype.slice.call(arguments,1);r(n,t)}]))},function(n,e){u.apply(t,[n].concat(e))})}};var A=function(n,t){var e=function(){var e=this,r=Array.prototype.slice.call(arguments),u=r.pop();return n(t,function(n,t){n.apply(e,r.concat([t]))},u)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};r.applyEach=l(A),r.applyEachSeries=s(A),r.forever=function(n,t){function e(r){if(r){if(t)return t(r);throw r}n(e)}e()},"undefined"!=typeof define&&define.amd?define([],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:t.async=r}();

@@ -28,3 +28,3 @@

},{"./blend":5,"./process":8,"./util":9}],7:[function(require,module,exports){
"use strict";function toColor(t,e,r,a,n){var i,o,s,h,l,g,m,u;if(void 0===t)i=o=s=0,h=1;else if(Array.isArray(t))u=e||{},i=void 0!==t[0]?t[0]:0,o=void 0!==t[1]?t[1]:0,s=void 0!==t[2]?t[2]:0,h=void 0!==t[3]?t[3]:u.base||1;else if(void 0!==t.r)u=e||{},i=t.r,o=t.g,s=t.b,h=void 0!==t.a?t.a:u.base||1;else if("string"==typeof t){if(0===t.indexOf("#"))return t;if(0===t.indexOf("rgb"))return t;if(-1!==colors.indexOf(t))return t}else"number"==typeof t&&(1===arguments.length?(i=o=s=t,h=1):2===arguments.length?(i=o=s=t,"number"==typeof e?h=e:(u=e,h=u.base||1)):3===arguments.length?"number"==typeof r?(i=t,o=e,s=r,h=1):(i=o=s=t,h=e,u=r):4===arguments.length?(i=t,o=e,s=r,"number"==typeof a?h=a:(u=a||{},h=u.base||1)):(i=t,o=e,s=r,h=a,u=n));if("number"!=typeof i||"number"!=typeof o||"number"!=typeof s||"number"!=typeof h)throw new Error("Invalid color arguments");return u=u||{},void 0!==u.base&&(i/=u.base,o/=u.base,s/=u.base,h/=u.base),l=Math.round(255*i),g=Math.round(255*o),m=Math.round(255*s),"rgba("+l+", "+g+", "+m+", "+h+")"}function toGradientData(t,e,r,a,n){var i,o,s,h,l,g,m={};if(1===arguments.length)g=t||{},i=g.startColor,o=g.endColor,s=g.type,h=g.rotation,l=g.spread;else if(arguments.length>=2)if(i=t,o=e,s="linear",h=0,l=0,3===arguments.length)"string"==typeof r?s=r:"number"==typeof r&&(h=r);else if(4===arguments.length)if("number"==typeof r)h=r,l=a;else if("linear"===r)h=a;else{if("radial"!==r)throw new Error("Wrong argument provided: "+r);s=r,l=a}else 5===arguments.length&&(s=r,h=a,l=n);if(!i&&0!==i)throw new Error("No startColor was given.");if(!o&&0!==o)throw new Error("No endColor was given.");try{m.startColor=toColor(i)}catch(u){throw new Error("startColor is not a valid color: "+i)}try{m.endColor=toColor(o)}catch(d){throw new Error("endColor is not a valid color: "+o)}if(void 0===s&&(s="linear"),"linear"!==s&&"radial"!==s)throw new Error("Unknown gradient type: "+s);if(m.type=s,void 0===l&&(l=0),"number"!=typeof l)throw new Error("Spread value is not a number: "+l);if("linear"===s){if(void 0===h&&(h=0),"number"!=typeof h)throw new Error("Rotation value is not a number: "+h);m.rotation=h}return m.spread=clamp(l,0,.99),m}function findType(t){if("string"==typeof t)return TYPE_PATH;if(t instanceof Image)return TYPE_IMAGE;if(t instanceof HTMLCanvasElement)return TYPE_HTML_CANVAS;if(t instanceof ImageCanvas)return TYPE_IMAGE_CANVAS;if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b&&void 0!==t.a)return TYPE_FILL;if(void 0!==t.startColor&&void 0!==t.endColor)return TYPE_GRADIENT;throw new Error("Cannot establish type for data ",t)}function isPoint(t){return t?void 0!==t.x&&void 0!==t.y:!1}function pointFromArray(t){var e=t[0],r=t.length>1?t[1]:e;return{x:e,y:r}}function pointFromNumber(t){return{x:t,y:t}}function isValidArg(t){return void 0!==t&&null!==t}function convertArg(t){return Array.isArray(t)?pointFromArray(t):"number"==typeof t?pointFromNumber(t):isPoint(t)?t:void 0}function loadImage(t,e){var r=new Image;r.onload=function(){e(null,[t,this])},r.src=t}function loadImages(t,e){async.map(t,loadImage,function(t,r){if(e){for(var a,n,i={},o=0;o<r.length;o+=1)a=r[o][0],n=r[o][1],i[a]=n;e(i)}})}function rectUnite(t,e){var r=Math.min(t.x,e.x),a=Math.min(t.y,e.y),n=Math.max(t.x+t.width,e.x+e.width)-r,i=Math.max(t.y+t.height,e.y+e.height)-a;return{x:r,y:a,width:n,height:i}}function merge(t){var e,r,a,n;for(e=0;e<t.length;e+=1)r=t[e],a=0===e?r.bounds():rectUnite(a,r.bounds());var i=a.width/2+a.x,o=a.height/2+a.y,s=new ImageCanvas(a.width,a.height);for(e=0;e<t.length;e+=1)n=s.addLayer(t[e].toLayer()),n.translate(-i,-o);return new Img(s.render(),i,o)}var util=require("./util"),CanvasRenderer=require("./canvasrenderer"),AsyncRenderer=require("./asyncrenderer"),img,ImageCanvas,Layer,Img,DEFAULT_WIDTH=800,DEFAULT_HEIGHT=800,TYPE_PATH="path",TYPE_IMAGE="image",TYPE_HTML_CANVAS="htmlCanvas",TYPE_IMAGE_CANVAS="iCanvas",TYPE_FILL="fill",TYPE_GRADIENT="gradient",IDENTITY_TRANSFORM=util.transform(),Transform=IDENTITY_TRANSFORM,clamp=util.clamp,colors=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];Layer=function(t,e){e||(e=findType(t)),this.data=t,this.type=e,(e===TYPE_HTML_CANVAS||e===TYPE_IMAGE_CANVAS||e===TYPE_IMAGE)&&(this.width=t.width,this.height=t.height),this.opacity=1,this.blendmode="source-over",this.transform=IDENTITY_TRANSFORM,this.flip_h=!1,this.flip_v=!1,this.mask=new ImageCanvas,this.filters=[]},Layer.Transform=Layer.IDENTITY_TRANSFORM=IDENTITY_TRANSFORM,Layer.prototype.clone=function(){function t(t){var e,r,a={};if(a.name=t.name,void 0!==t.options){a.options={};for(var n=Object.keys(t.options),i=0;i<n.length;i+=1)e=n[i],r=t.options[e],Array.isArray(r)?a.options[e]=r.slice(0):a.options[e]=r}return a}var e=Object.create(Layer.prototype);e.data=this.data,e.type=this.type,e.width=this.width,e.height=this.height,e.opacity=this.opacity,e.blendmode=this.blendmode,e.transform=this.transform,e.flip_h=this.flip_h,e.flip_v=this.flip_v,e.mask=this.mask.clone(),e.filters=[],this.type===TYPE_IMAGE_CANVAS?e.data=this.data.clone():this.type===TYPE_GRADIENT&&(e.data={startColor:this.data.startColor,endColor:this.data.endColor,type:this.data.type,rotation:this.data.rotation,spread:this.data.spread});for(var r=0;r<this.filters.length;r+=1)e.filters.push(t(this.filters[r]));return e},Layer.prototype.setOpacity=function(t){this.opacity=clamp(t,0,1)},Layer.prototype.translate=function(t,e){e=void 0===e?0:e;var r=Transform.translate(t,e);this.transform=this.transform.prepend(r)},Layer.prototype.scale=function(t,e){e=void 0===e?t:e;var r=Transform.scale(t,e);this.transform=this.transform.prepend(r)},Layer.prototype.rotate=function(t){var e=Transform.rotate(t);this.transform=this.transform.prepend(e)},Layer.prototype.skew=function(t,e){e=void 0===e?t:e;var r=Transform.skew(t,e);this.transform=this.transform.prepend(r)},Layer.prototype.flipHorizontal=function(t){void 0!==t?this.flip_h=t:this.flip_h=!this.flip_h},Layer.prototype.flipVertical=function(t){void 0!==t?this.flip_v=t:this.flip_v=!this.flip_v},Layer.prototype.addFilter=function(t,e){this.filters.push({name:t,options:e})},Layer.prototype.draw=function(t){var e=void 0===this.width?DEFAULT_WIDTH:this.width,r=void 0===this.height?DEFAULT_HEIGHT:this.height,a=new ImageCanvas(e,r);a.addLayer(this),a.draw(t)},Layer.prototype.toCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return this.draw(e),t},Layer.fromFile=function(t){return new Layer(t,TYPE_PATH)},Layer.fromImage=function(t){return new Layer(t,TYPE_IMAGE)},Layer.fromCanvas=function(t){return t instanceof HTMLCanvasElement?Layer.fromHtmlCanvas(t):Layer.fromImageCanvas(t)},Layer.fromHtmlCanvas=function(t){return new Layer(t,TYPE_HTML_CANVAS)},Layer.fromImageCanvas=function(t){return new Layer(t,TYPE_IMAGE_CANVAS)},Layer.fromColor=function(t){return new Layer(toColor(t),TYPE_FILL)},Layer.fromGradient=function(){return new Layer(toGradientData.apply(null,arguments),TYPE_GRADIENT)},Layer.prototype.isPath=function(){return this.type===TYPE_PATH},Layer.prototype.isFill=function(){return this.type===TYPE_FILL},Layer.prototype.isGradient=function(){return this.type===TYPE_GRADIENT},Layer.prototype.isHtmlCanvas=function(){return this.type===TYPE_HTML_CANVAS},Layer.prototype.isImage=function(){return this.type===TYPE_IMAGE},Layer.prototype.isImageCanvas=function(){return this.type===TYPE_IMAGE_CANVAS};var Pixels=function(t){this.width=t.width,this.height=t.height;var e=t.getContext("2d");this._data=e.getImageData(0,0,this.width,this.height),this.array=this._data.data};Pixels.prototype.get=function(t){t*=4;var e=this.array;return[e[t+0],e[t+1],e[t+2],e[t+3]]},Pixels.prototype.set=function(t,e){t*=4;var r=this.array;r[t+0]=e[0],r[t+1]=e[1],r[t+2]=e[2],r[t+3]=e[3]},Pixels.prototype.toCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return e.putImageData(this._data,0,0),t},ImageCanvas=function(t,e){t||(t=DEFAULT_WIDTH),e||(e=DEFAULT_HEIGHT),this.width=t,this.height=e,this.layers=[]},ImageCanvas.prototype.clone=function(){for(var t=new ImageCanvas(this.width,this.height),e=0;e<this.layers.length;e+=1)t.layers.push(this.layers[e].clone());return t},ImageCanvas.prototype.addLayer=function(t){var e;try{return this.addGradientLayer.apply(this,arguments)}catch(r){}try{return this.addColorLayer.apply(this,arguments)}catch(a){}if(1===arguments.length&&("string"==typeof t?e=new Layer(t,TYPE_PATH):t instanceof Layer?e=t:t instanceof HTMLCanvasElement?e=new Layer(t,TYPE_HTML_CANVAS):t instanceof Image?e=new Layer(t,TYPE_IMAGE):t instanceof ImageCanvas&&(e=new Layer(t,TYPE_IMAGE_CANVAS))),!e)throw new Error("Error creating layer.");return this.layers.push(e),e},ImageCanvas.prototype.addColorLayer=function(){var t=toColor.apply(null,arguments),e=new Layer(t,TYPE_FILL);return this.layers.push(e),e},ImageCanvas.prototype.addGradientLayer=function(){var t=toGradientData.apply(null,arguments),e=new Layer(t,TYPE_GRADIENT);return this.layers.push(e),e},ImageCanvas.prototype.render=function(t){var e=t?AsyncRenderer:CanvasRenderer;return e.render(this,t)},ImageCanvas.prototype.draw=function(t,e){if(e)this.render(function(e){t.drawImage(e,0,0,e.width,e.height)});else{var r=this.render();t.drawImage(r,0,0,r.width,r.height)}},Img=function(t,e,r){this.canvas=t,this.originalWidth=t?t.width:0,this.originalHeight=t?t.height:0,this.transform=e||r?Transform.translate(e,r):Layer.IDENTITY_TRANSFORM},Img.prototype.clone=function(){var t=new Img;return t.canvas=this.canvas,t.originalWidth=this.originalWidth,t.originalHeight=this.originalHeight,t.transform=this.transform,t},Img.prototype.withCanvas=function(t){var e=this.clone();return e.canvas=t,e},Img.prototype._transform=function(t){var e=this.clone();return e.transform=e.transform.prepend(t),e},Img.prototype.translate=function(t){var e=pointFromNumber(0),r=arguments;return 1===r.length&&isValidArg(t)?e=convertArg(t):2===r.length&&(e={x:r[0],y:r[1]}),0===e.x&&0===e.y?this:this._transform(Transform.translate(e.x,e.y))},Img.prototype.rotate=function(t){if(!t)return this;var e=pointFromNumber(0),r=arguments;return 2===r.length?e=convertArg(r[1]):3===r.length&&(e={x:r[1],y:r[2]}),this._transform(Transform.translate(e.x,e.y).rotate(t).translate(-e.x,-e.y))},Img.prototype.scale=function(t){var e=pointFromNumber(100),r=pointFromNumber(0),a=arguments;return 1===a.length&&isValidArg(t)?e=convertArg(t):2===a.length?"number"==typeof t&&"number"==typeof a[1]?e={x:a[0],y:a[1]}:(e=convertArg(t),r=convertArg(a[1])):4===a.length&&(e={x:a[0],y:a[1]},r={x:a[2],y:a[3]}),100===e.x&&100===e.y?this:this._transform(Transform.translate(r.x,r.y).scale(e.x/100,e.y/100).translate(-r.x,-r.y))},Img.prototype.skew=function(t){var e=pointFromNumber(0),r=pointFromNumber(0),a=arguments;return 1===a.length&&isValidArg(t)?e=convertArg(t):2===a.length?"number"==typeof t&&"number"==typeof a[1]?e={x:a[0],y:a[1]}:(e=convertArg(t),r=convertArg(a[1])):4===a.length&&(e={x:a[0],y:a[1]},r={x:a[2],y:a[3]}),0===e.x&&0===e.y?this:this._transform(Transform.translate(r.x,r.y).skew(e.x,e.y).translate(-r.x,-r.y))},Img.prototype.transformed=function(){return img.merge([this])},Img.prototype.bounds=function(){for(var t,e,r,a,n,i=this.transform,o=this.originalWidth/2,s=this.originalHeight/2,h={x:-o,y:-s},l={x:o,y:-s},g={x:-o,y:s},m={x:o,y:s},u=[h,l,g,m],d=0;4>d;d+=1)t=i.transformPoint(u[d]),0===d?(e=a=t.x,r=n=t.y):(t.x<e&&(e=t.x),t.x>a&&(a=t.x),t.y<r&&(r=t.y),t.y>n&&(n=t.y));return{x:e,y:r,width:a-e,height:n-r}},Img.prototype.colorize=function(t){var e=Layer.fromColor(t);e.width=this.originalWidth,e.height=this.originalHeight;var r=new Img(e.toCanvas());return r=r._transform(this.transform.matrix()),img.merge([this,r])},Img.prototype.desaturate=function(){var t=this.toLayer(!1);return t.addFilter("desaturate"),this.withCanvas(t.toCanvas())},Img.prototype.crop=function(t){function e(t,e){var r=t.x+t.width,a=t.y+t.height,n=e.x+e.width,i=e.y+e.height,o=Math.max(t.x,e.x),s=Math.max(t.y,e.y),h=Math.max(Math.min(r,n)-o,0),l=Math.max(Math.min(a,i)-s,0);return{x:o,y:s,width:h,height:l}}var r=this.bounds(),a=t.bounds(),n=e(r,a),i=Math.ceil(n.width),o=Math.ceil(n.height);if(0===n.width||0===n.height)throw new Error("Resulting image has no dimensions");var s=new img.ImageCanvas(i,o),h=s.addLayer(this.toLayer());return h.translate(i/2-a.width-a.x,o/2-a.height-a.y),i<a.width&&n.x>r.x&&h.translate(a.width-i,0),o<a.height&&n.y>r.y&&h.translate(0,a.height-o),new Img(s.render(),n.x+i/2,n.y+o/2)},Img.prototype.draw=function(t){t.save();var e=this.transform.matrix();t.transform(e[0],e[1],e[3],e[4],e[6],e[7]),t.translate(-this.originalWidth/2,-this.originalHeight/2),t.drawImage(this.canvas,0,0),t.restore()},Img.prototype.toLayer=function(t){var e=document.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height;var r=e.getContext("2d");r.drawImage(this.canvas,0,0);var a=img.Layer.fromHtmlCanvas(e);return void 0===t&&(t=!0),t&&(a.transform=this.transform),a},Img.prototype.getPixels=function(){return new Pixels(this.canvas)},Img.prototype.toImage=function(){var t=this.bounds(),e=this.crop({bounds:function(){return t}}),r=new Image;return r.width=e.canvas.width,r.height=e.canvas.height,r.src=e.canvas.toDataURL(),r},img={},img.Layer=Layer,img.ImageCanvas=ImageCanvas,img.Img=Img,img.Pixels=Pixels;var async=require("async");img.loadImages=loadImages,img.merge=merge,module.exports=img;
"use strict";function toColor(t,e,r,a,n){var i,o,s,h,l,g,m,u;if(void 0===t)i=o=s=0,h=1;else if(Array.isArray(t))u=e||{},i=void 0!==t[0]?t[0]:0,o=void 0!==t[1]?t[1]:0,s=void 0!==t[2]?t[2]:0,h=void 0!==t[3]?t[3]:u.base||1;else if(void 0!==t.r)u=e||{},i=t.r,o=t.g,s=t.b,h=void 0!==t.a?t.a:u.base||1;else if("string"==typeof t){if(0===t.indexOf("#"))return t;if(0===t.indexOf("rgb"))return t;if(-1!==colors.indexOf(t))return t}else"number"==typeof t&&(1===arguments.length?(i=o=s=t,h=1):2===arguments.length?(i=o=s=t,"number"==typeof e?h=e:(u=e,h=u.base||1)):3===arguments.length?"number"==typeof r?(i=t,o=e,s=r,h=1):(i=o=s=t,h=e,u=r):4===arguments.length?(i=t,o=e,s=r,"number"==typeof a?h=a:(u=a||{},h=u.base||1)):(i=t,o=e,s=r,h=a,u=n));if("number"!=typeof i||"number"!=typeof o||"number"!=typeof s||"number"!=typeof h)throw new Error("Invalid color arguments");return u=u||{},void 0!==u.base&&(i/=u.base,o/=u.base,s/=u.base,h/=u.base),l=Math.round(255*i),g=Math.round(255*o),m=Math.round(255*s),"rgba("+l+", "+g+", "+m+", "+h+")"}function toGradientData(t,e,r,a,n){var i,o,s,h,l,g,m={};if(1===arguments.length)g=t||{},i=g.startColor,o=g.endColor,s=g.type,h=g.rotation,l=g.spread;else if(arguments.length>=2)if(i=t,o=e,s="linear",h=0,l=0,3===arguments.length)"string"==typeof r?s=r:"number"==typeof r&&(h=r);else if(4===arguments.length)if("number"==typeof r)h=r,l=a;else if("linear"===r)h=a;else{if("radial"!==r)throw new Error("Wrong argument provided: "+r);s=r,l=a}else 5===arguments.length&&(s=r,h=a,l=n);if(!i&&0!==i)throw new Error("No startColor was given.");if(!o&&0!==o)throw new Error("No endColor was given.");try{m.startColor=toColor(i)}catch(u){throw new Error("startColor is not a valid color: "+i)}try{m.endColor=toColor(o)}catch(d){throw new Error("endColor is not a valid color: "+o)}if(void 0===s&&(s="linear"),"linear"!==s&&"radial"!==s)throw new Error("Unknown gradient type: "+s);if(m.type=s,void 0===l&&(l=0),"number"!=typeof l)throw new Error("Spread value is not a number: "+l);if("linear"===s){if(void 0===h&&(h=0),"number"!=typeof h)throw new Error("Rotation value is not a number: "+h);m.rotation=h}return m.spread=clamp(l,0,.99),m}function findType(t){if("string"==typeof t)return TYPE_PATH;if(t instanceof Image)return TYPE_IMAGE;if(t instanceof HTMLCanvasElement)return TYPE_HTML_CANVAS;if(t instanceof ImageCanvas)return TYPE_IMAGE_CANVAS;if(void 0!==t.r&&void 0!==t.g&&void 0!==t.b&&void 0!==t.a)return TYPE_FILL;if(void 0!==t.startColor&&void 0!==t.endColor)return TYPE_GRADIENT;throw new Error("Cannot establish type for data ",t)}function isPoint(t){return t?void 0!==t.x&&void 0!==t.y:!1}function pointFromArray(t){var e=t[0],r=t.length>1?t[1]:e;return{x:e,y:r}}function pointFromNumber(t){return{x:t,y:t}}function isValidArg(t){return void 0!==t&&null!==t}function convertArg(t){return Array.isArray(t)?pointFromArray(t):"number"==typeof t?pointFromNumber(t):isPoint(t)?t:void 0}function loadImage(t,e){var r=new Image;r.onload=function(){e(null,[t,this])},r.src=t}function loadImages(t,e){async.map(t,loadImage,function(t,r){if(e){for(var a,n,i={},o=0;o<r.length;o+=1)a=r[o][0],n=r[o][1],i[a]=n;e(i)}})}function rectUnite(t,e){var r=Math.min(t.x,e.x),a=Math.min(t.y,e.y),n=Math.max(t.x+t.width,e.x+e.width)-r,i=Math.max(t.y+t.height,e.y+e.height)-a;return{x:r,y:a,width:n,height:i}}function merge(t){var e,r,a,n;for(e=0;e<t.length;e+=1)r=t[e],a=0===e?r.bounds():rectUnite(a,r.bounds());var i=a.width/2+a.x,o=a.height/2+a.y,s=new ImageCanvas(a.width,a.height);for(e=0;e<t.length;e+=1)n=s.addLayer(t[e].toLayer()),n.translate(-i,-o);return new Img(s.render(),i,o)}var util=require("./util"),CanvasRenderer=require("./canvasrenderer"),AsyncRenderer=require("./asyncrenderer"),img,ImageCanvas,Layer,Img,DEFAULT_WIDTH=800,DEFAULT_HEIGHT=800,TYPE_PATH="path",TYPE_IMAGE="image",TYPE_HTML_CANVAS="htmlCanvas",TYPE_IMAGE_CANVAS="iCanvas",TYPE_FILL="fill",TYPE_GRADIENT="gradient",IDENTITY_TRANSFORM=util.transform(),Transform=IDENTITY_TRANSFORM,clamp=util.clamp,colors=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"];Layer=function(t,e){e||(e=findType(t)),this.data=t,this.type=e,(e===TYPE_HTML_CANVAS||e===TYPE_IMAGE_CANVAS||e===TYPE_IMAGE)&&(this.width=t.width,this.height=t.height),this.opacity=1,this.blendmode="source-over",this.transform=IDENTITY_TRANSFORM,this.flip_h=!1,this.flip_v=!1,this.mask=new ImageCanvas,this.filters=[]},Layer.Transform=Layer.IDENTITY_TRANSFORM=IDENTITY_TRANSFORM,Layer.prototype.clone=function(){function t(t){var e,r,a={};if(a.name=t.name,void 0!==t.options){a.options={};for(var n=Object.keys(t.options),i=0;i<n.length;i+=1)e=n[i],r=t.options[e],Array.isArray(r)?a.options[e]=r.slice(0):a.options[e]=r}return a}var e=Object.create(Layer.prototype);e.data=this.data,e.type=this.type,e.width=this.width,e.height=this.height,e.opacity=this.opacity,e.blendmode=this.blendmode,e.transform=this.transform,e.flip_h=this.flip_h,e.flip_v=this.flip_v,e.mask=this.mask.clone(),e.filters=[],this.type===TYPE_IMAGE_CANVAS?e.data=this.data.clone():this.type===TYPE_GRADIENT&&(e.data={startColor:this.data.startColor,endColor:this.data.endColor,type:this.data.type,rotation:this.data.rotation,spread:this.data.spread});for(var r=0;r<this.filters.length;r+=1)e.filters.push(t(this.filters[r]));return e},Layer.prototype.setOpacity=function(t){this.opacity=clamp(t,0,1)},Layer.prototype.translate=function(t,e){e=void 0===e?0:e;var r=Transform.translate(t,e);this.transform=this.transform.prepend(r)},Layer.prototype.scale=function(t,e){e=void 0===e?t:e;var r=Transform.scale(t,e);this.transform=this.transform.prepend(r)},Layer.prototype.rotate=function(t){var e=Transform.rotate(t);this.transform=this.transform.prepend(e)},Layer.prototype.skew=function(t,e){e=void 0===e?t:e;var r=Transform.skew(t,e);this.transform=this.transform.prepend(r)},Layer.prototype.flipHorizontal=function(t){void 0!==t?this.flip_h=t:this.flip_h=!this.flip_h},Layer.prototype.flipVertical=function(t){void 0!==t?this.flip_v=t:this.flip_v=!this.flip_v},Layer.prototype.addFilter=function(t,e){this.filters.push({name:t,options:e})},Layer.prototype.draw=function(t){var e=void 0===this.width?DEFAULT_WIDTH:this.width,r=void 0===this.height?DEFAULT_HEIGHT:this.height,a=new ImageCanvas(e,r);a.addLayer(this),a.draw(t)},Layer.prototype.toCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return this.draw(e),t},Layer.fromFile=function(t){return new Layer(t,TYPE_PATH)},Layer.fromImage=function(t){return new Layer(t,TYPE_IMAGE)},Layer.fromCanvas=function(t){return t instanceof HTMLCanvasElement?Layer.fromHtmlCanvas(t):Layer.fromImageCanvas(t)},Layer.fromHtmlCanvas=function(t){return new Layer(t,TYPE_HTML_CANVAS)},Layer.fromImageCanvas=function(t){return new Layer(t,TYPE_IMAGE_CANVAS)},Layer.fromColor=function(t){return new Layer(toColor(t),TYPE_FILL)},Layer.fromGradient=function(){return new Layer(toGradientData.apply(null,arguments),TYPE_GRADIENT)},Layer.prototype.isPath=function(){return this.type===TYPE_PATH},Layer.prototype.isFill=function(){return this.type===TYPE_FILL},Layer.prototype.isGradient=function(){return this.type===TYPE_GRADIENT},Layer.prototype.isHtmlCanvas=function(){return this.type===TYPE_HTML_CANVAS},Layer.prototype.isImage=function(){return this.type===TYPE_IMAGE},Layer.prototype.isImageCanvas=function(){return this.type===TYPE_IMAGE_CANVAS};var Pixels=function(t){this.width=t.width,this.height=t.height;var e=t.getContext("2d");this._data=e.getImageData(0,0,this.width,this.height),this.array=this._data.data};Pixels.prototype.get=function(t){t*=4;var e=this.array;return[e[t+0],e[t+1],e[t+2],e[t+3]]},Pixels.prototype.set=function(t,e){t*=4;var r=this.array;r[t+0]=e[0],r[t+1]=e[1],r[t+2]=e[2],r[t+3]=e[3]},Pixels.prototype.toCanvas=function(){var t=document.createElement("canvas");t.width=this.width,t.height=this.height;var e=t.getContext("2d");return e.putImageData(this._data,0,0),t},ImageCanvas=function(t,e){t||(t=DEFAULT_WIDTH),e||(e=DEFAULT_HEIGHT),this.width=t,this.height=e,this.layers=[]},ImageCanvas.prototype.clone=function(){for(var t=new ImageCanvas(this.width,this.height),e=0;e<this.layers.length;e+=1)t.layers.push(this.layers[e].clone());return t},ImageCanvas.prototype.addLayer=function(t){var e;try{return this.addGradientLayer.apply(this,arguments)}catch(r){}try{return this.addColorLayer.apply(this,arguments)}catch(a){}if(1===arguments.length&&("string"==typeof t?e=new Layer(t,TYPE_PATH):t instanceof Layer?e=t:t instanceof HTMLCanvasElement?e=new Layer(t,TYPE_HTML_CANVAS):t instanceof Image?e=new Layer(t,TYPE_IMAGE):t instanceof ImageCanvas&&(e=new Layer(t,TYPE_IMAGE_CANVAS))),!e)throw new Error("Error creating layer.");return this.layers.push(e),e},ImageCanvas.prototype.addColorLayer=function(){var t=toColor.apply(null,arguments),e=new Layer(t,TYPE_FILL);return this.layers.push(e),e},ImageCanvas.prototype.addGradientLayer=function(){var t=toGradientData.apply(null,arguments),e=new Layer(t,TYPE_GRADIENT);return this.layers.push(e),e},ImageCanvas.prototype.render=function(t){var e=t?AsyncRenderer:CanvasRenderer;return e.render(this,t)},ImageCanvas.prototype.draw=function(t,e){if(e)this.render(function(e){t.drawImage(e,0,0,e.width,e.height)});else{var r=this.render();t.drawImage(r,0,0,r.width,r.height)}},Img=function(t,e,r){this.canvas=t,this.originalWidth=t?t.width:0,this.originalHeight=t?t.height:0,this.transform=e||r?Transform.translate(e,r):Layer.IDENTITY_TRANSFORM},Img.prototype.clone=function(){var t=new Img;return t.canvas=this.canvas,t.originalWidth=this.originalWidth,t.originalHeight=this.originalHeight,t.transform=this.transform,t},Img.prototype.withCanvas=function(t){var e=this.clone();return e.canvas=t,e},Img.prototype._transform=function(t){var e=this.clone();return e.transform=e.transform.prepend(t),e},Img.prototype.translate=function(t){var e=pointFromNumber(0),r=arguments;return 1===r.length&&isValidArg(t)?e=convertArg(t):2===r.length&&(e={x:r[0],y:r[1]}),0===e.x&&0===e.y?this:this._transform(Transform.translate(e.x,e.y))},Img.prototype.rotate=function(t){if(!t)return this;var e=pointFromNumber(0),r=arguments;return 2===r.length?e=convertArg(r[1]):3===r.length&&(e={x:r[1],y:r[2]}),this._transform(Transform.translate(e.x,e.y).rotate(t).translate(-e.x,-e.y))},Img.prototype.scale=function(t){var e=pointFromNumber(1),r=pointFromNumber(0),a=arguments;return 1===a.length&&isValidArg(t)?e=convertArg(t):2===a.length?"number"==typeof t&&"number"==typeof a[1]?e={x:a[0],y:a[1]}:(e=convertArg(t),r=convertArg(a[1])):4===a.length&&(e={x:a[0],y:a[1]},r={x:a[2],y:a[3]}),1===e.x&&1===e.y?this:this._transform(Transform.translate(r.x,r.y).scale(e.x,e.y).translate(-r.x,-r.y))},Img.prototype.skew=function(t){var e=pointFromNumber(0),r=pointFromNumber(0),a=arguments;return 1===a.length&&isValidArg(t)?e=convertArg(t):2===a.length?"number"==typeof t&&"number"==typeof a[1]?e={x:a[0],y:a[1]}:(e=convertArg(t),r=convertArg(a[1])):4===a.length&&(e={x:a[0],y:a[1]},r={x:a[2],y:a[3]}),0===e.x&&0===e.y?this:this._transform(Transform.translate(r.x,r.y).skew(e.x,e.y).translate(-r.x,-r.y))},Img.prototype.transformed=function(){return img.merge([this])},Img.prototype.bounds=function(){for(var t,e,r,a,n,i=this.transform,o=this.originalWidth/2,s=this.originalHeight/2,h={x:-o,y:-s},l={x:o,y:-s},g={x:-o,y:s},m={x:o,y:s},u=[h,l,g,m],d=0;4>d;d+=1)t=i.transformPoint(u[d]),0===d?(e=a=t.x,r=n=t.y):(t.x<e&&(e=t.x),t.x>a&&(a=t.x),t.y<r&&(r=t.y),t.y>n&&(n=t.y));return{x:e,y:r,width:a-e,height:n-r}},Img.prototype.colorize=function(t){var e=Layer.fromColor(t);e.width=this.originalWidth,e.height=this.originalHeight;var r=new Img(e.toCanvas());return r=r._transform(this.transform.matrix()),img.merge([this,r])},Img.prototype.desaturate=function(){var t=this.toLayer(!1);return t.addFilter("desaturate"),this.withCanvas(t.toCanvas())},Img.prototype.crop=function(t){function e(t,e){var r=t.x+t.width,a=t.y+t.height,n=e.x+e.width,i=e.y+e.height,o=Math.max(t.x,e.x),s=Math.max(t.y,e.y),h=Math.max(Math.min(r,n)-o,0),l=Math.max(Math.min(a,i)-s,0);return{x:o,y:s,width:h,height:l}}var r=this.bounds(),a=t.bounds(),n=e(r,a),i=Math.ceil(n.width),o=Math.ceil(n.height);if(0===n.width||0===n.height)throw new Error("Resulting image has no dimensions");var s=new img.ImageCanvas(i,o),h=s.addLayer(this.toLayer());return h.translate(i/2-a.width-a.x,o/2-a.height-a.y),i<a.width&&n.x>r.x&&h.translate(a.width-i,0),o<a.height&&n.y>r.y&&h.translate(0,a.height-o),new Img(s.render(),n.x+i/2,n.y+o/2)},Img.prototype.draw=function(t){t.save();var e=this.transform.matrix();t.transform(e[0],e[1],e[3],e[4],e[6],e[7]),t.translate(-this.originalWidth/2,-this.originalHeight/2),t.drawImage(this.canvas,0,0),t.restore()},Img.prototype.toLayer=function(t){var e=document.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height;var r=e.getContext("2d");r.drawImage(this.canvas,0,0);var a=img.Layer.fromHtmlCanvas(e);return void 0===t&&(t=!0),t&&(a.transform=this.transform),a},Img.prototype.getPixels=function(){return new Pixels(this.canvas)},Img.prototype.toImage=function(){var t=this.bounds(),e=this.crop({bounds:function(){return t}}),r=new Image;return r.width=e.canvas.width,r.height=e.canvas.height,r.src=e.canvas.toDataURL(),r},img={},img.Layer=Layer,img.ImageCanvas=ImageCanvas,img.Img=Img,img.Pixels=Pixels;var async=require("async");img.loadImages=loadImages,img.merge=merge,module.exports=img;
},{"./asyncrenderer":4,"./canvasrenderer":6,"./util":9,"async":1}],8:[function(require,module,exports){

@@ -31,0 +31,0 @@ "use strict";function defaultOptions(o,n){if(!o)return n;var t,r={};for(t in n)n.hasOwnProperty(t)&&("undefined"==typeof o[t]?r[t]=n[t]:r[t]=o[t]);return r}function smoothstep(o,n,t){return o>t?0:t>=n?1:(t=(t-o)/(n-o),t*t*(3-2*t))}function noise(){return.5*Math.random()+.5}function colorDistance(o,n,t){return clamp(o*n+(1-o)*t,0,255)}function convolve3x3(o,n,t,r,a,e,i,u){var f,c,l,s,v,p,d,m,h,x,g,O,M,b,y,z,k,w,P,q,S,A,j=a[0][0],D=a[0][1],I=a[0][2],B=a[1][0],C=a[1][1],E=a[1][2],F=a[2][0],G=a[2][1],H=a[2][2];for(c=0;r>c;c+=1)for(m=c*t*4,h=m-4*t,x=m+4*t,1>c&&(h=m),c>=t-1&&(x=m),f=0;t>f;f+=1)l=4*(c*t+f),g=4*f,O=g-4,M=g+4,1>f&&(O=g),f>=t-1&&(M=g),b=h+O,y=h+g,z=h+M,k=m+O,w=m+g,P=m+M,q=x+O,S=x+g,A=x+M,s=o[b]*j+o[y]*D+o[z]*I+o[k]*B+o[w]*C+o[P]*E+o[q]*F+o[S]*G+o[A]*H,v=o[b+1]*j+o[y+1]*D+o[z+1]*I+o[k+1]*B+o[w+1]*C+o[P+1]*E+o[q+1]*F+o[S+1]*G+o[A+1]*H,p=o[b+2]*j+o[y+2]*D+o[z+2]*I+o[k+2]*B+o[w+2]*C+o[P+2]*E+o[q+2]*F+o[S+2]*G+o[A+2]*H,d=e?o[b+3]*j+o[y+3]*D+o[z+3]*I+o[k+3]*B+o[w+3]*C+o[P+3]*E+o[q+3]*F+o[S+3]*G+o[A+3]*H:o[l+3],u&&(s=v=p=(s+v+p)/3),i&&(s=255-s,v=255-v,p=255-p),n[l]=s,n[l+1]=v,n[l+2]=p,n[l+3]=d}function convolve5x5(o,n,t,r,a,e,i,u){var f,c,l,s,v,p,d,m,h,x,g,O,M,b,y,z,k,w,P,q,S,A,j,D,I,B,C,E,F,G,H,J,K,L,N,Q,R,T,U,V,W,X,Y=a[0][0],Z=a[0][1],$=a[0][2],_=(a[0][3],a[0][4]),oo=a[1][0],no=a[1][1],to=a[1][2],ro=(a[1][3],a[1][4]),ao=a[2][0],eo=a[2][1],io=a[2][2],uo=(a[2][3],a[2][4]),fo=a[3][0],co=a[3][1],lo=a[3][2],so=(a[3][3],a[3][4]),vo=a[4][0],po=a[4][1],mo=a[4][2],ho=(a[4][3],a[4][4]);for(c=0;r>c;c+=1)for(m=c*t*4,h=m-4*t,g=m-4*t*2,x=m+4*t,O=m+4*t*2,1>c&&(h=m),c>=t-1&&(x=m),2>c&&(g=h),c>=t-2&&(O=x),f=0;t>f;f+=1)l=4*(c*t+f),M=4*f,b=M-4,y=M+4,z=M-8,k=M+8,1>f&&(b=M),f>=t-1&&(y=M),2>f&&(z=b),f>=t-2&&(k=y),w=g+z,P=g+b,q=g+M,S=g+y,A=g+k,j=h+z,D=h+b,I=h+M,B=h+y,C=h+k,E=m+z,F=m+b,G=m+M,H=m+y,J=m+k,K=x+z,L=x+b,N=x+M,Q=x+y,R=x+k,T=O+z,U=O+b,V=O+M,W=O+y,X=O+k,s=o[w]*Y+o[P]*Z+o[q]*$+o[S]*_+o[q]*_+o[j]*oo+o[D]*no+o[I]*to+o[B]*ro+o[I]*ro+o[E]*ao+o[F]*eo+o[G]*io+o[H]*uo+o[G]*uo+o[K]*fo+o[L]*co+o[N]*lo+o[Q]*so+o[N]*so+o[T]*vo+o[U]*po+o[V]*mo+o[W]*ho+o[V]*ho,v=o[w+1]*Y+o[P+1]*Z+o[q+1]*$+o[S+1]*_+o[q+1]*_+o[j+1]*oo+o[D+1]*no+o[I+1]*to+o[B+1]*ro+o[I+1]*ro+o[E+1]*ao+o[F+1]*eo+o[G+1]*io+o[H+1]*uo+o[G+1]*uo+o[K+1]*fo+o[L+1]*co+o[N+1]*lo+o[Q+1]*so+o[N+1]*so+o[T+1]*vo+o[U+1]*po+o[V+1]*mo+o[W+1]*ho+o[V+1]*ho,p=o[w+2]*Y+o[P+2]*Z+o[q+2]*$+o[S+2]*_+o[q+2]*_+o[j+2]*oo+o[D+2]*no+o[I+2]*to+o[B+2]*ro+o[I+2]*ro+o[E+2]*ao+o[F+2]*eo+o[G+2]*io+o[H+2]*uo+o[G+2]*uo+o[K+2]*fo+o[L+2]*co+o[N+2]*lo+o[Q+2]*so+o[N+2]*so+o[T+2]*vo+o[U+2]*po+o[V+2]*mo+o[W+2]*ho+o[V+2]*ho,d=e?o[w+3]*Y+o[P+3]*Z+o[q+3]*$+o[S+3]*_+o[q+3]*_+o[j+3]*oo+o[D+3]*no+o[I+3]*to+o[B+3]*ro+o[I+3]*ro+o[E+3]*ao+o[F+3]*eo+o[G+3]*io+o[H+3]*uo+o[G+3]*uo+o[K+3]*fo+o[L+3]*co+o[N+3]*lo+o[Q+3]*so+o[N+3]*so+o[T+3]*vo+o[U+3]*po+o[V+3]*mo+o[W+3]*ho+o[V+3]*ho:o[l+3],u&&(s=v=p=(s+v+p)/3),i&&(s=255-s,v=255-v,p=255-p),n[l]=s,n[l+1]=v,n[l+2]=p,n[l+3]=d}function gaussian(o,n,t,r,a){var e,i,u,f,c,l,s,v,p,d,m,h,x,g,O,M=[],b=13,y=[[1]];for(a=clamp(a,3,b),x=-a/2+(a%2?.5:0),g=a+x,u=1;b>u;u+=1)y[0][u]=0;for(u=1;b>u;u+=1)for(y[u]=[1],f=1;b>f;f+=1)y[u][f]=y[u-1][f]+y[u-1][f-1];for(O=y[a-1],u=0,h=0;a>u;u+=1)h+=O[u];for(u=0;a>u;u+=1)O[u]/=h;for(i=0;r>i;i+=1)for(e=0;t>e;e+=1){for(c=l=s=v=0,u=x;g>u;u+=1)d=e+u,m=i,h=O[u-x],0>d&&(d=0),d>=t&&(d=t-1),p=4*(m*t+d),c+=o[p]*h,l+=o[p+1]*h,s+=o[p+2]*h,v+=o[p+3]*h;p=4*(i*t+e),M[p]=c,M[p+1]=l,M[p+2]=s,M[p+3]=v}for(i=0;r>i;i+=1)for(e=0;t>e;e+=1){for(c=l=s=v=0,u=x;g>u;u+=1)d=e,m=i+u,h=O[u-x],0>m&&(m=0),m>=r&&(m=r-1),p=4*(m*t+d),c+=M[p]*h,l+=M[p+1]*h,s+=M[p+2]*h,v+=M[p+3]*h;p=4*(i*t+e),n[p]=c,n[p+1]=l,n[p+2]=s,n[p+3]=v}}function getPixel(o,n){return n*=4,[o[n+0],o[n+1],o[n+2],o[n+3]]}function setPixel(o,n,t){n*=4,o[n+0]=t[0],o[n+1]=t[1],o[n+2]=t[2],o[n+3]=t[3]}function polar(o,n,t,r,a,e,i){t=a/2+(t||0),r=e/2+(r||0);var u,f,c,l,s,v,p;for(u=0;e>u;u+=1)for(f=0;a>f;f+=1)c=f-t,l=u-r,s=Math.sqrt(Math.pow(c,2)+Math.pow(l,2)),v=Math.atan2(l,c),p=i(s,v),s=p[0],v=p[1],setPixel(n,f+u*a,getPixel(o,Math.round(t+Math.cos(v)*s)+Math.round(r+Math.sin(v)*s)*a))}var stackblur=require("stackblur"),util=require("./util"),clamp=util.clamp,process={invert:function(o,n,t,r){var a,e=t*r*4;for(a=0;e>a;a+=4)n[a]=255-o[a],n[a+1]=255-o[a+1],n[a+2]=255-o[a+2],n[a+3]=o[a+3]},sepia:function(o,n,t,r){var a,e,i,u,f=t*r*4;for(a=0;f>a;a+=4)e=o[a],i=o[a+1],u=o[a+2],n[a]=.393*e+.769*i+.189*u,n[a+1]=.349*e+.686*i+.168*u,n[a+2]=.272*e+.534*i+.131*u,n[a+3]=o[a+3]},solarize:function(o,n,t,r){var a,e,i,u,f=t*r*4;for(a=0;f>a;a+=4)e=o[a],i=o[a+1],u=o[a+2],n[a]=e>127?255-e:e,n[a+1]=i>127?255-i:i,n[a+2]=u>127?255-u:u,n[a+3]=o[a+3]},brightness:function(o,n,t,r,a){a=defaultOptions(a,{brightness:1,contrast:0});var e,i,u,f,c,l=t*r*4,s=clamp(a.contrast,-1,1)/2,v=1+clamp(a.brightness,-1,1),p=0>v?-v:v,d=0>v?0:v;for(s=.5*Math.tan((s+1)*Math.PI/4),c=255*-(s-.5),e=0;l>e;e+=4)i=o[e],u=o[e+1],f=o[e+2],i=(i+i*p+d)*s+c,u=(u+u*p+d)*s+c,f=(f+f*p+d)*s+c,n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},desaturate:function(o,n,t,r){var a,e,i=t*r*4;for(a=0;i>a;a+=4)e=.3*o[a]+.59*o[a+1]+.11*o[a+2],n[a]=e,n[a+1]=e,n[a+2]=e,n[a+3]=o[a+3]},lighten:function(o,n,t,r,a){a=defaultOptions(a,{amount:.25});var e,i=t*r*4,u=1+clamp(a.amount,0,1);for(e=0;i>e;e+=4)n[e]=o[e]*u,n[e+1]=o[e+1]*u,n[e+2]=o[e+2]*u,n[e+3]=o[e+3]},noise:function(o,n,t,r,a){a=defaultOptions(a,{amount:.5,strength:.5,mono:!1});var e,i,u,f,c,l=t*r*4,s=clamp(a.amount,0,1),v=clamp(a.strength,0,1),p=!!a.mono,d=Math.random;for(e=0;l>e;e+=4)u=o[e],f=o[e+1],c=o[e+2],i=d(),s>i&&(p?(i=v*(i/s*2-1)*255,u+=i,f+=i,c+=i):(u+=v*d()*255,f+=v*d()*255,c+=v*d()*255)),n[e]=u,n[e+1]=f,n[e+2]=c,n[e+3]=o[e+3]},flipv:function(o,n,t,r){var a,e,i,u;for(e=0;r>e;e+=1)for(a=0;t>a;a+=1)i=4*(e*t+a),u=4*(e*t+(t-a-1)),n[u]=o[i],n[u+1]=o[i+1],n[u+2]=o[i+2],n[u+3]=o[i+3]},fliph:function(o,n,t,r){var a,e,i,u;for(e=0;r>e;e+=1)for(a=0;t>a;a+=1)i=4*(e*t+a),u=4*((r-e-1)*t+a),n[u]=o[i],n[u+1]=o[i+1],n[u+2]=o[i+2],n[u+3]=o[i+3]},blur:function(o,n,t,r,a){a=defaultOptions(a,{radius:10});for(var e=0;e<o.length;e+=1)n[e]=o[e];stackblur(n,t,r,a.radius)},glow:function(o,n,t,r,a){a=defaultOptions(a,{amount:.75,kernelSize:5});var e,i,u,f,c=t*r*4,l=a.amount,s=[];for(gaussian(o,s,t,r,a.kernelSize),e=0;c>e;e+=4)i=o[e]+s[e]*l,u=o[e+1]+s[e+1]*l,f=o[e+2]+s[e+2]*l,i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},convolve3x3:function(o,n,t,r,a){convolve3x3(o,n,t,r,a.kernel)},convolve5x5:function(o,n,t,r,a){convolve5x5(o,n,t,r,a.kernel)},sharpen3x3:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=-clamp(a.strength,0,1);convolve3x3(o,n,t,r,[[e,e,e],[e,1-8*e,e],[e,e,e]])},sharpen5x5:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=-clamp(a.strength,0,1);convolve5x5(o,n,t,r,[[e,e,e,e,e],[e,e,e,e,e],[e,e,1-24*e,e,e],[e,e,e,e,e],[e,e,e,e,e]])},soften3x3:function(o,n,t,r){var a=1/9;convolve3x3(o,n,t,r,[[a,a,a],[a,a,a],[a,a,a]])},soften5x5:function(o,n,t,r){var a=.04;convolve5x5(o,n,t,r,[[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a],[a,a,a,a,a]])},crossedges:function(o,n,t,r,a){a=defaultOptions(a,{strength:1});var e=5*clamp(a.strength,0,1);convolve3x3(o,n,t,r,[[0,-e,0],[-e,0,e],[0,e,0]],!1,!0)},emboss:function(o,n,t,r,a){a=defaultOptions(a,{amount:1,angle:0});var e,i=t*r*4,u=a.amount,f=a.angle,c=Math.cos(-f)*u,l=Math.sin(-f)*u,s=-c-l,v=-c,p=l-c,d=-l,m=l,h=-l+c,x=c,g=l+c,O=[];for(convolve3x3(o,O,t,r,[[s,d,h],[v,0,x],[p,m,g]]),e=0;i>e;e+=4)n[e]=128+O[e],n[e+1]=128+O[e+1],n[e+2]=128+O[e+2],n[e+3]=o[e+3]},findedges:function(o,n,t,r){var a,e,i,u,f,c,l,s=t*r*4,v=[],p=[];for(convolve3x3(o,v,t,r,[[-1,0,1],[-2,0,2],[-1,0,1]]),convolve3x3(o,p,t,r,[[-1,-2,-1],[0,0,0],[1,2,1]]),a=0;s>a;a+=4)e=v[a],i=p[a],u=v[a+1],f=p[a+1],c=v[a+2],l=p[a+2],0>e&&(e=-e),0>i&&(i=-i),0>u&&(u=-u),0>f&&(f=-f),0>c&&(c=-c),0>l&&(l=-l),n[a]=255-.8*(e+i),n[a+1]=255-.8*(u+f),n[a+2]=255-.8*(c+l),n[a+3]=o[a+3]},edgeenhance3x3:function(o,n,t,r){var a=-1/9;convolve3x3(o,n,t,r,[[a,a,a],[a,17/9,a],[a,a,a]])},edgeenhance5x5:function(o,n,t,r){var a=-0.04;convolve5x5(o,n,t,r,[[a,a,a,a,a],[a,a,a,a,a],[a,a,1.96,a,a],[a,a,a,a,a],[a,a,a,a,a]])},laplace3x3:function(o,n,t,r){convolve3x3(o,n,t,r,[[-1,-1,-1],[-1,8,-1],[-1,-1,-1]],!1,!0,!0)},laplace5x5:function(o,n,t,r){convolve5x5(o,n,t,r,[[-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1],[-1,-1,24,-1,-1],[-1,-1,-1,-1,-1],[-1,-1,-1,-1,-1]],!1,!0,!0)},coloradjust:function(o,n,t,r,a){a=defaultOptions(a,{r:0,g:0,b:0});var e,i,u,f,c=t*r*4,l=255*clamp(a.r,-1,1),s=255*clamp(a.g,-1,1),v=255*clamp(a.b,-1,1);for(e=0;c>e;e+=4)i=o[e]+l,u=o[e+1]+s,f=o[e+2]+v,0>i&&(i=0),0>u&&(u=0),0>f&&(f=0),i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},colorfilter:function(o,n,t,r,a){a=defaultOptions(a,{luminosity:!1,r:1,g:.5,b:0});var e,i,u,f,c,l,s,v,p,d,m,h=t*r*4,x=!!a.luminosity,g=clamp(a.r,0,1),O=clamp(a.g,0,1),M=clamp(a.b,0,1);for(e=0;h>e;e+=4)i=o[e]/255,u=o[e+1]/255,f=o[e+2]/255,v=.3*i+.59*u+.11*f,i=(i+i*g)/2,u=(u+u*O)/2,f=(f+f*M)/2,x&&(c=l=i,u>l&&(l=u),f>l&&(l=f),c>u&&(c=u),c>f&&(c=f),d=l-c,s=i===l?(u-f)/d%6:u===l?(f-i)/d+2:(i-u)/d+4,p=s>>0,m=d*(s-p),i=u=f=v-(.3*i+.59*u+.11*f),0===p?(i+=d,u+=m):1===p?(i+=d-m,u+=d):2===p?(u+=d,f+=m):3===p?(u+=d-m,f+=d):4===p?(i+=m,f+=d):5===p&&(i+=d,f+=d-m)),n[e]=255*i,n[e+1]=255*u,n[e+2]=255*f,n[e+3]=o[e+3]},hsl:function(o,n,t,r,a){a=defaultOptions(a,{hue:.5,saturation:.3,lightness:.1});var e,i,u,f,c,l,s,v,p,d,m,h,x,g,O=t*r*4,M=clamp(a.hue,-1,1),b=clamp(a.saturation,-1,1),y=clamp(a.lightness,-1,1),z=1+b*(0>b?1:2),k=0>y?1+y:1-y,w=0>y?0:255*y;for(M=6*M%6,e=0;O>e;e+=4)i=o[e],u=o[e+1],f=o[e+2],(0!==M||0!==b)&&(c=i,u>c&&(c=u),f>c&&(c=f),l=i,l>u&&(l=u),l>f&&(l=f),s=c-l,d=(l+c)/510,d>0&&s>0&&(.5>=d?(p=s/(c+l)*z,p>1&&(p=1),m=d*(1+p)):(p=s/(510-c-l)*z,p>1&&(p=1),m=d+p-d*p),v=i===c?u===l?5+(c-f)/s+M:1-(c-u)/s+M:u===c?f===l?1+(c-i)/s+M:3-(c-f)/s+M:i===l?3+(c-u)/s+M:5-(c-i)/s+M,0>v&&(v+=6),v>=6&&(v-=6),h=d+d-m,g=v>>0,x=(m-h)*(v-g),0===g?(i=m,u=h+x,f=h):1===g?(i=m-x,u=m,f=h):2===g?(i=h,u=m,f=h+x):3===g?(i=h,u=m-x,f=m):4===g?(i=h+x,u=h,f=m):5===g&&(i=m,u=h,f=m-x),i*=255,u*=255,f*=255)),i=i*k+w,u=u*k+w,f=f*k+w,0>i&&(i=0),0>u&&(u=0),0>f&&(f=0),i>255&&(i=255),u>255&&(u=255),f>255&&(f=255),n[e]=i,n[e+1]=u,n[e+2]=f,n[e+3]=o[e+3]},posterize:function(o,n,t,r,a){a=defaultOptions(a,{levels:5});var e,i=t*r*4,u=clamp(a.levels,2,256),f=256/u,c=256/(u-1);for(e=0;i>e;e+=4)n[e]=c*(o[e]/f>>0),n[e+1]=c*(o[e+1]/f>>0),n[e+2]=c*(o[e+2]/f>>0),n[e+3]=o[e+3]},removenoise:function(o,n,t,r){var a,e,i,u,f,c,l,s,v,p,d,m,h,x,g,O,M,b,y;for(e=0;r>e;e+=1)for(s=e*t*4,v=s-4*t,p=s+4*t,1>e&&(v=s),e>=t-1&&(p=s),a=0;t>a;a+=1)l=4*(e*t+a),d=4*a,m=d-4,h=d+4,1>a&&(m=d),a>=t-1&&(h=d),x=M=o[s+m],c=o[s+h],x>c&&(x=c),c>M&&(M=c),c=o[v+d],x>c&&(x=c),c>M&&(M=c),c=o[p+d],x>c&&(x=c),c>M&&(M=c),g=o[s+m+1],c=o[s+h+1],g>c&&(g=c),c=o[v+d+1],g>c&&(g=c),c=o[p+d+1],g>c&&(g=c),O=o[s+m+2],c=o[s+h+2],O>c&&(O=c),c=o[v+d+2],O>c&&(O=c),c=o[p+d+2],O>c&&(O=c),i=o[l],u=o[l+1],f=o[l+2],x>i&&(i=x),i>M&&(i=M),g>u&&(u=g),u>b&&(u=b),O>f&&(f=O),f>y&&(f=y),n[l]=i,n[l+1]=u,n[l+2]=f,n[l+3]=o[l+3]},mosaic:function(o,n,t,r,a){a=defaultOptions(a,{blockSize:8});var e,i,u,f,c,l,s,v,p,d,m,h,x,g,O=clamp(a.blockSize,1,Math.max(t,r)),M=Math.ceil(r/O),b=Math.ceil(t/O);for(e=0,p=0,s=0;M>s;s+=1){for(i=clamp(e+O,0,r),u=0,v=0;b>v;v+=1){for(f=clamp(u+O,0,t),c=e*t+u<<2,d=o[c],m=o[c+1],h=o[c+2],x=e;i>x;x+=1)for(g=u;f>g;g+=1)l=x*t+g<<2,n[l]=d,n[l+1]=m,n[l+2]=h,n[l+3]=o[l+3];u=f,p+=1}e=i}},equalize:function(o,n,t,r,a){var e,i,u,f,c=t*r,l=Math.round,s=new Array(256);for(i=0;256>i;i+=1)s[i]=0;for(i=0;c>i;i+=1)e=4*i,u=clamp(l(.3*o[e]+.59*o[e+1]+.11*o[e+2]),0,255),n[e+3]=u,s[u]+=1;var v=new Array(256);for(v[0]=s[0],i=1;256>i;i+=1)v[i]=v[i-1]+s[i];for(i=0;256>i;i+=1)v[i]=v[i]/c*255;for(i=0;c>i;i+=1)e=4*i,u=n[e+3],f=v[u]/(u||1),n[e]=clamp(l(o[e]*f),0,255),n[e+1]=clamp(l(o[e+1]*f),0,255),n[e+2]=clamp(l(o[e+2]*f),0,255),n[e+3]=o[e+3]},luminancebw:function(o,n,t,r){var a,e,i=t*r*4;for(a=0;i>a;a+=4)e=.2125*o[a]+.7154*o[a+1]+.0721*o[a+2],n[a]=e,n[a+1]=e,n[a+2]=e,n[a+3]=o[a+3]},mask:function(o,n,t,r,a){var e,i=t*r*4,u=a.data;for(e=0;i>e;e+=4)n[e]=o[e],n[e+1]=o[e+1],n[e+2]=o[e+2],n[e+3]=o[e+3]*u[e]/255*u[e+3]/255},bump:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,zoom:0});var e=a.radius,i=clamp(a.zoom,0,1);return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o*smoothstep(0,i,o/e),n]})},dent:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,zoom:0});var e=a.radius,i=clamp(a.zoom,0,1);return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[2*o-o*smoothstep(0,i,o/e),n]})},pinch:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,zoom:0});var e=util.distance(0,0,t,r),i=clamp(.75*a.zoom,-.75,.75);return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o*Math.pow(e/o,i)*(1-i),n]})},splash:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0});var e=a.radius;return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o>e?e:o,n]})},twirl:function(o,n,t,r,a){a=defaultOptions(a,{dx:0,dy:0,radius:0,angle:0});var e=util.radians(a.angle),i=a.radius;return polar(o,n,a.dx,a.dy,t,r,function(o,n){return[o,n+(1-smoothstep(-i,i,o))*e]})}};module.exports=process;

@@ -11,3 +11,3 @@ {

],
"version": "0.1.4",
"version": "0.1.5",
"repository": {

@@ -14,0 +14,0 @@ "type": "git",

@@ -669,3 +669,3 @@ 'use strict';

Img.prototype.scale = function (scale) {
var s = pointFromNumber(100);
var s = pointFromNumber(1);
var o = pointFromNumber(0);

@@ -686,4 +686,4 @@ var args = arguments;

}
if (s.x === 100 && s.y === 100) { return this; }
return this._transform(Transform.translate(o.x, o.y).scale(s.x / 100, s.y / 100).translate(-o.x, -o.y));
if (s.x === 1 && s.y === 1) { return this; }
return this._transform(Transform.translate(o.x, o.y).scale(s.x, s.y).translate(-o.x, -o.y));
};

@@ -690,0 +690,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc