-
Notifications
You must be signed in to change notification settings - Fork 1
/
glitch-canvas.min.js
1 lines (1 loc) · 12.1 KB
/
glitch-canvas.min.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.glitch=e()}}(function(){return function e(t,a,r){function n(o,i){if(!a[o]){if(!t[o]){var f="function"==typeof require&&require;if(!i&&f)return f(o,!0);if(u)return u(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var d=a[o]={exports:{}};t[o][0].call(d.exports,function(e){var a=t[o][1][e];return n(a?a:e)},d,d.exports,e,t,a,r)}return a[o].exports}for(var u="function"==typeof require&&require,o=0;o<r.length;o++)n(r[o]);return n}({1:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0});var n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e};a["default"]=function(e){function t(){return e}function a(){var e=n({},O);return j||n(e,P),e}function r(){var e=n({},O);return x||n(e,L),e}function u(e){return e}function i(e){return m(f["default"],e)}function s(e){return m(u,e)}function l(e){return y(u)}function g(e){return y(d["default"],e,!0)}function p(e){return y(c["default"],e,!0)}function m(e,t,a){return j=function(){return new Promise(function(r,n){if(a)e(t,r,n);else if(e===u)r(t);else try{r(e(t,r,n))}catch(o){n(o)}})},w()?_():r()}function y(e,t,r){return x=function(a){return new Promise(function(n,o){r?e(a,t,n,o):e===u?n(a):e(a,t).then(n,o)})},w()?_():a()}function w(){return j&&x}function _(){return new Promise(function(t,a){j().then(function(t){return M(t,e)},a).then(function(e){x(e).then(t,a)},a)})}function M(e,t){return new Promise(function(a,r){(0,h["default"])(e,t.quality).then(function(a){return I(e,a,t)},r).then(a,r)})}function I(e,t,a){return new Promise(function(r,n){D.addEventListener("message",function(e){e.data&&e.data.base64URL?r(e.data.base64URL):n(e.data&&e.data.err?e.data.err:e)}),D.postMessage({params:a,base64URL:t,imageData:e,imageDataWidth:e.width,imageDataHeight:e.height})})}e=(0,o["default"])(e);var j=void 0,x=void 0,D=(0,v["default"])(b["default"]),O={getParams:t,getInput:a,getOutput:r},P={fromImageData:s,fromImage:i},L={toImage:g,toDataURL:l,toImageData:p};return a()};var u=e("./input/sanitizeInput"),o=r(u),i=e("./input/browser/fromImage"),f=r(i),s=e("./output/browser/toImage"),d=r(s),l=e("./output/toImageData"),c=r(l),g=e("./glitch/browser/imageDataToBase64"),h=r(g),p=e("./glitch/glitchImageData"),m=(r(p),e("webworkify")),v=r(m),y=e("./workers/glitchWorker"),b=r(y);t.exports=a["default"]},{"./glitch/browser/imageDataToBase64":4,"./glitch/glitchImageData":7,"./input/browser/fromImage":9,"./input/sanitizeInput":11,"./output/browser/toImage":12,"./output/toImageData":13,"./workers/glitchWorker":20,webworkify:22}],2:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=r.split(""),u={};n.forEach(function(e,t){u[e]=t}),a["default"]={map:n,reverse:u},t.exports=a["default"]},{}],3:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){for(var t,a,n,u=[],o=23,i=e.length;i>o;o++){switch(a=r.reverse[e.charAt(o)],t=(o-23)%4){case 1:u.push(n<<2|a>>4);break;case 2:u.push((15&n)<<4|a>>2);break;case 3:u.push((3&n)<<6|a)}n=a}return u};var r=e("./base64Map");t.exports=a["default"]},{"./base64Map":2}],4:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e,t){return new Promise(function(a,r){if((0,i["default"])(e)){var n=new u["default"](e.width,e.height),o=n.getContext("2d");o.putImageData(e,0,0);var f=n.toDataURL("image/jpeg",t/100);a(f)}else r(new Error("object is not valid imageData"))})};var n=e("canvas-browserify"),u=r(n),o=e("../../util/isImageData"),i=r(o);t.exports=a["default"]},{"../../util/isImageData":18,"canvas-browserify":21}],5:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){for(var t=["data:image/jpeg;base64,"],a=void 0,n=void 0,u=void 0,o=0,i=e.length;i>o;o++){switch(n=e[o],a=o%3){case 0:t.push(r.map[n>>2]);break;case 1:t.push(r.map[(3&u)<<4|n>>4]);break;case 2:t.push(r.map[(15&u)<<2|n>>6]),t.push(r.map[63&n])}u=n}return 0===a?(t.push(r.map[(3&u)<<4]),t.push("==")):1===a&&(t.push(r.map[(15&u)<<2]),t.push("=")),t.join("")};var r=e("./base64Map");t.exports=a["default"]},{"./base64Map":2}],6:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e,t,a,r){for(var n=(0,u["default"])(e),o=e.length-n-4,i=a/100,f=t/100,s=0;r>s;s++){var d=o/r*s|0,l=o/r*(s+1)|0,c=l-d,g=d+c*f|0;g>o&&(g=o);var h=~~(n+g);e[h]=~~(256*i)}return e};var n=e("./jpgHeaderLength"),u=r(n);t.exports=a["default"]},{"./jpgHeaderLength":8}],7:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e,t,a){if((0,u["default"])(e)){var r=(0,i["default"])(t),n=(0,s["default"])(r,a.seed,a.amount,a.iterations),o=(0,l["default"])(n);return o}throw new Error("glitchImageData: imageData seems to be corrupt.")};var n=e("../util/isImageData"),u=r(n),o=e("./base64ToByteArray"),i=r(o),f=e("./glitchByteArray"),s=r(f),d=e("./byteArrayToBase64"),l=r(d);t.exports=a["default"]},{"../util/isImageData":18,"./base64ToByteArray":3,"./byteArrayToBase64":5,"./glitchByteArray":6}],8:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){for(var t=417,a=0,r=e.length;r>a;a++)if(255===e[a]&&218===e[a+1]){t=a+2;break}return t},t.exports=a["default"]},{}],9:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){if(e instanceof HTMLImageElement){if(!e.naturalWidth||!e.naturalHeight||e.complete===!1)throw new Error("This this image hasn't finished loading: "+e.src);var t=new u["default"](e.naturalWidth,e.naturalHeight),a=t.getContext("2d");a.drawImage(e,0,0,t.width,t.height);var r=a.getImageData(0,0,t.width,t.height);return r.data&&r.data.length&&("undefined"==typeof r.width&&(r.width=e.naturalWidth),"undefined"==typeof r.height&&(r.height=e.naturalHeight)),r}throw new Error("This object does not seem to be an image.")};var n=e("canvas-browserify"),u=r(n);u["default"].Image;t.exports=a["default"]},{"canvas-browserify":21}],10:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]={amount:35,iterations:20,quality:30,seed:25},t.exports=a["default"]},{}],11:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};a["default"]=function(e){e=(0,f["default"])(e),"object"!==("undefined"==typeof e?"undefined":n(e))&&(e={});var t=Object.keys(d["default"]).filter(function(e){return"iterations"!==e});return t.forEach(function(t){"number"!=typeof e[t]||isNaN(e[t])?e[t]=d["default"][t]:e[t]=(0,o["default"])(e[t],0,100),e[t]=Math.round(e[t])}),("number"!=typeof e.iterations||isNaN(e.iterations)||e.iterations<=0)&&(e.iterations=d["default"].iterations),e.iterations=Math.round(e.iterations),e};var u=e("../util/clamp"),o=r(u),i=e("../util/clone"),f=r(i),s=e("./defaultParams"),d=r(s);t.exports=a["default"]},{"../util/clamp":15,"../util/clone":16,"./defaultParams":10}],12:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e,t,a,r){(0,u["default"])(e).then(a,r)};var n=e("../../util/loadBase64Image"),u=r(n);t.exports=a["default"]},{"../../util/loadBase64Image":19}],13:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e,t,a,r){(0,u["default"])(e).then(function(e){var t=(0,s["default"])(e),r=(0,i["default"])(e).ctx.getImageData(0,0,t.width,t.height);r.width||(r.width=t.width),r.height||(r.height=t.height),a(r)},r)};var n=e("../util/loadBase64Image"),u=r(n),o=e("../util/canvasFromImage"),i=r(o),f=e("../util/getImageSize"),s=r(f);t.exports=a["default"]},{"../util/canvasFromImage":14,"../util/getImageSize":17,"../util/loadBase64Image":19}],14:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){var t=(0,i["default"])(e),a=new u["default"](t.width,t.height),r=a.getContext("2d");return r.drawImage(e,0,0,t.width,t.height),{canvas:a,ctx:r}};var n=e("canvas-browserify"),u=r(n),o=e("./getImageSize"),i=r(o);t.exports=a["default"]},{"./getImageSize":17,"canvas-browserify":21}],15:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e,t,a){return t>e?t:e>a?a:e},t.exports=a["default"]},{}],16:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){var t=!1;if("undefined"!=typeof e)try{t=JSON.parse(JSON.stringify(e))}catch(a){}return t},t.exports=a["default"]},{}],17:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){return{width:e.width||e.naturalWidth,height:e.height||e.naturalHeight}},t.exports=a["default"]},{}],18:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};a["default"]=function(e){return e&&"number"==typeof e.width&&"number"==typeof e.height&&e.data&&"number"==typeof e.data.length&&"object"===r(e.data)},t.exports=a["default"]},{}],19:[function(e,t,a){"use strict";Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=function(e){return new Promise(function(t,a){var n=new r.Image;n.onload=function(){t(n)},n.onerror=function(e){a(e)},n.src=e})};var r=e("canvas-browserify");t.exports=a["default"]},{"canvas-browserify":21}],20:[function(e,t,a){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function n(e){e.addEventListener("message",function(t){var a=t.data.imageData,r=t.data.params,n=t.data.base64URL;if(a&&n&&r)try{"undefined"==typeof a.width&&"number"==typeof t.data.imageDataWidth&&(a.width=t.data.imageDataWidth),"undefined"==typeof a.height&&"number"==typeof t.data.imageDataHeight&&(a.height=t.data.imageDataHeight);var i=(0,f["default"])(a,n,r);o(i)}catch(s){u(s)}else u(t.data.imageData?"Parameters are missing.":"ImageData is missing.");e.close()})}function u(e){self.postMessage({err:e.message||e})}function o(e){self.postMessage({base64URL:e})}Object.defineProperty(a,"__esModule",{value:!0}),a["default"]=n;var i=e("../glitch/glitchImageData"),f=r(i);t.exports=a["default"]},{"../glitch/glitchImageData":7}],21:[function(e,t,a){var r=t.exports=function(e,t){var a=document.createElement("canvas");return a.width=e||300,a.height=t||150,a};r.Image=function(){var e=document.createElement("img");return e}},{}],22:[function(e,t,a){var r=arguments[3],n=arguments[4],u=arguments[5],o=JSON.stringify;t.exports=function(e){for(var t,a=Object.keys(u),i=0,f=a.length;f>i;i++){var s=a[i],d=u[s].exports;if(d===e||d["default"]===e){t=s;break}}if(!t){t=Math.floor(Math.pow(16,8)*Math.random()).toString(16);for(var l={},i=0,f=a.length;f>i;i++){var s=a[i];l[s]=s}n[t]=[Function(["require","module","exports"],"("+e+")(self)"),l]}var c=Math.floor(Math.pow(16,8)*Math.random()).toString(16),g={};g[t]=t,n[c]=[Function(["require"],"var f = require("+o(t)+");(f.default ? f.default : f)(self);"),g];var h="("+r+")({"+Object.keys(n).map(function(e){return o(e)+":["+n[e][0]+","+o(n[e][1])+"]"}).join(",")+"},{},["+o(c)+"])",p=window.URL||window.webkitURL||window.mozURL||window.msURL;return new Worker(p.createObjectURL(new Blob([h],{type:"text/javascript"})))}},{}]},{},[1])(1)});