UNPKG

tumult

Version:
42 lines 27.4 kB
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"g31k":[function(require,module,exports) { try{var t=new ImageData(20,20),o=Math.trunc(20.1)}catch(n){var e="Error, browser not supported by Terrapaint. ";e+="Please switch to Vivaldi, Firefox, Chrome, Opera, or Safari.",console.log(e)}function i(){function t(){for(var t=0,o=0,e=this.period,i=Math.pow(this.persistance,this.octaves),n=[],a=0;a<this.octaves;a++){for(var r=0;r<arguments.length;r++)n[r]=arguments[r]/e;t+=(this.noise.apply(this.thisArg,n)+this.offset)*i,o+=i*(this.offset+1),i/=this.persistance,e/=2}return t/o}function o(t){t=t||{},this.octaves=t.octaves||1,this.period=t.period||32,this.offset=t.offset?1:0,this.persistance=t.persistance||2,this.update=t.update||function(){throw"No update fn"},this.loopvalues=t.init||[],this.colormap=t.colormap||function(t){return[t,t,t,255]},this.thisArg=t.thisArg||null}function e(t,e){o.call(this,e),this.noise=t}function i(t,e){o.call(this,e),this.noise=t}return e.prototype.compute=function(o,e){for(var i=new Uint8ClampedArray(o*e*4),n=0;n<e;n++)for(var a=0;a<o;a++){0!==this.loopvalues.length&&(this.loopvalues=this.update(this.loopvalues));var r,s=[a,n].concat(this.loopvalues),p=Math.trunc(255*t.apply(this,s));r="function"==typeof this.colormap?this.colormap(p):this.colormap[p],i.set(r,4*a+4*n*o)}return new ImageData(i,o,e)},e.prototype.draw=function(t){(t="string"==typeof t?document.querySelector(t):t).getContext("2d").putImageData(this.compute(t.width,t.height),0,0),this.canvas=t},e.prototype.create=function(t,o,e){var i=document.createElement("canvas"),n=i.getContext("2d");t="string"==typeof t?document.querySelector(t):t,i.width=o,i.height=e,n.putImageData(this.compute(o,e),0,0),t.appendChild(i),this.canvas=i},e.prototype.loop=function(){var t=this,o=function(){t.draw(t.canvas),this.animReq=requestAnimationFrame(o)};this.animReq=requestAnimationFrame(o)},e.prototype.stop=function(){cancelAnimationFrame(this.animReq)},i.prototype.compute=function(o,e){for(var i=new Uint8ClampedArray(o*e*4).fill(255),n=0;n<o;n++){0!==this.loopvalues.length&&(this.loopvalues=this.update(this.loopvalues));for(var a=[n].concat(this.loopvalues),r=Math.trunc(255*t.apply(this,a)),s=0;s<3;s++)i[r*o*4+4*n+s]=0}return new ImageData(i,o,e)},i.prototype.draw=function(t){e.prototype.draw.call(this,t)},i.prototype.create=function(t,o,i){e.prototype.create.call(this,t,o,i)},i.prototype.loop=function(){e.prototype.loop.call(this)},i.prototype.stop=function(){e.prototype.stop.call(this)},{map:function(t,o){return new e(t,o)},curve:function(t,o){return new i(t,o)},THREE2:function(){return new THREE2},THREE3:function(){return new THREE3}}}module.exports=i(); },{}],"LFj2":[function(require,module,exports) { function i(i,n,r,t){return JSON.stringify(i,e(n,t),r)}function e(i,e){var n=[],r=[];return null==e&&(e=function(i,e){return n[0]===e?"[Circular ~]":"[Circular ~."+r.slice(0,n.indexOf(e)).join(".")+"]"}),function(t,l){if(n.length>0){var u=n.indexOf(this);~u?n.splice(u+1):n.push(this),~u?r.splice(u,1/0,t):r.push(t),~n.indexOf(l)&&(l=e.call(this,t,l))}else n.push(l);return null==i?l:i.call(this,t,l)}}exports=module.exports=i,exports.getSerialize=e; },{}],"f53L":[function(require,module,exports) { "use strict";var n=require("json-stringify-safe"),r=function(){var n=4022871197;return function(r){if(r){r=r.toString();for(var t=0;t<r.length;t++){var e=.02519603282416938*(n+=r.charCodeAt(t));e-=n=e>>>0,n=(e*=n)>>>0,n+=4294967296*(e-=n)}return 2.3283064365386963e-10*(n>>>0)}n=4022871197}},t=function(t){return function(){var e,o,i=48,u=1,a=i,f=new Array(i),c=0,l=new r;for(e=0;e<i;e++)f[e]=l(Math.random());var g=function(){++a>=i&&(a=0);var n=1768863*f[a]+2.3283064365386963e-10*u;return f[a]=n-(u=0|n)},h=function(n){return Math.floor(n*(g()+1.1102230246251565e-16*(2097152*g()|0)))};h.string=function(n){var r,t="";for(r=0;r<n;r++)t+=String.fromCharCode(33+h(94));return t};return h.cleanString=function(n){return n=(n=(n=n.replace(/(^\s*)|(\s*$)/gi,"")).replace(/[\x00-\x1F]/gi,"")).replace(/\n /,"\n")},h.hashString=function(n){for(n=h.cleanString(n),l(n),e=0;e<n.length;e++)for(c=n.charCodeAt(e),o=0;o<i;o++)f[o]-=l(c),f[o]<0&&(f[o]+=1)},h.seed=function(r){null==r&&(r=Math.random()),"string"!=typeof r&&(r=n(r,function(n,r){return"function"==typeof r?r.toString():r})),h.initState(),h.hashString(r)},h.addEntropy=function(){var n=[];for(e=0;e<arguments.length;e++)n.push(arguments[e]);!function(){var n=Array.prototype.slice.call(arguments);for(e=0;e<n.length;e++)for(o=0;o<i;o++)f[o]-=l(n[e]),f[o]<0&&(f[o]+=1)}(c+++(new Date).getTime()+n.join("")+Math.random())},h.initState=function(){for(l(),e=0;e<i;e++)f[e]=l(" ");u=1,a=i},h.done=function(){l=null},void 0!==t&&h.seed(t),h.range=function(n){return h(n)},h.random=function(){return h(Number.MAX_VALUE-1)/Number.MAX_VALUE},h.floatBetween=function(n,r){return h.random()*(r-n)+n},h.intBetween=function(n,r){return Math.floor(h.random()*(r-n+1))+n},h}()};t.create=function(n){return new t(n)},module.exports=t; },{"json-stringify-safe":"LFj2"}],"G4fX":[function(require,module,exports) { "use strict";function r(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function e(r,e){for(var n=0;n<e.length;n++){var t=e[n];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(r,t.key,t)}}function n(r,n,t){return n&&e(r.prototype,n),t&&e(r,t),r}var t=require("random-seed"),a=function(){function e(n){r(this,e),this.p=new Uint8Array(512),this.seed(n)}return n(e,[{key:"gen",value:function(){}},{key:"seed",value:function(r){for(var e=t.create(r||Math.random()),n=0;n<256;n++)this.p[n]=n;for(var a=0;a<256;a++){var i=e(256),o=this.p[a];this.p[a]=this.p[i],this.p[i]=o}for(var u=0;u<256;u++)this.p[u+256]=this.p[u]}},{key:"transform",value:function(r){var e=this;return function(){for(var n=arguments.length,t=new Array(n),a=0;a<n;a++)t[a]=arguments[a];return r.apply(e,t)}.bind(this)}},{key:"octavate",value:function(){for(var r=this,e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];for(var a=n[0],i=n.slice(1),o=0,u=0,f=function(e){var n=1<<e;o+=r.gen.apply(r,i.map(function(r){return r*n}))/n},s=0;s<a;s++)f(s);for(s=0;s<a;s++)u+=1/(1<<s);return o/u}}]),e}();module.exports=a; },{"random-seed":"f53L"}],"rNDH":[function(require,module,exports) { "use strict";function n(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function e(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function t(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}var r=function(){function e(t){n(this,e),this.x=t}return t(e,[{key:"dot",value:function(n){return this.x*n}}]),e}(),o=[new r(1),new r(-1)];function u(n,e){return o[n[e]%o.length]}module.exports={grad1:u}; },{}],"Ql3W":[function(require,module,exports) { "use strict";function n(){for(var n=arguments.length,r=new Array(n),u=0;u<n;u++)r[u]=arguments[u];var e=r.slice(1),t=r[0]-e.reduce(function(n,r){return n+r*r},0);return t*t*t*t}function r(n,r,u){return n*(1-u)+r*u}function u(n){return n*n*n*(10+n*(6*n-15))}var e=n.bind(null,1),t=n.bind(null,.5);module.exports={lerp:r,fade:u,cut1:e,cut:t}; },{}],"zb74":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function o(t,e,o){return e&&n(t.prototype,e),o&&n(t,o),t}function r(e,n){return!n||"object"!==t(n)&&"function"!=typeof n?u(e):n}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=require("../util/noise"),p=require("../util/1d"),a=p.grad1,y=require("../util/math"),s=y.cut1,b=function(t){function n(){return e(this,n),r(this,i(n).apply(this,arguments))}return c(n,l),o(n,[{key:"gen",value:function(t){var e=Math.floor(t)%256,n=t-e;return.5*(s(n)*a(this.p,e).dot(n)+s(n-1)*a(this.p,e+1).dot(n-1))}}]),n}();module.exports=b; },{"../util/noise":"G4fX","../util/1d":"rNDH","../util/math":"Ql3W"}],"knQx":[function(require,module,exports) { "use strict";function n(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function e(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function t(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}var r=function(){function e(t,r){n(this,e),this.x=t,this.y=r}return t(e,[{key:"dot",value:function(n,e){return this.x*n+this.y*e}}]),e}(),a=[new r(1,0),new r(1,1),new r(0,1),new r(-1,1),new r(-1,0),new r(-1,-1),new r(0,-1),new r(1,-1)];function i(n,e,t){var r=n[e+n[t]]%a.length;return a[r]}var o=.5*(Math.sqrt(3)-1),u=(3-Math.sqrt(3))/6;module.exports={grad2:i,S2_TO_C:o,C_TO_S2:u}; },{}],"+tDv":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function o(e,n){return!n||"object"!==t(n)&&"function"!=typeof n?u(e):n}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var p=require("../util/noise"),a=require("../util/2d"),l=a.grad2,s=a.S2_TO_C,y=a.C_TO_S2,b=require("../util/math"),h=b.cut,m=function(t){function n(){return e(this,n),o(this,i(n).apply(this,arguments))}return c(n,p),r(n,[{key:"gen",value:function(t,e){var n=(t+e)*s,r=Math.trunc(t+n),o=Math.trunc(e+n),u=(r+o)*y,i=t-(r-u),c=e-(o-u),f=i>c?1:0,p=i>c?0:1,a=i-f+y,b=c-p+y,m=i-1+2*y,O=c-1+2*y;return 70*(h(i,c)*l(this.p,r,o).dot(i,c)+h(a,b)*l(this.p,r+f,o+p).dot(a,b)+h(m,O)*l(this.p,r+1,o+1).dot(m,O))}}]),n}();module.exports=m; },{"../util/noise":"G4fX","../util/2d":"knQx","../util/math":"Ql3W"}],"ddtU":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}function o(e,r){return!r||"object"!==t(r)&&"function"!=typeof r?u(e):r}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function f(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=require("../util/noise"),p=require("../util/1d"),a=p.grad1,y=require("../util/math"),s=y.lerp,b=y.fade,h=function(t){function r(){return e(this,r),o(this,i(r).apply(this,arguments))}return f(r,l),n(r,[{key:"gen",value:function(t){var e=Math.floor(t)%256,r=t-e,n=a(this.p,e).dot(r),o=a(this.p,e+1).dot(r-1);return s(n,o,b(r))}}]),r}();module.exports=h; },{"../util/noise":"G4fX","../util/1d":"rNDH","../util/math":"Ql3W"}],"g1d2":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function o(e,n){return!n||"object"!==t(n)&&"function"!=typeof n?u(e):n}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var p=require("../util/noise"),a=require("../util/2d"),l=a.grad2,s=require("../util/math"),y=s.fade,b=s.lerp,h=function(t){function n(){return e(this,n),o(this,i(n).apply(this,arguments))}return c(n,p),r(n,[{key:"gen",value:function(t,e){var n=Math.trunc(t)%256,r=Math.trunc(e)%256,o=t-n,u=e-r,i=l(this.p,n,r).dot(o,u),c=l(this.p,n+1,r).dot(o-1,u),f=l(this.p,n,r+1).dot(o,u-1),p=l(this.p,n+1,r+1).dot(o-1,u-1);return b(b(i,c,y(o)),b(f,p,y(o)),y(u))}}]),n}();module.exports=h; },{"../util/noise":"G4fX","../util/2d":"knQx","../util/math":"Ql3W"}],"GZ3h":[function(require,module,exports) { "use strict";function n(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function e(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}function t(n,t,r){return t&&e(n.prototype,t),r&&e(n,r),n}var r=function(){function e(t,r,i){n(this,e),this.x=t,this.y=r,this.z=i}return t(e,[{key:"dot",value:function(n,e,t){return this.x*n+this.y*e+this.z*t}}]),e}(),i=[new r(1,1,1),new r(-1,1,1),new r(1,-1,1),new r(-1,-1,1),new r(1,1,0),new r(-1,1,0),new r(1,-1,0),new r(-1,-1,0),new r(1,1,-1),new r(-1,1,-1),new r(1,-1,-1),new r(-1,-1,-1)];function o(n,e,t,r){var o=n[e+n[t+n[r]]]%i.length;return i[o]}module.exports={grad3:o}; },{}],"Vk8a":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}function r(e,o){return!o||"object"!==t(o)&&"function"!=typeof o?i(e):o}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var p=require("../util/noise"),a=require("../util/3d"),l=a.grad3,s=require("../util/math"),y=s.fade,b=s.lerp,h=function(t){function o(){return e(this,o),r(this,u(o).apply(this,arguments))}return c(o,p),n(o,[{key:"gen",value:function(t,e,o){var n=Math.trunc(t)%256,r=Math.trunc(e)%256,i=Math.trunc(o)%256,u=t-n,c=e-r,f=o-i,p=l(this.p,n,r,i).dot(u,c,f),a=l(this.p,n+1,r,i).dot(u-1,c,f),s=l(this.p,n,r+1,i).dot(u,c-1,f),h=l(this.p,n+1,r+1,i).dot(u-1,c-1,f),d=l(this.p,n,r,i+1).dot(u,c,f-1),m=l(this.p,n+1,r,i+1).dot(u-1,c,f-1),O=l(this.p,n,r+1,i+1).dot(u,c-1,f-1),v=l(this.p,n+1,r+1,i+1).dot(u-1,c-1,f-1);return b(b(b(p,a,u),b(s,h,u),y(c)),b(b(d,m,u),b(O,v,u),y(c)),y(f))}}]),o}();module.exports=h; },{"../util/noise":"G4fX","../util/3d":"GZ3h","../util/math":"Ql3W"}],"k4MN":[function(require,module,exports) { "use strict";function n(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}function e(n,e){for(var t=0;t<e.length;t++){var w=e[t];w.enumerable=w.enumerable||!1,w.configurable=!0,"value"in w&&(w.writable=!0),Object.defineProperty(n,w.key,w)}}function t(n,t,w){return t&&e(n.prototype,t),w&&e(n,w),n}var w=function(){function e(t,w,r,i){n(this,e),this.x=t,this.y=w,this.z=r,this.t=i}return t(e,[{key:"dot",value:function(n,e,t,w){return this.x*n+this.y*e+this.z*t+this.t*w}}]),e}(),r=[new w(0,1,1,1),new w(0,1,1,-1),new w(0,1,-1,1),new w(0,1,-1,-1),new w(0,-1,1,1),new w(0,-1,1,-1),new w(0,-1,-1,1),new w(0,-1,-1,-1),new w(1,0,1,1),new w(1,0,1,-1),new w(1,0,-1,1),new w(1,0,-1,-1),new w(-1,0,1,1),new w(-1,0,1,-1),new w(-1,0,-1,1),new w(-1,0,-1,-1),new w(1,1,0,1),new w(1,1,0,-1),new w(1,-1,0,1),new w(1,-1,0,-1),new w(-1,1,0,1),new w(-1,1,0,-1),new w(-1,-1,0,1),new w(-1,-1,0,-1),new w(1,1,1,0),new w(1,1,-1,0),new w(1,-1,1,0),new w(1,-1,-1,0),new w(-1,1,1,0),new w(-1,1,-1,0),new w(-1,-1,1,0),new w(-1,-1,-1,0)];function i(n,e,t,w,i){var o=n[e+n[t+n[w+n[i]]]]%r.length;return r[o]}module.exports={grad4:i}; },{}],"x9bC":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function n(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}function r(e,o){return!o||"object"!==t(o)&&"function"!=typeof o?i(e):o}function i(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function p(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var f=require("../util/noise"),s=require("../util/4d"),a=s.grad4,l=require("../util/math"),h=l.fade,y=l.lerp,d=function(t){function o(){return e(this,o),r(this,u(o).apply(this,arguments))}return p(o,f),n(o,[{key:"gen",value:function(t,e,o,n){var r=Math.trunc(t)%256,i=Math.trunc(e)%256,u=Math.trunc(o)%256,p=Math.trunc(n)%256,c=t-r,f=e-i,s=o-u,l=n-p,d=a(this.p,r,i,u,p).dot(c,f,s,l),b=a(this.p,r+1,i,u,p).dot(c-1,f,s),m=a(this.p,r,i+1,u,p).dot(c,f-1,s),O=a(this.p,r+1,i+1,u,p).dot(c-1,f-1,s),v=a(this.p,r,i,u+1,p).dot(c,f,s-1),w=a(this.p,r+1,i,u+1,p).dot(c-1,f,s-1),_=a(this.p,r,i+1,u+1,p).dot(c,f-1,s-1),g=a(this.p,r+1,i+1,u+1,p).dot(c-1,f-1,s-1),j=a(this.p,r,i,u,p+1).dot(c,f,s,l-1),S=a(this.p,r+1,i,u,p+1).dot(c-1,f,s,l-1),P=a(this.p,r,i+1,u,p+1).dot(c,f-1,s,l-1),M=a(this.p,r+1,i+1,u,p+1).dot(c-1,f-1,s,l-1),q=a(this.p,r,i,u+1,p+1).dot(c,f,s-1,l-1),E=a(this.p,r+1,i,u+1,p+1).dot(c-1,f,s-1,l-1),k=a(this.p,r,i+1,u+1,p+1).dot(c,f-1,s-1,l-1),x=a(this.p,r+1,i+1,u+1,p+1).dot(c-1,f-1,s-1,l-1);return y(y(y(y(d,b,c),y(m,O,c),h(f)),y(y(v,w,c),y(_,g,c),h(f)),h(s)),y(y(y(j,S,c),y(P,M,c),h(f)),y(y(q,E,c),y(k,x,c),h(f)),h(s)),h(l))}}]),o}();module.exports=d; },{"../util/noise":"G4fX","../util/4d":"k4MN","../util/math":"Ql3W"}],"ZdOn":[function(require,module,exports) { "use strict";function e(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function n(e,n){for(var r=0;r<n.length;r++){var t=n[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,t.key,t)}}function r(e,r,t){return r&&n(e.prototype,r),t&&n(e,t),e}var t=require("./math"),l=t.lerp,i=t.fade;function o(e,n){return 1===n.length?e[n[0]]:e[n[0]+o(e,n.slice(1))]}var a=function(){function n(r){e(this,n),this.R=r}return r(n,[{key:"dot",value:function(e){for(var n=0,r=0;r<e.length;r++)n+=this.R[r]*e[r];return n}}]),n}(),u=[];function c(e){for(var n=0;n<2*e;n++){var r=new Array(e).fill(0);r[n%e]=n/e>=1?1:-1,u[n]=new a(r)}}function f(e,n){if(1===n.length)return l(e[0],e[1],i(n[0]));var r=e.slice(0,Math.floor(e.length/2)),t=e.slice(Math.ceil(e.length/2));return l(f(r,n.slice(0,n.length-1)),f(t,n.slice(0,n.length-1)),i(n[n.length-1]))}function h(e,n,r,t){var l=[];0===u.length&&c(n);for(var i=0;i<2<<n-1;i++){for(var a=r.slice(),f=t.slice(),h=i,s=0;s<n;s++)1&h&&(a[s]+=1,f[s]-=1),h>>=1;l[i]=u[o(e,a)%u.length].dot(f)}return l}module.exports={lerpN:f,getNs:h}; },{"./math":"Ql3W"}],"lNIx":[function(require,module,exports) { "use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function r(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}function o(e,n){return!n||"object"!==t(n)&&"function"!=typeof n?u(e):n}function u(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&f(t,e)}function f(t,e){return(f=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var l=require("../util/noise"),p=require("../util/nd"),a=p.lerpN,y=p.getNs,s=function(t){function n(){return e(this,n),o(this,i(n).apply(this,arguments))}return c(n,l),r(n,[{key:"gen",value:function(){for(var t=[],e=[],n=0;n<arguments.length;n++)t[n]=Math.trunc(n<0||arguments.length<=n?void 0:arguments[n])%256,e[n]=(n<0||arguments.length<=n?void 0:arguments[n])-t[n];var r=y(this.p,arguments.length,t,e);return a(r,e)}}]),n}();module.exports=s; },{"../util/noise":"G4fX","../util/nd":"ZdOn"}],"VNNP":[function(require,module,exports) { var e=require("./simplex/simplex1"),r=require("./simplex/simplex2"),i=require("./perlin/perlin1"),l=require("./perlin/perlin2"),p=require("./perlin/perlin3"),n=require("./perlin/perlin4"),u=require("./perlin/perlinN");module.exports={Simplex1:e,Simplex2:r,Perlin1:i,Perlin2:l,Perlin3:p,Perlin4:n,PerlinN:u}; },{"./simplex/simplex1":"zb74","./simplex/simplex2":"+tDv","./perlin/perlin1":"ddtU","./perlin/perlin2":"g1d2","./perlin/perlin3":"Vk8a","./perlin/perlin4":"x9bC","./perlin/perlinN":"lNIx"}],"S3PC":[function(require,module,exports) { "use strict";module.exports=require("./lib"); },{"./lib":"VNNP"}],"lgAh":[function(require,module,exports) { "use strict";var e=r(require("terrapaint")),n=r(require("../"));function r(e){return e&&e.__esModule?e:{default:e}}var t=n.default.Simplex2,a=Math.random(),i=new t(a);function o(e){return document.querySelector(e)}e.default.map(i.gen,{offset:!0,period:64,thisArg:i}).draw("#noise-canvas"),o("#gen-noise").addEventListener("click",function(){var n,r=o("#eval-str").value,t="\n var n = this.gen.bind(this)\n var f = this.octavate.bind(this)\n var sin = Math.sin\n var cos = Math.cos\n var pow = Math.pow\n var pi = Math.PI\n var abs = Math.abs\n var e = Math.E\n return ".concat(r,"\n ");try{n=new Function("x","y",t).bind(i)}catch(s){return void alert("\n Something is wrong with the syntax of your function.\n Please ensure all the parentheses are closed and that you're\n using the correct functions and variable names.\n ")}var a=i.transform(function(e,r){try{return n(e,r)}catch(s){throw alert("\n Your function created a run-time error. Please ensure\n the period of the noise function is greater than one\n (ie. divide x and y by a value, like 4 or 16, before\n passing it to n()).\n "),new Error("Runtime error")}});e.default.map(a,{offset:!0,period:1,thisArg:i}).draw("#noise-canvas")}); },{"terrapaint":"g31k","../":"S3PC"}]},{},["lgAh"], null) //# sourceMappingURL=demo.c8d0cba3.js.map