text: !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.klouds=t():e.klouds=t()}(window,(function(){return function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";t.__esModule=!0,t.create=t.Klouds=t.VERSION=void 0;var o=r(1),n=r(2),i=r(3);function a(e){var t=[0,0,0];return"string"==typeof e?function(e){var t=document.createElement("div");t.style.display="none",t.style.color=e,document.body.appendChild(t);var r=(getComputedStyle(t).color||"rgb(0, 0, 0)").match(/[+-]?\d+(\.\d+)?/g),o=r?r.map((function(e){return parseInt(e,10)})):[0,0,0];if(t.parentElement&&t.parentElement.removeChild(t),o.length>3)o.length=3;else if(o.length<3)return[0,0,0];return o}(e).forEach((function(e,r){t[r]=e/255})):Array.isArray(e)&&3===e.length&&e.slice(0,3).forEach((function(e,r){t[r]=e/255})),t}t.VERSION="2.1.1";var l=function(){function e(e){var t=this;this.isRunning=!1,this.accumTime=0,this.lastTime=performance.now(),this.render=function(e){var r=t.gl,o=t.program,n=t.buffer,a=(e-t.lastTime)*t.speed*.001;t.accumTime+=a,t.lastTime=e,i.resizeCanvasToDisplaySize(t.canvas),r.viewport(0,0,r.canvas.width,r.canvas.height),r.useProgram(o.handle),r.bindBuffer(r.ARRAY_BUFFER,n);var l=o.attributes.position;r.enableVertexAttribArray(l),r.vertexAttribPointer(l,3,r.FLOAT,!1,0,0),r.uniform2f(o.uniforms.resolution,r.canvas.width,r.canvas.height),r.uniform1f(o.uniforms.layerCount,t.layerCount),r.uniform1f(o.uniforms.time,t.accumTime),r.uniform3fv(o.uniforms.bgColor,t.bgColor),r.uniform3fv(o.uniforms.cloudColor1,t.cloudColor1),r.uniform3fv(o.uniforms.cloudColor2,t.cloudColor2),r.drawArrays(r.TRIANGLES,0,6),t.isRunning&&requestAnimationFrame(t.render)};var r=this.queryRootElement(e.selector);if(!r)throw new Error("Invalid options.selector value passed to Klouds");this.canvas=r;var o=e.speed||1,n=e.layerCount||5,a=e.cloudColor1||[25,178,204],l=e.cloudColor2||[255,255,255],u=e.bgColor||[0,102,128];r.style.width="100%",r.style.height="100%",this.initGraphics(r),this.setSpeed(o),this.setLayerCount(n),this.setBgColor(u),this.setCloudColor1(a),this.setCloudColor2(l),this.start()}return e.prototype.queryRootElement=function(e){if("string"==typeof e){var t=document.querySelector(e);return t?t instanceof HTMLCanvasElement?t:(console.error("options.selector element is not a <canvas> element"),null):(console.error("options.selector element not found"),null)}return e instanceof HTMLElement?e instanceof HTMLCanvasElement?e:(console.error("options.selector element is not a <canvas> element"),null):(console.error("options.selector value is invalid"),null)},e.prototype.initGraphics=function(e){var t=i.createContext(e);if(!t)throw new Error("Failed to create WebGL context");var r=i.createProgram(t,o.default,n.default,["position"],["resolution","layerCount","time","bgColor","cloudColor1","cloudColor2"]);if(!r)throw new Error("Failed to create WebGL program");var a=t.createBuffer();if(!a)throw t.deleteProgram(r),new Error("Failed to create WebGL buffer");var l=r.attributes.position;t.enableVertexAttribArray(l),t.vertexAttribPointer(l,3,t.FLOAT,!1,0,0);t.bindBuffer(t.ARRAY_BUFFER,a),t.bufferData(t.ARRAY_BUFFER,new Float32Array([[-1,-1,0],[1,-1,0],[-1,1,0],[-1,1,0],[1,-1,0],[1,1,0]].reduce((function(e,t){return e.concat(t)}),[])),t.STATIC_DRAW),this.gl=t,this.program=r,this.buffer=a},e.prototype.start=function(){this.isRunning||(this.isRunning=!0,requestAnimationFrame(this.render))},e.prototype.stop=function(){this.isRunning=!1},e.prototype.setSpeed=function(e){this.speed=Math.max(-100,Math.min(100,e))},e.prototype.setCloudColor1=function(e){var t=a(e);t&&(this.cloudColor1=t)},e.prototype.setCloudColor2=function(e){var t=a(e);t&&(this.cloudColor2=t)},e.prototype.setBgColor=function(e){var t=a(e);t&&(this.bgColor=t)},e.prototype.setLayerCount=function(e){this.layerCount=Math.max(1,Math.min(8,e))/10},e.prototype.getSpeed=function(){return this.speed},e.prototype.getLayerCount=function(){return this.layerCount},e.prototype.getBgColor=function(){return this.bgColor.slice()},e.prototype.getCloudColor1=function(){return this.cloudColor1.slice()},e.prototype.getCloudColor2=function(){return this.cloudColor2.slice()},e}();t.Klouds=l,t.create=function(e){return new l(e)},window&&void 0!==window.jQuery&&(window.jQuery.fn.Klouds=function(e){e=e||{};for(var t=this.get(),r=[],o=0;o<t.length;++o)e.selector=t[o],r.push(new l(e));return r})},function(e,t,r){"use strict";r.r(t),t.default="attribute vec3 position;\n\nvoid main() {\n    gl_Position = vec4(position, 1.0);\n}\n"},function(e,t,r){"use strict";r.r(t),t.default="precision mediump float;\n\nuniform vec2 resolution;\nuniform float layerCount;\nuniform float time;\nuniform vec3 bgColor;\nuniform vec3 cloudColor1;\nuniform vec3 cloudColor2;\n\n#define TAU 6.28318530718\n\nfloat func(float pX) {\n    return 0.6 * (0.5 * sin(0.1 * pX) + 0.5 * sin(0.553 * pX) + 0.7 * sin(1.2 * pX));\n}\n\nfloat funcR(float pX) {\n    return 0.5 + 0.25 * (1.0 + sin(mod(40.0 * pX, TAU)));\n}\n\nfloat layer(vec2 pQ, float pT) {\n    vec2 Qt = 3.5 * pQ;\n    pT *= 0.5;\n    Qt.x += pT;\n\n    float Xi = floor(Qt.x);\n    float Xf = Qt.x - Xi - 0.5;\n\n    vec2 C;\n    float Yi;\n    float D = 1.0 - step(Qt.y,  func(Qt.x));\n\n    Yi = func(Xi + 0.5);\n    C = vec2(Xf, Qt.y - Yi ); \n    D =  min(D, length(C) - funcR(Xi + pT / 80.0));\n\n    Yi = func(Xi + 1.0 + 0.5);\n    C = vec2(Xf - 1.0, Qt.y - Yi ); \n    D =  min(D, length(C) - funcR(Xi + 1.0+ pT / 80.0));\n\n    Yi = func(Xi - 1.0 + 0.5);\n    C = vec2(Xf + 1.0, Qt.y - Yi ); \n    D =  min(D, length(C) - funcR(Xi - 1.0 + pT / 80.0));\n\n    return min(1.0, D);\n}\n\nvoid main() {\n    float t = time;\n    vec2 UV = 2.0 * (gl_FragCoord.xy - resolution.xy / 2.0) / min(resolution.x, resolution.y);\t\n    \n    vec3 Color = bgColor;\n\n    for(float i = 0.0; i < 0.8; i += 0.1) {\n        if (i >= layerCount) {\n            break;\n        }\n\n        float Lt =  t * (0.5 + 2.0 * i) * (1.0 + 0.1 * sin(226.0 * i)) + 1000.0 * i;\n        vec2 Lp = vec2(100.0 * i, 0.8 * (i / (layerCount - 0.0999) / 0.8) - 0.3);\n        float L = layer(UV + Lp, Lt);\n\n        float Blur = 4.0 * (0.5 * abs(2.0 - 5.0 * i)) / (11.0 - 5.0 * i);\n\n        float V = mix(0.0, 1.0, 1.0 - smoothstep(0.0, 0.01 + 0.2 * Blur, L));\n        vec3 Lc = mix(cloudColor1, cloudColor2, i / (layerCount - 0.0999) / 0.8);\n\n        Color = mix(Color, Lc,  V);\n    }\n\n    gl_FragColor = vec4(Color, 1.0);\n}\n"},function(e,t,r){"use strict";var o;function n(e,t,r){var n=t===o.VERTEX?e.createShader(e.VERTEX_SHADER):e.createShader(e.FRAGMENT_SHADER);return n?(e.shaderSource(n,r),e.compileShader(n),e.getShaderParameter(n,e.COMPILE_STATUS)?n:(console.debug(e.getShaderInfoLog(n)),console.error("Failed to compile WebGL shader"),e.deleteShader(n),null)):(console.error("Failed to create WebGL shader"),null)}t.__esModule=!0,t.resizeCanvasToDisplaySize=t.createProgram=t.createShader=t.ShaderType=t.createContext=void 0,t.createContext=function(e){return e.getContext("webgl")},function(e){e[e.VERTEX=0]="VERTEX",e[e.FRAGMENT=1]="FRAGMENT"}(o=t.ShaderType||(t.ShaderType={})),t.createShader=n,t.createProgram=function(e,t,r,i,a){var l=e.createProgram();if(!l)return console.error("Failed to create WebGL program"),null;var u=n(e,o.VERTEX,t),s=n(e,o.FRAGMENT,r);if(!u||!s)return console.error("Failed to create a shader while creating a program"),null;if(e.attachShader(l,u),e.attachShader(l,s),e.linkProgram(l),e.validateProgram(l),!e.getProgramParameter(l,e.LINK_STATUS))return e.deleteProgram(l),e.deleteShader(u),e.deleteShader(s),console.error("Failed to link WebGL program"),console.debug(e.getProgramInfoLog(l)),null;if(!e.getProgramParameter(l,e.VALIDATE_STATUS))return e.deleteProgram(l),e.deleteShader(u),e.deleteShader(s),console.error("Failed to validate WebGL program"),console.debug(e.getProgramInfoLog(l)),null;for(var c={},f=0;f<i.length;++f){var d=i[f],p=e.getAttribLocation(l,d);if(-1===p)return console.error('Program attribute named "'+d+"\" doesn't exist"),e.deleteProgram(l),null;c[d]=p}var m={};for(f=0;f<a.length;++f){var h=a[f],g=e.getUniformLocation(l,h);if(null===g)return console.error('Program uniform named "'+h+"\" doesn't exist"),e.deleteProgram(l),null;m[h]=g}return{handle:l,attributes:c,uniforms:m}},t.resizeCanvasToDisplaySize=function(e){var t=e.clientWidth,r=e.clientHeight;return(e.width!==t||e.height!==r)&&(e.width=t,e.height=r,!0)}}])}));
  //# sourceMappingURL=klouds.min.js.map