├── .npmignore
├── .gitignore
├── examples
├── 1
│ ├── index.html
│ ├── package.json
│ └── index.js
├── 2
│ ├── index.html
│ ├── package.json
│ ├── index.js
│ └── build.js
├── 3
│ ├── videos
│ │ ├── cut1.mp4
│ │ ├── cut2.mp4
│ │ ├── cut3.mp4
│ │ ├── cut1.webm
│ │ ├── cut2.webm
│ │ └── cut3.webm
│ ├── index.html
│ ├── package.json
│ ├── videos.js
│ ├── qvideo.js
│ └── index.js
└── index.html
├── .jshintrc
├── package.json
├── LICENCE
├── index.js
└── README.md
/.npmignore:
--------------------------------------------------------------------------------
1 | examples/
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | bundle.js
3 | node_modules
4 | components
5 | .tmp.*
6 |
7 |
--------------------------------------------------------------------------------
/examples/3/videos/cut1.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gre/glsl-transition/HEAD/examples/3/videos/cut1.mp4
--------------------------------------------------------------------------------
/examples/3/videos/cut2.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gre/glsl-transition/HEAD/examples/3/videos/cut2.mp4
--------------------------------------------------------------------------------
/examples/3/videos/cut3.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gre/glsl-transition/HEAD/examples/3/videos/cut3.mp4
--------------------------------------------------------------------------------
/examples/3/videos/cut1.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gre/glsl-transition/HEAD/examples/3/videos/cut1.webm
--------------------------------------------------------------------------------
/examples/3/videos/cut2.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gre/glsl-transition/HEAD/examples/3/videos/cut2.webm
--------------------------------------------------------------------------------
/examples/3/videos/cut3.webm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gre/glsl-transition/HEAD/examples/3/videos/cut3.webm
--------------------------------------------------------------------------------
/examples/1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Example 1
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Example 2
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Example 3
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/examples/1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "1",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "budo index.js"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "baboon-image": "^1.0.0",
13 | "gl-now": "^1.4.0",
14 | "gl-texture2d": "^2.0.8",
15 | "lena": "^1.0.0"
16 | },
17 | "devDependencies": {
18 | "budo": "^2.1.4",
19 | "watchify": "^3.1.0"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/examples/2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "2",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "budo index.js"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "gl-texture2d": "^2.0.8",
13 | "glsl-transitions": "^2015.4.6",
14 | "q": "^1.2.0",
15 | "qimage": "^1.3.0",
16 | "raf": "^2.0.4"
17 | },
18 | "devDependencies": {
19 | "budo": "^2.1.4",
20 | "watchify": "^3.1.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/examples/3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "3",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "start": "budo index.js"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "gl-texture2d": "^2.0.8",
13 | "glsl-transitions": "^2015.5.8",
14 | "q": "^1.3.0",
15 | "qajax": "^1.2.0",
16 | "raf": "^2.0.4"
17 | },
18 | "devDependencies": {
19 | "budo": "^2.1.4",
20 | "watchify": "^3.1.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "globals": {
3 | "window": true,
4 | "document": true
5 | },
6 | "indent": 2,
7 | "node": true,
8 | "bitwise": true,
9 | "camelcase": true,
10 | "eqeqeq": true,
11 | "immed": true,
12 | "latedef": true,
13 | "undef": true,
14 | "unused": true,
15 | "trailing": true,
16 | "smarttabs": false,
17 | "forin": false,
18 | "browser": false,
19 | "globalstrict": false,
20 | "esnext": false,
21 | "quotmark": false
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/examples/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
11 |
12 |
13 |
14 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "glsl-transition",
3 | "version": "1.0.1",
4 | "description": "render GLSL Transitions – transition effects performed with WebGL",
5 | "keywords": [
6 | "glsl",
7 | "webgl",
8 | "transition",
9 | "transitions",
10 | "shaders",
11 | "animation"
12 | ],
13 | "homepage": "https://github.com/gre/glsl-transition",
14 | "author": "Gaëtan Renaudeau ",
15 | "contributors": [],
16 | "main": "index.js",
17 | "repository": {
18 | "type": "git",
19 | "url": "https://github.com/gre/glsl-transition.git"
20 | },
21 | "license": "MIT",
22 | "dependencies": {
23 | "gl-shader": "^4.0.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/examples/3/videos.js:
--------------------------------------------------------------------------------
1 | // Handle the examples videos loading
2 |
3 | var Q = require("q");
4 | var Qvideo = require("./qvideo");
5 | var videos;
6 | var v = document.createElement('video');
7 | var canPlayWebm = v.canPlayType && v.canPlayType('video/webm').replace(/no/, '');
8 | var canPlayMp4 = v.canPlayType && v.canPlayType('video/mp4').replace(/no/, '');
9 | if (canPlayMp4 || canPlayWebm) {
10 | videos = Q.all([
11 | "./videos/cut1",
12 | "./videos/cut2",
13 | "./videos/cut3"
14 | ].map(function (url) {
15 | return Qvideo(url+(!canPlayWebm ? ".mp4" : ".webm"), { event: "canplaythrough" });
16 | }));
17 | }
18 | else {
19 | console.error(new Error("Can't play any video format (webm | mp4)."));
20 | }
21 |
22 | module.exports = videos;
23 |
--------------------------------------------------------------------------------
/examples/3/qvideo.js:
--------------------------------------------------------------------------------
1 | var Q = require("q");
2 | var Qajax = require("qajax");
3 |
4 | // Video loading with promise.
5 | // using an ajax request as a workaround to help some browsers...
6 |
7 | function Qvideo (url, options) {
8 |
9 | return Qajax(url, { responseType: "blob" }).then(function (xhr) {
10 | if (typeof options !== "object") options={};
11 | if (!options.event) options.event = "canplaythrough";
12 | var d = Q.defer();
13 | var video;
14 | try {
15 | video = new window.Video();
16 | } catch (e) {
17 | video = document.createElement('video');
18 | }
19 |
20 | video.src = window.URL.createObjectURL(xhr.response);
21 | video.addEventListener(options.event, function onLoadEvent () {
22 | video.removeEventListener(options.event, onLoadEvent);
23 | d.resolve(video);
24 | }, false);
25 | video.onerror = function (e) {
26 | console.error(e&&e.stack||e);
27 | d.reject(new Error("Video "+url+" failed to load: "+e));
28 | };
29 | video.load();
30 | return d.promise;
31 | });
32 | }
33 |
34 | module.exports = Qvideo;
35 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2015 @greweb
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/examples/2/index.js:
--------------------------------------------------------------------------------
1 | var Q = require("q");
2 | var Qimage = require("qimage");
3 | var raf = require("raf");
4 | var GlslTransitions = require("glsl-transitions").sort(function (a, b) {
5 | return b.stars - a.stars;
6 | });
7 | var createTexture = require("gl-texture2d");
8 | var createTransition = require("../..");
9 |
10 | Q.all([
11 | Qimage.anonymously("http://i.imgur.com/N8a9CkZ.jpg"),
12 | Qimage.anonymously("http://i.imgur.com/MQtLWbD.jpg")
13 | ]).spread(function (fromImage, toImage) {
14 | var canvas = document.createElement("canvas");
15 | canvas.style.display = "block";
16 | canvas.width = 600;
17 | canvas.height = 400;
18 | var gl = canvas.getContext("webgl");
19 | if (!gl) throw new Error("webgl context is not supported.");
20 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
21 | var from = createTexture(gl, fromImage);
22 | var to = createTexture(gl, toImage);
23 | var transitionItem, transition;
24 |
25 | raf(function loop (t) {
26 | raf(loop);
27 | if (transition) {
28 | var progress = (t/1500) % 2;
29 | if (progress > 1) progress = 2 - progress; // backwards
30 | transition.render(progress, from, to, transitionItem.uniforms);
31 | }
32 | });
33 |
34 | function setTransition (i) {
35 | transitionItem = GlslTransitions[i];
36 | if (transition) transition.dispose();
37 | transition = createTransition(gl, transitionItem.glsl);
38 | }
39 |
40 | var select = document.createElement("select");
41 | select.style.width = "600px";
42 | GlslTransitions.forEach(function (t) {
43 | var option = document.createElement("option");
44 | option.textContent = t.name;
45 | select.appendChild(option);
46 | });
47 | select.addEventListener("change", function () {
48 | setTransition(select.selectedIndex);
49 | });
50 | setTransition(select.selectedIndex);
51 |
52 | document.body.innerHTML = "";
53 | document.body.appendChild(select);
54 | document.body.appendChild(canvas);
55 | }).done();
56 | document.body.innerHTML = "Loading...";
57 |
--------------------------------------------------------------------------------
/examples/3/index.js:
--------------------------------------------------------------------------------
1 | var raf = require("raf");
2 | var createTexture = require("gl-texture2d");
3 | var createTransition = require("../..");
4 | var GlslTransitions = require("glsl-transitions").sort(function (a, b) {
5 | return b.stars - a.stars;
6 | });
7 | var videos = require("./videos");
8 |
9 | videos.then(function (videos) {
10 |
11 | var canvas = document.createElement("canvas");
12 | canvas.style.display = "block";
13 | canvas.width = 600;
14 | canvas.height = 400;
15 | var gl = canvas.getContext("webgl");
16 | if (!gl) throw new Error("webgl context is not supported.");
17 |
18 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
19 | var from = createTexture(gl, videos[0]);
20 | var to = createTexture(gl, videos[1]);
21 | var transitionItem, transition;
22 |
23 | var duration = 1500;
24 |
25 | videos.forEach(function (video) {
26 | video.loop = true;
27 | video.play();
28 | });
29 |
30 | raf(function loop (t) {
31 | raf(loop);
32 | var i = Math.floor(t / duration) % videos.length;
33 | var j = (i + 1) % videos.length;
34 | from.setPixels(videos[i]);
35 | to.setPixels(videos[j]);
36 | var progress = (t % duration) / duration;
37 | if (transition) transition.render(progress, from, to, transitionItem.uniforms);
38 | });
39 |
40 | function setTransition (i) {
41 | transitionItem = GlslTransitions[i];
42 | if (transition) transition.dispose();
43 | transition = createTransition(gl, transitionItem.glsl);
44 | }
45 |
46 | var select = document.createElement("select");
47 | select.style.width = "600px";
48 | GlslTransitions.forEach(function (t) {
49 | var option = document.createElement("option");
50 | option.textContent = t.name;
51 | select.appendChild(option);
52 | });
53 | select.addEventListener("change", function () {
54 | setTransition(select.selectedIndex);
55 | });
56 | setTransition(select.selectedIndex);
57 |
58 | document.body.innerHTML = "";
59 | document.body.appendChild(select);
60 | document.body.appendChild(canvas);
61 | }).done();
62 | document.body.innerHTML = "Loading...";
63 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var createShader = require("gl-shader");
2 |
3 | var vertexShader = 'attribute vec2 position; void main() { gl_Position = vec4(2.0*position-1.0, 0.0, 1.0);}';
4 |
5 | function GlslTransition (gl, fragmentShader) {
6 | if (!(this instanceof GlslTransition)) return new GlslTransition(gl, fragmentShader);
7 | this.gl = gl;
8 | this.shader = createShader(gl, vertexShader, fragmentShader);
9 | this.buffer = gl.createBuffer();
10 | }
11 |
12 | module.exports = GlslTransition;
13 |
14 | GlslTransition.prototype = {
15 | dispose: function () {
16 | this.shader.dispose();
17 | this.gl.deleteBuffer(this.buffer);
18 | this.shader = null;
19 | this.buffer = null;
20 | },
21 |
22 | render: function (progress, from, to, extraUniforms) {
23 | var gl = this.gl;
24 | var shader = this.shader;
25 | var unit = 0;
26 | shader.bind();
27 | this._checkViewport();
28 | shader.uniforms.progress = progress;
29 | shader.uniforms.from = from.bind(unit++);
30 | shader.uniforms.to = to.bind(unit++);
31 | for (var key in extraUniforms) {
32 | var value = extraUniforms[key];
33 | if (value && value.bind) {
34 | shader.uniforms[key] = value.bind(unit++);
35 | }
36 | else if (shader.uniforms[key] !== value) {
37 | shader.uniforms[key] = value;
38 | }
39 | }
40 | gl.drawArrays(gl.TRIANGLES, 0, 6);
41 | },
42 |
43 | _checkViewport: function () {
44 | var gl = this.gl;
45 | var canvas = gl.canvas;
46 | var w = canvas.width, h = canvas.height;
47 | if (this._w!==w || this._h!==h) {
48 | this._syncViewport(w, h);
49 | this._w = w;
50 | this._h = h;
51 | }
52 | },
53 |
54 | _syncViewport: function (w, h) {
55 | var gl = this.gl;
56 | var shader = this.shader;
57 | var buffer = this.buffer;
58 | var x1 = 0, x2 = w, y1 = 0, y2 = h;
59 | shader.uniforms.resolution = new Float32Array([ w, h ]);
60 | gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
61 | shader.attributes.position.pointer();
62 | gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
63 | x1, y1,
64 | x2, y1,
65 | x1, y2,
66 | x1, y2,
67 | x2, y1,
68 | x2, y2
69 | ]), gl.STATIC_DRAW);
70 | gl.viewport(x1, y1, x2, y2);
71 | }
72 | };
73 |
--------------------------------------------------------------------------------
/examples/1/index.js:
--------------------------------------------------------------------------------
1 | var baboon = require("baboon-image");
2 | var lena = require("lena");
3 | var createTexture = require("gl-texture2d");
4 | var createTransition = require("../..");
5 | var CubeTransition = { // from "glsl-transitions"
6 | "glsl" : "#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from, to;\nuniform float progress;\nuniform vec2 resolution;\n\nuniform float persp;\nuniform float unzoom;\nuniform float reflection;\nuniform float floating;\n\nvec2 project (vec2 p) {\n return p * vec2(1.0, -1.2) + vec2(0.0, -floating/100.);\n}\n\nbool inBounds (vec2 p) {\n return all(lessThan(vec2(0.0), p)) && all(lessThan(p, vec2(1.0)));\n}\n\nvec4 bgColor (vec2 p, vec2 pfr, vec2 pto) {\n vec4 c = vec4(0.0, 0.0, 0.0, 1.0);\n pfr = project(pfr);\n if (inBounds(pfr)) {\n c += mix(vec4(0.0), texture2D(from, pfr), reflection * mix(1.0, 0.0, pfr.y));\n }\n pto = project(pto);\n if (inBounds(pto)) {\n c += mix(vec4(0.0), texture2D(to, pto), reflection * mix(1.0, 0.0, pto.y));\n }\n return c;\n}\n\n// p : the position\n// persp : the perspective in [ 0, 1 ]\n// center : the xcenter in [0, 1] \\ 0.5 excluded\nvec2 xskew (vec2 p, float persp, float center) {\n float x = mix(p.x, 1.0-p.x, center);\n return (\n (\n vec2( x, (p.y - 0.5*(1.0-persp) * x) / (1.0+(persp-1.0)*x) )\n - vec2(0.5-distance(center, 0.5), 0.0)\n )\n * vec2(0.5 / distance(center, 0.5) * (center<0.5 ? 1.0 : -1.0), 1.0)\n + vec2(center<0.5 ? 0.0 : 1.0, 0.0)\n );\n}\n\nvoid main() {\n vec2 op = gl_FragCoord.xy / resolution.xy;\n float uz = unzoom * 2.0*(0.5-distance(0.5, progress));\n vec2 p = -uz*0.5+(1.0+uz) * op;\n vec2 fromP = xskew(\n (p - vec2(progress, 0.0)) / vec2(1.0-progress, 1.0),\n 1.0-mix(progress, 0.0, persp),\n 0.0\n );\n vec2 toP = xskew(\n p / vec2(progress, 1.0),\n mix(pow(progress, 2.0), 1.0, persp),\n 1.0\n );\n if (inBounds(fromP)) {\n gl_FragColor = texture2D(from, fromP);\n }\n else if (inBounds(toP)) {\n gl_FragColor = texture2D(to, toP);\n }\n else {\n gl_FragColor = bgColor(op, fromP, toP);\n }\n}",
7 | "uniforms": { "persp": 0.7, "unzoom": 0.3, "reflection": 0.4, "floating": 3.0 }
8 | };
9 |
10 | var transition, from, to;
11 | var shell = require("gl-now")();
12 | shell.on("gl-init", function() {
13 | var gl = shell.gl;
14 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
15 | transition = createTransition(gl, CubeTransition.glsl);
16 | to = createTexture(gl, baboon.transpose(1, 0));
17 | from = createTexture(gl, lena.transpose(1, 0));
18 | });
19 |
20 | shell.on("gl-render", function () {
21 | transition.render((Date.now() / 1000) % 1, from, to, CubeTransition.uniforms);
22 | });
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # glsl-transition
2 | render GLSL Transitions – transition effects performed with WebGL.
3 |
4 | - [see also: GLSL.io](http://glsl.io/)
5 |
6 | [](http://npmjs.org/package/glsl-transition)
7 |
8 | # GLSL Transition ?
9 |
10 | A GLSL Transition is a fragment shader that MUST have 4 uniforms:
11 | ```glsl
12 | uniform sampler2D from, to;
13 | uniform float progress;
14 | uniform vec2 resolution;
15 | ```
16 |
17 | A GLSL Transition draws a transition between `from` and `to` textures
18 | when `progress` moves between **0.0** and **1.0**.
19 |
20 | A GLSL Transition is allowed *(and encouraged)* to have extra uniforms.
21 |
22 | # [Example 1](http://gre.github.io/glsl-transition/examples/1/)
23 |
24 | ```javascript
25 | var baboon = require("baboon-image");
26 | var lena = require("lena");
27 | var createTexture = require("gl-texture2d");
28 | var createTransition = require("glsl-transition");
29 | var CubeTransition = { // from "glsl-transitions"
30 | "glsl" : "#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from, to;\nuniform float progress;\nuniform vec2 resolution;\n\nuniform float persp;\nuniform float unzoom;\nuniform float reflection;\nuniform float floating;\n\nvec2 project (vec2 p) {\n return p * vec2(1.0, -1.2) + vec2(0.0, -floating/100.);\n}\n\nbool inBounds (vec2 p) {\n return all(lessThan(vec2(0.0), p)) && all(lessThan(p, vec2(1.0)));\n}\n\nvec4 bgColor (vec2 p, vec2 pfr, vec2 pto) {\n vec4 c = vec4(0.0, 0.0, 0.0, 1.0);\n pfr = project(pfr);\n if (inBounds(pfr)) {\n c += mix(vec4(0.0), texture2D(from, pfr), reflection * mix(1.0, 0.0, pfr.y));\n }\n pto = project(pto);\n if (inBounds(pto)) {\n c += mix(vec4(0.0), texture2D(to, pto), reflection * mix(1.0, 0.0, pto.y));\n }\n return c;\n}\n\n// p : the position\n// persp : the perspective in [ 0, 1 ]\n// center : the xcenter in [0, 1] \\ 0.5 excluded\nvec2 xskew (vec2 p, float persp, float center) {\n float x = mix(p.x, 1.0-p.x, center);\n return (\n (\n vec2( x, (p.y - 0.5*(1.0-persp) * x) / (1.0+(persp-1.0)*x) )\n - vec2(0.5-distance(center, 0.5), 0.0)\n )\n * vec2(0.5 / distance(center, 0.5) * (center<0.5 ? 1.0 : -1.0), 1.0)\n + vec2(center<0.5 ? 0.0 : 1.0, 0.0)\n );\n}\n\nvoid main() {\n vec2 op = gl_FragCoord.xy / resolution.xy;\n float uz = unzoom * 2.0*(0.5-distance(0.5, progress));\n vec2 p = -uz*0.5+(1.0+uz) * op;\n vec2 fromP = xskew(\n (p - vec2(progress, 0.0)) / vec2(1.0-progress, 1.0),\n 1.0-mix(progress, 0.0, persp),\n 0.0\n );\n vec2 toP = xskew(\n p / vec2(progress, 1.0),\n mix(pow(progress, 2.0), 1.0, persp),\n 1.0\n );\n if (inBounds(fromP)) {\n gl_FragColor = texture2D(from, fromP);\n }\n else if (inBounds(toP)) {\n gl_FragColor = texture2D(to, toP);\n }\n else {\n gl_FragColor = bgColor(op, fromP, toP);\n }\n}",
31 | "uniforms": { "persp": 0.7, "unzoom": 0.3, "reflection": 0.4, "floating": 3.0 }
32 | };
33 |
34 | var transition, from, to;
35 | var shell = require("gl-now")();
36 | shell.on("gl-init", function() {
37 | var gl = shell.gl;
38 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
39 | transition = createTransition(gl, CubeTransition.glsl);
40 | to = createTexture(gl, baboon.transpose(1, 0));
41 | from = createTexture(gl, lena.transpose(1, 0));
42 | });
43 |
44 | shell.on("gl-render", function () {
45 | transition.render((Date.now() / 1000) % 1, from, to, CubeTransition.uniforms);
46 | });
47 | ```
48 |
49 | [](http://gre.github.io/glsl-transition/examples/1/)
50 |
51 |
52 | # [Example 2](http://gre.github.io/glsl-transition/examples/2/)
53 |
54 | ```javascript
55 | var Q = require("q");
56 | var Qimage = require("qimage");
57 | var raf = require("raf");
58 | var GlslTransitions = require("glsl-transitions").sort(function (a, b) {
59 | return b.stars - a.stars;
60 | });
61 | var createTexture = require("gl-texture2d");
62 | var createTransition = require("glsl-transition");
63 |
64 | Q.all([
65 | Qimage.anonymously("http://i.imgur.com/N8a9CkZ.jpg"),
66 | Qimage.anonymously("http://i.imgur.com/MQtLWbD.jpg")
67 | ]).spread(function (fromImage, toImage) {
68 | var canvas = document.createElement("canvas");
69 | canvas.style.display = "block";
70 | canvas.width = 600;
71 | canvas.height = 400;
72 | var gl = canvas.getContext("webgl");
73 | if (!gl) throw new Error("webgl context is not supported.");
74 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
75 | var from = createTexture(gl, fromImage);
76 | var to = createTexture(gl, toImage);
77 | var transitionItem, transition;
78 |
79 | raf(function loop (t) {
80 | raf(loop);
81 | if (transition) {
82 | var progress = (t/1500) % 2;
83 | if (progress > 1) progress = 2 - progress; // backwards
84 | transition.render(progress, from, to, transitionItem.uniforms);
85 | }
86 | });
87 |
88 | function setTransition (i) {
89 | transitionItem = GlslTransitions[i];
90 | if (transition) transition.dispose();
91 | transition = createTransition(gl, transitionItem.glsl);
92 | }
93 |
94 | var select = document.createElement("select");
95 | select.style.width = "600px";
96 | GlslTransitions.forEach(function (t) {
97 | var option = document.createElement("option");
98 | option.textContent = t.name;
99 | select.appendChild(option);
100 | });
101 | select.addEventListener("change", function () {
102 | setTransition(select.selectedIndex);
103 | });
104 | setTransition(select.selectedIndex);
105 |
106 | document.body.innerHTML = "";
107 | document.body.appendChild(select);
108 | document.body.appendChild(canvas);
109 | }).done();
110 | document.body.innerHTML = "Loading...";
111 | ```
112 |
113 | [](http://gre.github.io/glsl-transition/examples/2/)
114 |
115 | # [Example 3](http://gre.github.io/glsl-transition/examples/3/)
116 |
117 | **GLSL Transitions performed between Videos**
118 |
119 | ```javascript
120 | var raf = require("raf");
121 | var createTexture = require("gl-texture2d");
122 | var createTransition = require("../..");
123 | var GlslTransitions = require("glsl-transitions").sort(function (a, b) {
124 | return b.stars - a.stars;
125 | });
126 | var videos = require("./videos");
127 |
128 | videos.then(function (videos) {
129 |
130 | var canvas = document.createElement("canvas");
131 | canvas.style.display = "block";
132 | canvas.width = 600;
133 | canvas.height = 400;
134 | var gl = canvas.getContext("webgl");
135 | if (!gl) throw new Error("webgl context is not supported.");
136 |
137 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
138 | var from = createTexture(gl, videos[0]);
139 | var to = createTexture(gl, videos[1]);
140 | var transitionItem, transition;
141 |
142 | var duration = 1500;
143 |
144 | videos.forEach(function (video) {
145 | video.loop = true;
146 | video.play();
147 | });
148 |
149 | raf(function loop (t) {
150 | raf(loop);
151 | var i = Math.floor(t / duration) % videos.length;
152 | var j = (i + 1) % videos.length;
153 | from.setPixels(videos[i]);
154 | to.setPixels(videos[j]);
155 | var progress = (t % duration) / duration;
156 | if (transition) transition.render(progress, from, to, transitionItem.uniforms);
157 | });
158 |
159 | function setTransition (i) {
160 | transitionItem = GlslTransitions[i];
161 | if (transition) transition.dispose();
162 | transition = createTransition(gl, transitionItem.glsl);
163 | }
164 |
165 | var select = document.createElement("select");
166 | select.style.width = "600px";
167 | GlslTransitions.forEach(function (t) {
168 | var option = document.createElement("option");
169 | option.textContent = t.name;
170 | select.appendChild(option);
171 | });
172 | select.addEventListener("change", function () {
173 | setTransition(select.selectedIndex);
174 | });
175 | setTransition(select.selectedIndex);
176 |
177 | document.body.innerHTML = "";
178 | document.body.appendChild(select);
179 | document.body.appendChild(canvas);
180 | }).done();
181 | document.body.innerHTML = "Loading...";
182 | ```
183 |
184 | [](http://gre.github.io/glsl-transition/examples/3/)
185 |
--------------------------------------------------------------------------------
/examples/2/build.js:
--------------------------------------------------------------------------------
1 | !function e(t,r,o){function n(a,s){if(!r[a]){if(!t[a]){var f="function"==typeof require&&require;if(!s&&f)return f(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[a]={exports:{}};t[a][0].call(l.exports,function(e){var r=t[a][1][e];return n(r?r:e)},l,l.exports,e,t,r,o)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;aO)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+O.toString(16)+" bytes");0>n?n=0:n>>>=0,o.TYPED_ARRAY_SUPPORT?r=o._augment(new Uint8Array(n)):(r.length=n,r._isBuffer=!0);var a;if(o.TYPED_ARRAY_SUPPORT&&"number"==typeof e.byteLength)r._set(e);else if(A(e))if(o.isBuffer(e))for(a=0;n>a;a++)r[a]=e.readUInt8(a);else for(a=0;n>a;a++)r[a]=(e[a]%256+256)%256;else if("string"===i)r.write(e,0,t);else if("number"===i&&!o.TYPED_ARRAY_SUPPORT)for(a=0;n>a;a++)r[a]=0;return n>0&&n<=o.poolSize&&(r.parent=N),r}function n(e,t){if(!(this instanceof n))return new n(e,t);var r=new o(e,t);return delete r.parent,r}function i(e,t,r,o){r=Number(r)||0;var n=e.length-r;o?(o=Number(o),o>n&&(o=n)):o=n;var i=t.length;if(i%2!==0)throw new Error("Invalid hex string");o>i/2&&(o=i/2);for(var a=0;o>a;a++){var s=parseInt(t.substr(2*a,2),16);if(isNaN(s))throw new Error("Invalid hex string");e[r+a]=s}return a}function a(e,t,r,o){var n=R(S(t,e.length-r),e,r,o);return n}function s(e,t,r,o){var n=R(I(t),e,r,o);return n}function f(e,t,r,o){return s(e,t,r,o)}function u(e,t,r,o){var n=R(F(t),e,r,o);return n}function l(e,t,r,o){var n=R(P(t,e.length-r),e,r,o);return n}function c(e,t,r){return L.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function p(e,t,r){var o="",n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)e[i]<=127?(o+=j(n)+String.fromCharCode(e[i]),n=""):n+="%"+e[i].toString(16);return o+j(n)}function h(e,t,r){var o="";r=Math.min(e.length,r);for(var n=t;r>n;n++)o+=String.fromCharCode(127&e[n]);return o}function d(e,t,r){var o="";r=Math.min(e.length,r);for(var n=t;r>n;n++)o+=String.fromCharCode(e[n]);return o}function g(e,t,r){var o=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>o)&&(r=o);for(var n="",i=t;r>i;i++)n+=D(e[i]);return n}function m(e,t,r){for(var o=e.slice(t,r),n="",i=0;ie)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function y(e,t,r,n,i,a){if(!o.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||a>t)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range")}function _(e,t,r,o){0>t&&(t=65535+t+1);for(var n=0,i=Math.min(e.length-r,2);i>n;n++)e[r+n]=(t&255<<8*(o?n:1-n))>>>8*(o?n:1-n)}function x(e,t,r,o){0>t&&(t=4294967295+t+1);for(var n=0,i=Math.min(e.length-r,4);i>n;n++)e[r+n]=t>>>8*(o?n:3-n)&255}function b(e,t,r,o,n,i){if(t>n||i>t)throw new RangeError("value is out of bounds");if(r+o>e.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function w(e,t,r,o,n){return n||b(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),U.write(e,t,r,o,23,4),r+4}function T(e,t,r,o,n){return n||b(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),U.write(e,t,r,o,52,8),r+8}function E(e){if(e=C(e).replace(V,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function C(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function A(e){return k(e)||o.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function D(e){return 16>e?"0"+e.toString(16):e.toString(16)}function S(e,t){t=t||1/0;for(var r,o=e.length,n=null,i=[],a=0;o>a;a++){if(r=e.charCodeAt(a),r>55295&&57344>r){if(!n){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(a+1===o){(t-=3)>-1&&i.push(239,191,189);continue}n=r;continue}if(56320>r){(t-=3)>-1&&i.push(239,191,189),n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&((t-=3)>-1&&i.push(239,191,189),n=null);if(128>r){if((t-=1)<0)break;i.push(r)}else if(2048>r){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function I(e){for(var t=[],r=0;r>8,n=r%256,i.push(n),i.push(o);return i}function F(e){return L.toByteArray(E(e))}function R(e,t,r,o){for(var n=0;o>n&&!(n+r>=t.length||n>=e.length);n++)t[n+r]=e[n];return n}function j(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}var L=e("base64-js"),U=e("ieee754"),k=e("is-array");r.Buffer=o,r.SlowBuffer=n,r.INSPECT_MAX_BYTES=50,o.poolSize=8192;var O=1073741823,N={};o.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);a>i&&e[i]===t[i];i++);return i!==a&&(r=e[i],n=t[i]),n>r?-1:r>n?1:0},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!k(e))throw new TypeError("list argument must be an Array of Buffers.");if(0===e.length)return new o(0);if(1===e.length)return e[0];var r;if(void 0===t)for(t=0,r=0;r>>1;break;case"utf8":case"utf-8":r=S(e).length;break;case"base64":r=F(e).length;break;default:r=e.length}return r},o.prototype.length=void 0,o.prototype.parent=void 0,o.prototype.toString=function(e,t,r){var o=!1;if(t>>>=0,r=void 0===r||r===1/0?this.length:r>>>0,e||(e="utf8"),0>t&&(t=0),r>this.length&&(r=this.length),t>=r)return"";for(;;)switch(e){case"hex":return g(this,t,r);case"utf8":case"utf-8":return p(this,t,r);case"ascii":return h(this,t,r);case"binary":return d(this,t,r);case"base64":return c(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,t,r);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}},o.prototype.equals=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===o.compare(this,e)},o.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},o.prototype.compare=function(e){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?0:o.compare(this,e)},o.prototype.indexOf=function(e,t){function r(e,t,r){for(var o=-1,n=0;r+n2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e)return 0===e.length?-1:String.prototype.indexOf.call(this,e,t);if(o.isBuffer(e))return r(this,e,t);if("number"==typeof e)return o.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):r(this,[e],t);throw new TypeError("val must be string, number or Buffer")},o.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},o.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},o.prototype.write=function(e,t,r,o){if(isFinite(t))isFinite(r)||(o=r,r=void 0);else{var n=o;o=t,t=r,r=n}if(t=Number(t)||0,0>r||0>t||t>this.length)throw new RangeError("attempt to write outside buffer bounds");var c=this.length-t;r?(r=Number(r),r>c&&(r=c)):r=c,o=String(o||"utf8").toLowerCase();var p;switch(o){case"hex":p=i(this,e,t,r);break;case"utf8":case"utf-8":p=a(this,e,t,r);break;case"ascii":p=s(this,e,t,r);break;case"binary":p=f(this,e,t,r);break;case"base64":p=u(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":p=l(this,e,t,r);break;default:throw new TypeError("Unknown encoding: "+o)}return p},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var n;if(o.TYPED_ARRAY_SUPPORT)n=o._augment(this.subarray(e,t));else{var i=t-e;n=new o(i,void 0);for(var a=0;i>a;a++)n[a]=this[a+e]}return n.length&&(n.parent=this.parent||this),n},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var o=this[e],n=1,i=0;++i>>=0,t>>>=0,r||v(e,t,this.length);for(var o=this[e+--t],n=1;t>0&&(n*=256);)o+=this[e+--t]*n;return o},o.prototype.readUInt8=function(e,t){return t||v(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||v(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||v(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||v(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||v(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var o=this[e],n=1,i=0;++i=n&&(o-=Math.pow(2,8*t)),o},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var o=t,n=1,i=this[e+--o];o>0&&(n*=256);)i+=this[e+--o]*n;return n*=128,i>=n&&(i-=Math.pow(2,8*t)),i},o.prototype.readInt8=function(e,t){return t||v(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},o.prototype.readInt16LE=function(e,t){t||v(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt16BE=function(e,t){t||v(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},o.prototype.readInt32LE=function(e,t){return t||v(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||v(e,4,this.length),U.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||v(e,4,this.length),U.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||v(e,8,this.length),U.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||v(e,8,this.length),U.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,o){e=+e,t>>>=0,r>>>=0,o||y(this,e,t,r,Math.pow(2,8*r),0);var n=1,i=0;for(this[t]=255&e;++i>>0&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,o){e=+e,t>>>=0,r>>>=0,o||y(this,e,t,r,Math.pow(2,8*r),0);var n=r-1,i=1;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=e/i>>>0&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):_(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):_(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):x(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):x(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,r,o){e=+e,t>>>=0,o||y(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var n=0,i=1,a=0>e?1:0;for(this[t]=255&e;++n>0)-a&255;return t+r},o.prototype.writeIntBE=function(e,t,r,o){e=+e,t>>>=0,o||y(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var n=r-1,i=1,a=0>e?1:0;for(this[t+n]=255&e;--n>=0&&(i*=256);)this[t+n]=(e/i>>0)-a&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):_(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):_(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):x(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):x(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,r){return w(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return w(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return T(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return T(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&r>n&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("sourceStart out of bounds");if(0>n)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-ti||!o.TYPED_ARRAY_SUPPORT)for(var a=0;i>a;a++)e[a+t]=this[a+r];else e._set(this.subarray(r,r+i),t);return i},o.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),t>r)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var o;if("number"==typeof e)for(o=t;r>o;o++)this[o]=e;else{var n=S(e.toString()),i=n.length;for(o=t;r>o;o++)this[o]=n[o%i]}return this}},o.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(o.TYPED_ARRAY_SUPPORT)return new o(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var M=o.prototype;o._augment=function(e){return e.constructor=o,e._isBuffer=!0,e._set=e.set,e.get=M.get,e.set=M.set,e.write=M.write,e.toString=M.toString,e.toLocaleString=M.toString,e.toJSON=M.toJSON,e.equals=M.equals,e.compare=M.compare,e.indexOf=M.indexOf,e.copy=M.copy,e.slice=M.slice,e.readUIntLE=M.readUIntLE,e.readUIntBE=M.readUIntBE,e.readUInt8=M.readUInt8,e.readUInt16LE=M.readUInt16LE,e.readUInt16BE=M.readUInt16BE,e.readUInt32LE=M.readUInt32LE,e.readUInt32BE=M.readUInt32BE,e.readIntLE=M.readIntLE,e.readIntBE=M.readIntBE,e.readInt8=M.readInt8,e.readInt16LE=M.readInt16LE,e.readInt16BE=M.readInt16BE,e.readInt32LE=M.readInt32LE,e.readInt32BE=M.readInt32BE,e.readFloatLE=M.readFloatLE,e.readFloatBE=M.readFloatBE,e.readDoubleLE=M.readDoubleLE,e.readDoubleBE=M.readDoubleBE,e.writeUInt8=M.writeUInt8,e.writeUIntLE=M.writeUIntLE,e.writeUIntBE=M.writeUIntBE,e.writeUInt16LE=M.writeUInt16LE,e.writeUInt16BE=M.writeUInt16BE,e.writeUInt32LE=M.writeUInt32LE,e.writeUInt32BE=M.writeUInt32BE,e.writeIntLE=M.writeIntLE,e.writeIntBE=M.writeIntBE,e.writeInt8=M.writeInt8,e.writeInt16LE=M.writeInt16LE,e.writeInt16BE=M.writeInt16BE,e.writeInt32LE=M.writeInt32LE,e.writeInt32BE=M.writeInt32BE,e.writeFloatLE=M.writeFloatLE,e.writeFloatBE=M.writeFloatBE,e.writeDoubleLE=M.writeDoubleLE,e.writeDoubleBE=M.writeDoubleBE,e.fill=M.fill,e.inspect=M.inspect,e.toArrayBuffer=M.toArrayBuffer,e};var V=/[^+\/0-9A-z\-]/g},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(e,t,r){var o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===a||t===c?62:t===s||t===p?63:f>t?-1:f+10>t?t-f+26+26:l+26>t?t-l:u+26>t?t-u+26:void 0}function r(e){function r(e){u[c++]=e}var o,n,a,s,f,u;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var l=e.length;f="="===e.charAt(l-2)?2:"="===e.charAt(l-1)?1:0,u=new i(3*e.length/4-f),a=f>0?e.length-4:e.length;var c=0;for(o=0,n=0;a>o;o+=4,n+=3)s=t(e.charAt(o))<<18|t(e.charAt(o+1))<<12|t(e.charAt(o+2))<<6|t(e.charAt(o+3)),r((16711680&s)>>16),r((65280&s)>>8),r(255&s);return 2===f?(s=t(e.charAt(o))<<2|t(e.charAt(o+1))>>4,r(255&s)):1===f&&(s=t(e.charAt(o))<<10|t(e.charAt(o+1))<<4|t(e.charAt(o+2))>>2,r(s>>8&255),r(255&s)),u}function n(e){function t(e){return o.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var n,i,a,s=e.length%3,f="";for(n=0,a=e.length-s;a>n;n+=3)i=(e[n]<<16)+(e[n+1]<<8)+e[n+2],f+=r(i);switch(s){case 1:i=e[e.length-1],f+=t(i>>2),f+=t(i<<4&63),f+="==";break;case 2:i=(e[e.length-2]<<8)+e[e.length-1],f+=t(i>>10),f+=t(i>>4&63),f+=t(i<<2&63),f+="="}return f}var i="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),s="/".charCodeAt(0),f="0".charCodeAt(0),u="a".charCodeAt(0),l="A".charCodeAt(0),c="-".charCodeAt(0),p="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=n}("undefined"==typeof r?this.base64js={}:r)},{}],3:[function(e,t,r){r.read=function(e,t,r,o,n){var i,a,s=8*n-o-1,f=(1<>1,l=-7,c=r?n-1:0,p=r?-1:1,h=e[t+c];for(c+=p,i=h&(1<<-l)-1,h>>=-l,l+=s;l>0;i=256*i+e[t+c],c+=p,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=o;l>0;a=256*a+e[t+c],c+=p,l-=8);if(0===i)i=1-u;else{if(i===f)return a?0/0:(h?-1:1)*(1/0);a+=Math.pow(2,o),i-=u}return(h?-1:1)*a*Math.pow(2,i-o)},r.write=function(e,t,r,o,n,i){var a,s,f,u=8*i-n-1,l=(1<>1,p=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,d=o?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-a))<1&&(a--,f*=2),t+=a+c>=1?p/f:p*Math.pow(2,1-c),t*f>=2&&(a++,f/=2),a+c>=l?(s=0,a=l):a+c>=1?(s=(t*f-1)*Math.pow(2,n),a+=c):(s=t*Math.pow(2,c-1)*Math.pow(2,n),a=0));n>=8;e[r+h]=255&s,h+=d,s/=256,n-=8);for(a=a<0;e[r+h]=255&a,h+=d,a/=256,u-=8);e[r+h-d]|=128*g}},{}],4:[function(e,t){var r=Array.isArray,o=Object.prototype.toString;t.exports=r||function(e){return!!e&&"[object Array]"==o.call(e)}},{}],5:[function(e,t){function r(){if(!a){a=!0;for(var e,t=i.length;t;){e=i,i=[];for(var r=-1;++r1&&(t=2-t),l.render(t,c,p,u.uniforms)}});var h=document.createElement("select");h.style.width="600px",n.forEach(function(e){var t=document.createElement("option");t.textContent=e.name,h.appendChild(t)}),h.addEventListener("change",function(){r(h.selectedIndex)}),r(h.selectedIndex),document.body.innerHTML="",document.body.appendChild(h),document.body.appendChild(s)}).done(),document.body.innerHTML="Loading..."},{"../..":26,"gl-texture2d":19,"glsl-transitions":20,q:22,qimage:23,raf:24}],7:[function(e,t,r){"use strict";function o(e){if(!e)return s;for(var t=0;t>",rrshift:">>>"};!function(){for(var e in f){var t=f[e];r[e]=i({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),r[e+"eq"]=i({args:["array","array"],body:{args:["a","b"],body:"a"+t+"=b"},rvalue:!0,funcName:e+"eq"}),r[e+"s"]=i({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),r[e+"seq"]=i({args:["array","scalar"],body:{args:["a","s"],body:"a"+t+"=s"},rvalue:!0,funcName:e+"seq"})}}();var u={not:"!",bnot:"~",neg:"-",recip:"1.0/"};!function(){for(var e in u){var t=u[e];r[e]=i({args:["array","array"],body:{args:["a","b"],body:"a="+t+"b"},funcName:e}),r[e+"eq"]=i({args:["array"],body:{args:["a"],body:"a="+t+"a"},rvalue:!0,count:2,funcName:e+"eq"})}}();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};!function(){for(var e in l){var t=l[e];r[e]=i({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+t+"c"},funcName:e}),r[e+"s"]=i({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+t+"s"},funcName:e+"s"}),r[e+"eq"]=i({args:["array","array"],body:{args:["a","b"],body:"a=a"+t+"b"},rvalue:!0,count:2,funcName:e+"eq"}),r[e+"seq"]=i({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+t+"s"},rvalue:!0,count:2,funcName:e+"seq"})}}();var c=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];!function(){for(var e=0;ethis_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),r.norm1=a({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),r.sup=a({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),r.inf=a({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),r.random=i({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),r.assign=i({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),r.assigns=i({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),r.equals=a({args:["array","array"],pre:s,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":8}],8:[function(e,t){"use strict";function r(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function o(e){var t=new r;t.pre=e.pre,t.body=e.body,t.post=e.post;var o=e.args.slice(0);t.argTypes=o;for(var i=0;i0)throw new Error("cwise: pre() block may not reference array args");if(i0)throw new Error("cwise: post() block may not reference array args")}else if("scalar"===a)t.scalarArgs.push(i),t.shimArgs.push("scalar"+i);else if("index"===a){if(t.indexArgs.push(i),i0)throw new Error("cwise: pre() block may not reference array index");if(i0)throw new Error("cwise: post() block may not reference array index")}else if("shape"===a){if(t.shapeArgs.push(i),io.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>o.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>o.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,n(t)}var n=e("./lib/thunk.js");t.exports=o},{"./lib/thunk.js":10}],9:[function(e,t){"use strict";function r(e,t,r){var o,n,i=e.length,a=t.arrayArgs.length,s=t.indexArgs.length>0,f=[],u=[],l=0,c=0;for(o=0;i>o;++o)u.push(["i",o,"=0"].join(""));for(n=0;a>n;++n)for(o=0;i>o;++o)c=l,l=e[o],u.push(0===o?["d",n,"s",o,"=t",n,"p",l].join(""):["d",n,"s",o,"=(t",n,"p",l,"-s",c,"*t",n,"p",c,")"].join(""));for(f.push("var "+u.join(",")),o=i-1;o>=0;--o)l=e[o],f.push(["for(i",o,"=0;i",o,"o;++o){for(c=l,l=e[o],n=0;a>n;++n)f.push(["p",n,"+=d",n,"s",o].join(""));s&&(o>0&&f.push(["index[",c,"]-=s",c].join("")),f.push(["++index[",l,"]"].join(""))),f.push("}")}return f.join("\n")}function o(e,t,o,n){for(var i=t.length,a=o.arrayArgs.length,s=o.blockSize,f=o.indexArgs.length>0,u=[],l=0;a>l;++l)u.push(["var offset",l,"=p",l].join(""));for(var l=e;i>l;++l)u.push(["for(var j"+l+"=SS[",t[l],"]|0;j",l,">0;){"].join("")),u.push(["if(j",l,"<",s,"){"].join("")),u.push(["s",t[l],"=j",l].join("")),u.push(["j",l,"=0"].join("")),u.push(["}else{s",t[l],"=",s].join("")),u.push(["j",l,"-=",s,"}"].join("")),f&&u.push(["index[",t[l],"]=j",l].join(""));for(var l=0;a>l;++l){for(var c=["offset"+l],p=e;i>p;++p)c.push(["j",p,"*t",l,"p",t[p]].join(""));u.push(["p",l,"=(",c.join("+"),")"].join(""))}u.push(r(t,o,n));for(var l=e;i>l;++l)u.push("}");return u.join("\n")}function n(e){for(var t=0,r=e[0].length;r>t;){for(var o=1;o0&&(r=r&&t[o]===t[o-1])}return r?t[0]:t.join("")}function s(e,t){for(var s=0|t[1].length,u=new Array(e.arrayArgs.length),l=new Array(e.arrayArgs.length),c=["SS"],p=["'use strict'"],h=[],d=0;s>d;++d)h.push(["s",d,"=SS[",d,"]"].join(""));for(var g=0;gd;++d)h.push(["t",g,"p",d,"=t",g,"[",d,"]"].join(""))}for(var g=0;g0&&h.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var m=new Array(s),g=0;s>g;++g)m[g]="0";h.push(["index=[",m.join(","),"]"].join(""))}for(var g=0;g3&&p.push(i(e.pre,e,l));var x=i(e.body,e,l),b=n(u);p.push(s>b?o(b,u[0],e,x):r(u[0],e,x)),e.post.body.length>3&&p.push(i(e.post,e,l)),e.debug&&console.log("Generated cwise routine for ",t,":\n\n",p.join("\n"));var w=[e.funcName||"unnamed","_cwise_loop_",u[0].join("s"),"m",b,a(l)].join(""),T=new Function(["function ",w,"(",c.join(","),"){",p.join("\n"),"} return ",w].join(""));return T()}var f=e("uniq");t.exports=s},{uniq:11}],10:[function(e,t){"use strict";function r(e){var t=["'use strict'","var CACHED={}"],r=[],n=e.funcName+"_cwise_thunk";t.push(["return function ",n,"(",e.shimArgs.join(","),"){"].join(""));for(var i=[],a=[],s=[["array",e.arrayArgs[0],".shape"].join("")],f=0;fa;++a)if(i=n,n=e[a],t(n,i)){if(a===r){r++;continue}e[r++]=n}return e.length=r,e}function o(e){for(var t=1,r=e.length,o=e[0],n=e[0],i=1;r>i;++i,n=o)if(n=o,o=e[i],o!==n){if(i===t){t++;continue}e[t++]=o}return e.length=t,e}function n(e,t,n){return 0===e.length?e:t?(n||e.sort(t),r(e,t)):(n||e.sort(),o(e))}t.exports=n},{}],12:[function(e,t){(function(r){function o(e,t){return e[0]-t[0]}function n(){var e,t=this.stride,r=new Array(t.length);for(e=0;et&&(r="View_Nil"+e);var o="generic"===e;if(-1===t){var i="function "+r+"(a){this.data=a;};var proto="+r+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}",a=new Function(i);return a()}if(0===t){var i="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(o?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(o?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}",a=new Function("TrivialArray",i);return a(c[e][0])}var i=["'use strict'"],s=f(t),u=s.map(function(e){return"i"+e}),l="this.offset+"+s.map(function(e){return"this.stride["+e+"]*i"+e}).join("+"),p=s.map(function(e){return"b"+e}).join(","),h=s.map(function(e){return"c"+e}).join(",");i.push("function "+r+"(a,"+p+","+h+",d){this.data=a","this.shape=["+p+"]","this.stride=["+h+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),i.push("Object.defineProperty(proto,'size',{get:function "+r+"_size(){return "+s.map(function(e){return"this.shape["+e+"]"}).join("*"),"}})"),1===t?i.push("proto.order=[0]"):(i.push("Object.defineProperty(proto,'order',{get:"),4>t?(i.push("function "+r+"_order(){"),2===t?i.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):i.push("ORDER})")),i.push("proto.set=function "+r+"_set("+u.join(",")+",v){"),i.push(o?"return this.data.set("+l+",v)}":"return this.data["+l+"]=v}"),i.push("proto.get=function "+r+"_get("+u.join(",")+"){"),i.push(o?"return this.data.get("+l+")}":"return this.data["+l+"]}"),i.push("proto.index=function "+r+"_index(",u.join(),"){return "+l+"}"),i.push("proto.hi=function "+r+"_hi("+u.join(",")+"){return new "+r+"(this.data,"+s.map(function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")}).join(",")+","+s.map(function(e){return"this.stride["+e+"]"}).join(",")+",this.offset)}");var d=s.map(function(e){return"a"+e+"=this.shape["+e+"]"}),g=s.map(function(e){return"c"+e+"=this.stride["+e+"]"});i.push("proto.lo=function "+r+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+g.join(","));for(var m=0;t>m;++m)i.push("if(typeof i"+m+"==='number'&&i"+m+">=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");i.push("return new "+r+"(this.data,"+s.map(function(e){return"a"+e}).join(",")+","+s.map(function(e){return"c"+e}).join(",")+",b)}"),i.push("proto.step=function "+r+"_step("+u.join(",")+"){var "+s.map(function(e){return"a"+e+"=this.shape["+e+"]"}).join(",")+","+s.map(function(e){return"b"+e+"=this.stride["+e+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var m=0;t>m;++m)i.push("if(typeof i"+m+"==='number'){d=i"+m+"|0;if(d<0){c+=b"+m+"*(a"+m+"-1);a"+m+"=ceil(-a"+m+"/d)}else{a"+m+"=ceil(a"+m+"/d)}b"+m+"*=d}");i.push("return new "+r+"(this.data,"+s.map(function(e){return"a"+e}).join(",")+","+s.map(function(e){return"b"+e}).join(",")+",c)}");for(var v=new Array(t),y=new Array(t),m=0;t>m;++m)v[m]="a[i"+m+"]",y[m]="b[i"+m+"]";i.push("proto.transpose=function "+r+"_transpose("+u+"){"+u.map(function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+v.join(",")+","+y.join(",")+",this.offset)}"),i.push("proto.pick=function "+r+"_pick("+u+"){var a=[],b=[],c=this.offset");for(var m=0;t>m;++m)i.push("if(typeof i"+m+"==='number'&&i"+m+">=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(data,"+s.map(function(e){return"shape["+e+"]"}).join(",")+","+s.map(function(e){return"stride["+e+"]"}).join(",")+",offset)}");var a=new Function("CTOR_LIST","ORDER",i.join("\n"));return a(c[e],n)}function a(e){if(l&&r.isBuffer(e))return"buffer";if(u)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(e)?"array":"generic"}function s(e,t,r,o){if(void 0===e){var n=c.array[0];return n([])}"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var s=t.length;if(void 0===r){r=new Array(s);for(var f=s-1,u=1;f>=0;--f)r[f]=u,u*=t[f]}if(void 0===o){o=0;for(var f=0;s>f;++f)r[f]<0&&(o-=(t[f]-1)*r[f])}for(var l=a(e),p=c[l];p.length<=s+1;)p.push(i(l,p.length-1));var n=p[s+1];return n(e,t,r,o)}var f=e("iota-array"),u="undefined"!=typeof Float64Array,l="undefined"!=typeof r,c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};t.exports=s}).call(this,e("buffer").Buffer)},{buffer:1,"iota-array":13}],13:[function(e,t){"use strict";function r(e){for(var t=new Array(e),r=0;e>r;++r)t[r]=r;return t}t.exports=r},{}],14:[function(e,t,r){"use strict";"use restrict";function o(e){var t=32;return e&=-e,e&&t--,65535&e&&(t-=16),16711935&e&&(t-=8),252645135&e&&(t-=4),858993459&e&&(t-=2),1431655765&e&&(t-=1),t}var n=32;r.INT_BITS=n,r.INT_MAX=2147483647,r.INT_MIN=-1<0)-(0>e)},r.abs=function(e){var t=e>>n-1;return(e^t)-t},r.min=function(e,t){return t^(e^t)&-(t>e)},r.max=function(e,t){return e^(e^t)&-(t>e)},r.isPow2=function(e){return!(e&e-1||!e)},r.log2=function(e){var t,r;return t=(e>65535)<<4,e>>>=t,r=(e>255)<<3,e>>>=r,t|=r,r=(e>15)<<2,e>>>=r,t|=r,r=(e>3)<<1,e>>>=r,t|=r,t|e>>1},r.log10=function(e){return e>=1e9?9:e>=1e8?8:e>=1e7?7:e>=1e6?6:e>=1e5?5:e>=1e4?4:e>=1e3?3:e>=100?2:e>=10?1:0},r.popCount=function(e){return e-=e>>>1&1431655765,e=(858993459&e)+(e>>>2&858993459),16843009*(e+(e>>>4)&252645135)>>>24},r.countTrailingZeros=o,r.nextPow2=function(e){return e+=0===e,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1},r.prevPow2=function(e){return e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e-(e>>>1)},r.parity=function(e){return e^=e>>>16,e^=e>>>8,e^=e>>>4,e&=15,27030>>>e&1};var i=new Array(256);!function(e){for(var t=0;256>t;++t){var r=t,o=t,n=7;for(r>>>=1;r;r>>>=1)o<<=1,o|=1&r,--n;e[t]=o<>>8&255]<<16|i[e>>>16&255]<<8|i[e>>>24&255]},r.interleave2=function(e,t){return e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1},r.deinterleave2=function(e,t){return e=e>>>t&1431655765,e=858993459&(e|e>>>1),e=252645135&(e|e>>>2),e=16711935&(e|e>>>4),e=65535&(e|e>>>16),e<<16>>16},r.interleave3=function(e,t,r){return e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e|=t<<1,r&=1023,r=4278190335&(r|r<<16),r=251719695&(r|r<<8),r=3272356035&(r|r<<4),r=1227133513&(r|r<<2),e|r<<2},r.deinterleave3=function(e,t){return e=e>>>t&1227133513,e=3272356035&(e|e>>>2),e=251719695&(e|e>>>4),e=4278190335&(e|e>>>8),e=1023&(e|e>>>16),e<<22>>22},r.nextCombination=function(e){var t=e|e-1;return t+1|(~t&-~t)-1>>>o(e)+1}},{}],15:[function(e,t){"use strict";function r(e,t,o){var n=0|e[o];if(0>=n)return[];var i,a=new Array(n);if(o===e.length-1)for(i=0;n>i;++i)a[i]=t;else for(i=0;n>i;++i)a[i]=r(e,t,o+1);return a}function o(e,t){var r,o;for(r=new Array(e),o=0;e>o;++o)r[o]=t;return r}function n(e,t){switch("undefined"==typeof t&&(t=0),typeof e){case"number":if(e>0)return o(0|e,t);break;case"object":if("number"==typeof e.length)return r(e,t,0)}return[]}t.exports=n},{}],16:[function(e,t,r){(function(t,o){"use strict";function n(e){if(e){var t=e.length||e.byteLength,r=y.log2(t);w[r].push(e)}}function i(e){n(e.buffer)}function a(e){var e=y.nextPow2(e),t=y.log2(e),r=w[t];return r.length>0?r.pop():new ArrayBuffer(e)}function s(e){return new Uint8Array(a(e),0,e)}function f(e){return new Uint16Array(a(2*e),0,e)}function u(e){return new Uint32Array(a(4*e),0,e)}function l(e){return new Int8Array(a(e),0,e)}function c(e){return new Int16Array(a(2*e),0,e)}function p(e){return new Int32Array(a(4*e),0,e)}function h(e){return new Float32Array(a(4*e),0,e)}function d(e){return new Float64Array(a(8*e),0,e)}function g(e){return x?new Uint8ClampedArray(a(e),0,e):s(e)}function m(e){return new DataView(a(e),0,e)}function v(e){e=y.nextPow2(e);var t=y.log2(e),r=T[t];return r.length>0?r.pop():new o(e)}var y=e("bit-twiddle"),_=e("dup");t.__TYPEDARRAY_POOL||(t.__TYPEDARRAY_POOL={UINT8:_([32,0]),UINT16:_([32,0]),UINT32:_([32,0]),INT8:_([32,0]),INT16:_([32,0]),INT32:_([32,0]),FLOAT:_([32,0]),DOUBLE:_([32,0]),DATA:_([32,0]),UINT8C:_([32,0]),BUFFER:_([32,0])});var x="undefined"!=typeof Uint8ClampedArray,b=t.__TYPEDARRAY_POOL;b.UINT8C||(b.UINT8C=_([32,0])),b.BUFFER||(b.BUFFER=_([32,0]));var w=b.DATA,T=b.BUFFER;r.free=function(e){if(o.isBuffer(e))T[y.log2(e.length)].push(e);else{if("[object ArrayBuffer]"!==Object.prototype.toString.call(e)&&(e=e.buffer),!e)return;var t=e.length||e.byteLength,r=0|y.log2(t);w[r].push(e)}},r.freeUint8=r.freeUint16=r.freeUint32=r.freeInt8=r.freeInt16=r.freeInt32=r.freeFloat32=r.freeFloat=r.freeFloat64=r.freeDouble=r.freeUint8Clamped=r.freeDataView=i,r.freeArrayBuffer=n,r.freeBuffer=function(e){T[y.log2(e.length)].push(e)},r.malloc=function(e,t){if(void 0===t||"arraybuffer"===t)return a(e);switch(t){case"uint8":return s(e);case"uint16":return f(e);case"uint32":return u(e);case"int8":return l(e);case"int16":return c(e);case"int32":return p(e);case"float":case"float32":return h(e);case"double":case"float64":return d(e);case"uint8_clamped":return g(e);case"buffer":return v(e);case"data":case"dataview":return m(e);default:return null}return null},r.mallocArrayBuffer=a,r.mallocUint8=s,r.mallocUint16=f,r.mallocUint32=u,r.mallocInt8=l,r.mallocInt16=c,r.mallocInt32=p,r.mallocFloat32=r.mallocFloat=h,r.mallocFloat64=r.mallocDouble=d,r.mallocUint8Clamped=g,r.mallocDataView=m,r.mallocBuffer=v,r.clearCache=function(){for(var e=0;32>e;++e)b.UINT8[e].length=0,b.UINT16[e].length=0,b.UINT32[e].length=0,b.INT8[e].length=0,b.INT16[e].length=0,b.INT32[e].length=0,b.FLOAT[e].length=0,b.DOUBLE[e].length=0,b.UINT8C[e].length=0,w[e].length=0,T[e].length=0}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"bit-twiddle":14,buffer:1,dup:15}],17:[function(e,t){!function(){"use strict";function e(t){t.permitHostObjects___&&t.permitHostObjects___(e)}function r(e){return!(e.substr(0,h.length)==h&&"___"===e.substr(e.length-3))}function o(e){if(e!==Object(e))throw new TypeError("Not an object: "+e);var t=e[d];if(t&&t.key===e)return t;if(!p(e))return void 0;t={key:e};try{return c(e,d,{value:t,writable:!1,enumerable:!1,configurable:!1}),t}catch(r){return void 0}}function n(e){return e.prototype=null,Object.freeze(e)}function i(){y||"undefined"==typeof console||(y=!0,console.warn("WeakMap should be invoked as new WeakMap(), not WeakMap(). This will be an error in the future."))}if("undefined"==typeof ses||!ses.ok||ses.ok()){"undefined"!=typeof ses&&(ses.weakMapPermitHostObjects=e);var a=!1;if("function"==typeof WeakMap){var s=WeakMap;if("undefined"!=typeof navigator&&/Firefox/.test(navigator.userAgent));else{var f=new s,u=Object.freeze({});if(f.set(u,1),1===f.get(u))return void(t.exports=WeakMap);a=!0}}var l=(Object.prototype.hasOwnProperty,Object.getOwnPropertyNames),c=Object.defineProperty,p=Object.isExtensible,h="weakmap:",d=h+"ident:"+Math.random()+"___";if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues&&"function"==typeof ArrayBuffer&&"function"==typeof Uint8Array){var g=new ArrayBuffer(25),m=new Uint8Array(g);crypto.getRandomValues(m),d=h+"rand:"+Array.prototype.map.call(m,function(e){return(e%36).toString(36)}).join("")+"___"}if(c(Object,"getOwnPropertyNames",{value:function(e){return l(e).filter(r)}}),"getPropertyNames"in Object){var v=Object.getPropertyNames;c(Object,"getPropertyNames",{value:function(e){return v(e).filter(r)}})}!function(){var e=Object.freeze;c(Object,"freeze",{value:function(t){return o(t),e(t)}});var t=Object.seal;c(Object,"seal",{value:function(e){return o(e),t(e)}});var r=Object.preventExtensions;c(Object,"preventExtensions",{value:function(e){return o(e),r(e)}})}();var y=!1,_=0,x=function(){function e(e,t){var r,n=o(e);return n?u in n?n[u]:t:(r=s.indexOf(e),r>=0?f[r]:t)}function t(e){var t=o(e);return t?u in t:s.indexOf(e)>=0}function r(e,t){var r,n=o(e);return n?n[u]=t:(r=s.indexOf(e),r>=0?f[r]=t:(r=s.length,f[r]=t,s[r]=e)),this}function a(e){var t,r,n=o(e);return n?u in n&&delete n[u]:(t=s.indexOf(e),0>t?!1:(r=s.length-1,s[t]=void 0,f[t]=f[r],s[t]=s[r],s.length=r,f.length=r,!0))}this instanceof x||i();var s=[],f=[],u=_++;return Object.create(x.prototype,{get___:{value:n(e)},has___:{value:n(t)},set___:{value:n(r)},delete___:{value:n(a)}})};x.prototype=Object.create(Object.prototype,{get:{value:function(e,t){return this.get___(e,t)},writable:!0,configurable:!0},has:{value:function(e){return this.has___(e)},writable:!0,configurable:!0},set:{value:function(e,t){return this.set___(e,t)},writable:!0,configurable:!0},"delete":{value:function(e){return this.delete___(e)},writable:!0,configurable:!0}}),"function"==typeof s?!function(){function r(){function t(e,t){return l?u.has(e)?u.get(e):l.get___(e,t):u.get(e,t)}function r(e){return u.has(e)||(l?l.has___(e):!1)}function o(e){var t=!!u["delete"](e);return l?l.delete___(e)||t:t}this instanceof x||i();var f,u=new s,l=void 0,c=!1;return f=a?function(e,t){return u.set(e,t),u.has(e)||(l||(l=new x),l.set(e,t)),this}:function(e,t){if(c)try{u.set(e,t)}catch(r){l||(l=new x),l.set___(e,t)}else u.set(e,t);return this},Object.create(x.prototype,{get___:{value:n(t)},has___:{value:n(r)},set___:{value:n(f)},delete___:{value:n(o)},permitHostObjects___:{value:n(function(t){if(t!==e)throw new Error("bogus call to permitHostObjects___");c=!0})}})}a&&"undefined"!=typeof Proxy&&(Proxy=void 0),r.prototype=x.prototype,t.exports=r,Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:!1,configurable:!0,writable:!0})}():("undefined"!=typeof Proxy&&(Proxy=void 0),t.exports=x)}}()},{}],18:[function(e,t){"use strict";function r(e){return e.replace(/^[A-Z]+_/,"")}function o(e){var t=i.get(e);if(t)return t;for(var o={},n=e.getSupportedExtensions(),a=0;at||t>n||0>r||r>n)throw new Error("gl-texture2d: Invalid texture size");return e._shape=[t,r],e.bind(),o.texImage2D(o.TEXTURE_2D,0,e.format,t,r,0,e.format,e.type,null),e._mipLevels=[0],e}function n(e,t,r,o,n,i){this.gl=e,this.handle=t,this.format=n,this.type=i,this._shape=[r,o],this._mipLevels=[0],this._magFilter=e.NEAREST,this._minFilter=e.NEAREST,this._wrapS=e.CLAMP_TO_EDGE,this._wrapT=e.CLAMP_TO_EDGE,this._anisoSamples=1;var a=this,s=[this._wrapS,this._wrapT];Object.defineProperties(s,[{get:function(){return a._wrapS},set:function(e){return a.wrapS=e}},{get:function(){return a._wrapT},set:function(e){return a.wrapT=e}}]),this._wrapVector=s;var f=[this._shape[0],this._shape[1]];Object.defineProperties(f,[{get:function(){return a._shape[0]},set:function(e){return a.width=e}},{get:function(){return a._shape[1]},set:function(e){return a.height=e}}]),this._shapeVector=f}function i(e,t){return 3===e.length?1===t[2]&&t[1]===e[0]*e[2]&&t[0]===e[2]:1===t[0]&&t[1]===e[0]}function a(e,t,r,o,n,a,s,f){var u=f.dtype,l=f.shape.slice();if(l.length<2||l.length>3)throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d");var c=0,g=0,m=i(l,f.stride.slice());"float32"===u?c=e.FLOAT:"float64"===u?(c=e.FLOAT,m=!1,u="float32"):"uint8"===u?c=e.UNSIGNED_BYTE:(c=e.UNSIGNED_BYTE,m=!1,u="uint8");var v=1;if(2===l.length)g=e.LUMINANCE,l=[l[0],l[1],1],f=p(f.data,l,[f.stride[0],f.stride[1],1],f.offset);else{if(3!==l.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===l[2])g=e.ALPHA;else if(2===l[2])g=e.LUMINANCE_ALPHA;else if(3===l[2])g=e.RGB;else{if(4!==l[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");g=e.RGBA}v=l[2]}if(g!==e.LUMINANCE&&g!==e.ALPHA||n!==e.LUMINANCE&&n!==e.ALPHA||(g=n),g!==n)throw new Error("gl-texture2d: Incompatible texture format for setPixels");var y=f.size,x=s.indexOf(o)<0;if(x&&s.push(o),c===a&&m)0===f.offset&&f.data.length===y?x?e.texImage2D(e.TEXTURE_2D,o,n,l[0],l[1],0,n,a,f.data):e.texSubImage2D(e.TEXTURE_2D,o,t,r,l[0],l[1],n,a,f.data):x?e.texImage2D(e.TEXTURE_2D,o,n,l[0],l[1],0,n,a,f.data.subarray(f.offset,f.offset+y)):e.texSubImage2D(e.TEXTURE_2D,o,t,r,l[0],l[1],n,a,f.data.subarray(f.offset,f.offset+y));else{var b;b=a===e.FLOAT?d.mallocFloat32(y):d.mallocUint8(y);var w=p(b,l,[l[2],l[2]*l[0],1]);c===e.FLOAT&&a===e.UNSIGNED_BYTE?_(w,f):h.assign(w,f),x?e.texImage2D(e.TEXTURE_2D,o,n,l[0],l[1],0,n,a,b.subarray(0,y)):e.texSubImage2D(e.TEXTURE_2D,o,t,r,l[0],l[1],n,a,b.subarray(0,y)),a===e.FLOAT?d.freeFloat32(b):d.freeUint8(b)}}function s(e){var t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function f(e,t,r,o,i){var a=e.getParameter(e.MAX_TEXTURE_SIZE);if(0>t||t>a||0>r||r>a)throw new Error("gl-texture2d: Invalid texture shape");if(i===e.FLOAT&&!g(e).texture_float)throw new Error("gl-texture2d: Floating point textures not supported on this platform");var f=s(e);return e.texImage2D(e.TEXTURE_2D,0,o,t,r,0,o,i,null),new n(e,f,t,r,o,i)}function u(e,t,r,o){var i=s(e);return e.texImage2D(e.TEXTURE_2D,0,r,r,o,t),new n(e,i,0|t.width,0|t.height,r,o)}function l(e,t){var r=t.dtype,o=t.shape.slice(),a=e.getParameter(e.MAX_TEXTURE_SIZE);if(o[0]<0||o[0]>a||o[1]<0||o[1]>a)throw new Error("gl-texture2d: Invalid texture size");var f=i(o,t.stride.slice()),u=0;"float32"===r?u=e.FLOAT:"float64"===r?(u=e.FLOAT,f=!1,r="float32"):"uint8"===r?u=e.UNSIGNED_BYTE:(u=e.UNSIGNED_BYTE,f=!1,r="uint8");var l=0;if(2===o.length)l=e.LUMINANCE,o=[o[0],o[1],1],t=p(t.data,o,[t.stride[0],t.stride[1],1],t.offset);else{if(3!==o.length)throw new Error("gl-texture2d: Invalid shape for texture");if(1===o[2])l=e.ALPHA;else if(2===o[2])l=e.LUMINANCE_ALPHA;else if(3===o[2])l=e.RGB;else{if(4!==o[2])throw new Error("gl-texture2d: Invalid shape for pixel coords");l=e.RGBA}}u!==e.FLOAT||g(e).texture_float||(u=e.UNSIGNED_BYTE,f=!1);var c,m,v=t.size;if(f)c=0===t.offset&&t.data.length===v?t.data:t.data.subarray(t.offset,t.offset+v);else{var y=[o[2],o[2]*o[0],1];m=d.malloc(v,r);var x=p(m,o,y,0);"float32"!==r&&"float64"!==r||u!==e.UNSIGNED_BYTE?h.assign(x,t):_(x,t),c=m.subarray(0,v)}var b=s(e);return e.texImage2D(e.TEXTURE_2D,0,l,o[0],o[1],0,l,u,c),f||d.free(m),new n(e,b,o[0],o[1],l,u)}function c(e){if(arguments.length<=1)throw new Error("gl-texture2d: Missing arguments for texture2d constructor");if(m||r(e),"number"==typeof arguments[1])return f(e,arguments[1],arguments[2],arguments[3]||e.RGBA,arguments[4]||e.UNSIGNED_BYTE);if(Array.isArray(arguments[1]))return f(e,0|arguments[1][0],0|arguments[1][1],arguments[2]||e.RGBA,arguments[3]||e.UNSIGNED_BYTE);if("object"==typeof arguments[1]){var t=arguments[1];if(t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement||t instanceof ImageData)return u(e,t,arguments[2]||e.RGBA,arguments[3]||e.UNSIGNED_BYTE);if(t.shape&&t.data&&t.stride)return l(e,t)}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}var p=e("ndarray"),h=e("ndarray-ops"),d=e("typedarray-pool"),g=e("webglew");t.exports=c;var m=null,v=null,y=null,_=function(e,t){h.muls(e,t,255)},x=n.prototype;Object.defineProperties(x,{minFilter:{get:function(){return this._minFilter},set:function(e){this.bind();var t=this.gl;if(this.type===t.FLOAT&&m.indexOf(e)>=0&&(g(t).texture_float_linear||(e=t.NEAREST)),v.indexOf(e)<0)throw new Error("gl-texture2d: Unknown filter mode "+e);return t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,e),this._minFilter=e}},magFilter:{get:function(){return this._magFilter},set:function(e){this.bind();var t=this.gl;if(this.type===t.FLOAT&&m.indexOf(e)>=0&&(g(t).texture_float_linear||(e=t.NEAREST)),v.indexOf(e)<0)throw new Error("gl-texture2d: Unknown filter mode "+e);return t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,e),this._magFilter=e}},mipSamples:{get:function(){return this._anisoSamples},set:function(e){var t=this._anisoSamples;if(this._anisoSamples=0|Math.max(e,1),t!==this._anisoSamples){var r=g(this.gl).EXT_texture_filter_anisotropic;r&&this.gl.texParameterf(this.gl.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(e){if(this.bind(),y.indexOf(e)<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,e),this._wrapS=e}},wrapT:{get:function(){return this._wrapT},set:function(e){if(this.bind(),y.indexOf(e)<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);return this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,e),this._wrapT=e}},wrap:{get:function(){return this._wrapVector},set:function(e){if(Array.isArray(e)||(e=[e,e]),2!==e.length)throw new Error("gl-texture2d: Must specify wrap mode for rows and columns");for(var t=0;2>t;++t)if(y.indexOf(e[t])<0)throw new Error("gl-texture2d: Unknown wrap mode "+e);this._wrapS=e[0],this._wrapT=e[1];var r=this.gl;return this.bind(),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,this._wrapS),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,this._wrapT),e}},shape:{get:function(){return this._shapeVector},set:function(e){if(Array.isArray(e)){if(2!==e.length)throw new Error("gl-texture2d: Invalid texture shape")}else e=[0|e,0|e];return o(this,0|e[0],0|e[1]),[0|e[0],0|e[1]]}},width:{get:function(){return this._shape[0]},set:function(e){return e=0|e,o(this,e,this._shape[1]),e}},height:{get:function(){return this._shape[1]},set:function(e){return e=0|e,o(this,this._shape[0],e),e}}}),x.bind=function(e){var t=this.gl;return void 0!==e&&t.activeTexture(t.TEXTURE0+(0|e)),t.bindTexture(t.TEXTURE_2D,this.handle),void 0!==e?0|e:t.getParameter(t.ACTIVE_TEXTURE)-t.TEXTURE0},x.dispose=function(){this.gl.deleteTexture(this.handle)},x.generateMipmap=function(){this.bind(),this.gl.generateMipmap(this.gl.TEXTURE_2D);for(var e=Math.min(this._shape[0],this._shape[1]),t=0;e>0;++t,e>>>=1)this._mipLevels.indexOf(t)<0&&this._mipLevels.push(t)},x.setPixels=function(e,t,r,o){var n=this.gl;if(this.bind(),Array.isArray(t)?(o=r,r=0|t[1],t=0|t[0]):(t=t||0,r=r||0),o=o||0,e instanceof HTMLCanvasElement||e instanceof ImageData||e instanceof HTMLImageElement||e instanceof HTMLVideoElement){var i=this._mipLevels.indexOf(o)<0;i?(n.texImage2D(n.TEXTURE_2D,0,this.format,this.format,this.type,e),this._mipLevels.push(o)):n.texSubImage2D(n.TEXTURE_2D,o,t,r,this.format,this.type,e)}else{if(!(e.shape&&e.stride&&e.data))throw new Error("gl-texture2d: Unsupported data type");if(e.shape.length<2||t+e.shape[1]>this._shape[1]>>>o||r+e.shape[0]>this._shape[0]>>>o||0>t||0>r)throw new Error("gl-texture2d: Texture dimensions are out of bounds");a(n,t,r,o,this.format,this.type,this._mipLevels,e)}}},{ndarray:12,"ndarray-ops":7,"typedarray-pool":16,webglew:18}],20:[function(e,t){t.exports=e("./transitions.min.json")},{"./transitions.min.json":21}],21:[function(e,t){t.exports=[{id:"1b4862e4e2050a3abebe",name:"glitch displace",owner:"mattdesl",uniforms:{},html_url:"https://gist.github.com/1b4862e4e2050a3abebe",created_at:"2015-01-15T19:48:03Z",updated_at:"2015-04-06T02:57:21Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;highp float random(vec2 co){highp float a=12.9898;highp float b=78.233;highp float c=43758.5453;highp float dt=dot(co.xy,vec2(a,b));highp float sn=mod(dt,3.14);return fract(sin(sn)*c);}float voronoi(in vec2 x){vec2 p=floor(x);vec2 f=fract(x);float res=8.0;for(float j=-1.;j<=1.;j++)for(float i=-1.;i<=1.;i++){vec2 b=vec2(i,j);vec2 r=b-f+random(p+b);float d=dot(r,r);res=min(res,d);}return sqrt(res);}vec2 displace(vec4 tex,vec2 texCoord,float dotDepth,float textureDepth,float strength){float b=voronoi(.003*texCoord+2.0);float g=voronoi(0.2*texCoord);float r=voronoi(texCoord-1.0);vec4 dt=tex*1.0;vec4 dis=dt*dotDepth+1.0-tex*textureDepth;dis.x=dis.x-1.0+textureDepth*dotDepth;dis.y=dis.y-1.0+textureDepth*dotDepth;dis.x*=strength;dis.y*=strength;vec2 res_uv=texCoord;res_uv.x=res_uv.x+dis.x-0.0;res_uv.y=res_uv.y+dis.y;return res_uv;}float ease1(float t){return t==0.0||t==1.0?t:t<0.5?+0.5*pow(2.0,(20.0*t)-10.0):-0.5*pow(2.0,10.0-(t*20.0))+1.0;}float ease2(float t){return t==1.0?t:1.0-pow(2.0,-10.0*t);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec4 color1=texture2D(from,p);vec4 color2=texture2D(to,p);vec2 disp=displace(color1,p,0.33,0.7,1.0-ease1(progress));vec2 disp2=displace(color2,p,0.33,0.5,ease2(progress));vec4 dColor1=texture2D(to,disp);vec4 dColor2=texture2D(from,disp2);float val=ease1(progress);vec3 gray=vec3(dot(min(dColor2,dColor1).rgb,vec3(0.299,0.587,0.114)));dColor2=vec4(gray,1.0);dColor2*=2.0;color1=mix(color1,dColor2,smoothstep(0.0,0.5,progress));color2=mix(color2,dColor1,smoothstep(1.0,0.5,progress));gl_FragColor=mix(color1,color2,val);}"
4 | },{id:"04fd9a7de4012cbb03f6",name:"crosshatch",owner:"pthrasher",uniforms:{},html_url:"https://gist.github.com/04fd9a7de4012cbb03f6",created_at:"2014-12-17T03:04:51Z",updated_at:"2015-04-06T03:00:04Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;const vec2 center=vec2(0.5,0.5);float quadraticInOut(float t){float p=2.0*t*t;return t<0.5?p:-p+(4.0*t)-1.0;}float rand(vec2 co){return fract(sin(dot(co.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;if(progress==0.0){gl_FragColor=texture2D(from,p);}else if(progress==1.0){gl_FragColor=texture2D(to,p);}else{float x=progress;float dist=distance(center,p);float r=x-min(rand(vec2(p.y,0.0)),rand(vec2(0.0,p.x)));float m=dist<=r?1.0:0.0;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),m);}}"},{id:"8e6226b215548ba12734",name:"undulating burn out",owner:"pthrasher",uniforms:{smoothness:.02},html_url:"https://gist.github.com/8e6226b215548ba12734",created_at:"2014-12-16T23:01:57Z",updated_at:"2015-04-06T02:58:14Z",stars:2,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define M_PI 3.14159265358979323846 /* pi */\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float smoothness;const vec2 center=vec2(0.5,0.5);float quadraticInOut(float t){float p=2.0*t*t;return t<0.5?p:-p+(4.0*t)-1.0;}float linearInterp(vec2 range,vec2 domain,float x){return mix(range.x,range.y,smoothstep(domain.x,domain.y,clamp(x,domain.x,domain.y)));}float getGradient(float r,float dist){float grad=smoothstep(-smoothness,0.0,r-dist*(1.0+smoothness));if(r-dist<0.005&&r-dist>-0.005){return -1.0;}else if(r-dist<0.01&&r-dist>-0.005){return -2.0;}return grad;}float round(float a){return floor(a+0.5);}float getWave(vec2 p){vec2 _p=p-center;float rads=atan(_p.y,_p.x);float degs=degrees(rads)+180.0;vec2 range=vec2(0.0,M_PI*30.0);vec2 domain=vec2(0.0,360.0);float ratio=(M_PI*30.0)/360.0;degs=degs*ratio;float x=progress;float magnitude=mix(0.02,0.09,smoothstep(0.0,1.0,x));float offset=mix(40.0,30.0,smoothstep(0.0,1.0,x));float ease_degs=quadraticInOut(sin(degs));float deg_wave_pos=(ease_degs*magnitude)*sin(x*offset);return x+deg_wave_pos;}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;if(progress==0.0){gl_FragColor=texture2D(from,p);}else if(progress==1.0){gl_FragColor=texture2D(to,p);}else{float dist=distance(center,p);float m=getGradient(getWave(p),dist);if(m==-2.0){gl_FragColor=mix(texture2D(from,p),vec4(0.0,0.0,0.0,1.0),0.75);}else{gl_FragColor=mix(texture2D(from,p),texture2D(to,p),m);}}}"},{id:"b3aa4a8b4f88dc228d4a",name:"test",owner:"brandonyoyo",uniforms:{},html_url:"https://gist.github.com/b3aa4a8b4f88dc228d4a",created_at:"2014-10-26T16:46:18Z",updated_at:"2015-04-06T02:58:08Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),progress);}"},{id:"d1f891c5585fc40b55ea",name:"Star Wipe",owner:"MemoryStomp",uniforms:{},html_url:"https://gist.github.com/d1f891c5585fc40b55ea",created_at:"2014-07-01T06:58:45Z",updated_at:"2015-04-06T03:00:05Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;vec2 circlePoint(float ang){ang+=6.28318*0.15;return vec2(cos(ang),sin(ang));}float cross2d(vec2 a,vec2 b){return (a.x*b.y-a.y*b.x);}float star(vec2 p,float size){if(size<=0.0){return 0.0;}p/=size;vec2 p0=circlePoint(0.0);vec2 p1=circlePoint(6.28318*1.0/5.0);vec2 p2=circlePoint(6.28318*2.0/5.0);vec2 p3=circlePoint(6.28318*3.0/5.0);vec2 p4=circlePoint(6.28318*4.0/5.0);float s0=(cross2d(p1-p0,p-p0));float s1=(cross2d(p2-p1,p-p1));float s2=(cross2d(p3-p2,p-p2));float s3=(cross2d(p4-p3,p-p3));float s4=(cross2d(p0-p4,p-p4));float s5=min(min(min(s0,s1),min(s2,s3)),s4);float s=max(1.0-sign(s0*s1*s2*s3*s4)+sign(s5),0.0);s=sign(2.6-length(p))*s;return max(s,0.0);}void main(){vec2 p=(gl_FragCoord.xy/resolution.xy);vec2 o=p*2.0-1.0;float t=progress*1.4;float c1=star(o,t);float c2=star(o,t-0.1);float border=max(c1-c2,0.0);gl_FragColor=mix(texture2D(from,p),texture2D(to,p),c1)+vec4(border,border,border,0.0);}"},{id:"5a4d1fb6711076d17e2e",name:"morph",owner:"paniq",uniforms:{},html_url:"https://gist.github.com/5a4d1fb6711076d17e2e",created_at:"2014-07-01T04:52:25Z",updated_at:"2015-04-06T02:55:11Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;const float strength=0.1;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec4 ca=texture2D(from,p);vec4 cb=texture2D(to,p);vec2 oa=(((ca.rg+ca.b)*0.5)*2.0-1.0);vec2 ob=(((cb.rg+cb.b)*0.5)*2.0-1.0);vec2 oc=mix(oa,ob,0.5)*strength;float w0=progress;float w1=1.0-w0;gl_FragColor=mix(texture2D(from,p+oc*w0),texture2D(to,p-oc*w1),progress);}"},{id:"00973cee8e0353c73305",name:"LumaWipe",owner:"rectalogic",uniforms:{lumaTex:"conical-asym.png",invertLuma:!0,softness:.25},html_url:"https://gist.github.com/00973cee8e0353c73305",created_at:"2014-06-17T02:11:27Z",updated_at:"2015-04-06T02:58:31Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform sampler2D lumaTex;uniform bool invertLuma;uniform float softness;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float luma=texture2D(lumaTex,p).x;if(invertLuma) luma=1.0-luma;vec4 fromColor=texture2D(from,p);vec4 toColor=texture2D(to,p);float time=mix(0.0,1.0+softness,progress);if(luma<=time-softness) gl_FragColor=toColor;else if(luma>=time) gl_FragColor=fromColor;else{float alpha=(time-luma)/softness;gl_FragColor=mix(fromColor,toColor,alpha);}}"},{id:"0141a38779af3a652c22",name:"simple luma",owner:"gre",uniforms:{luma:"spiral-1.png"},html_url:"https://gist.github.com/0141a38779af3a652c22",created_at:"2014-06-13T08:16:10Z",updated_at:"2015-04-06T02:58:48Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform sampler2D luma;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),step(texture2D(luma,p).r,progress));}"},{id:"ee15128c2b87d0e74dee",name:"cube",owner:"gre",uniforms:{persp:.7,unzoom:.3,reflection:.4,floating:3},html_url:"https://gist.github.com/ee15128c2b87d0e74dee",created_at:"2014-06-12T17:13:17Z",updated_at:"2015-04-06T03:00:01Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float persp;uniform float unzoom;uniform float reflection;uniform float floating;vec2 project(vec2 p){return p*vec2(1.0,-1.2)+vec2(0.0,-floating/100.);}bool inBounds(vec2 p){return all(lessThan(vec2(0.0),p))&&all(lessThan(p,vec2(1.0)));}vec4 bgColor(vec2 p,vec2 pfr,vec2 pto){vec4 c=vec4(0.0,0.0,0.0,1.0);pfr=project(pfr);if(inBounds(pfr)){c+=mix(vec4(0.0),texture2D(from,pfr),reflection*mix(1.0,0.0,pfr.y));}pto=project(pto);if(inBounds(pto)){c+=mix(vec4(0.0),texture2D(to,pto),reflection*mix(1.0,0.0,pto.y));}return c;}vec2 xskew(vec2 p,float persp,float center){float x=mix(p.x,1.0-p.x,center);return ((vec2(x,(p.y-0.5*(1.0-persp)*x)/(1.0+(persp-1.0)*x))-vec2(0.5-distance(center,0.5),0.0))*vec2(0.5/distance(center,0.5)*(center<0.5?1.0:-1.0),1.0)+vec2(center<0.5?0.0:1.0,0.0));}void main(){vec2 op=gl_FragCoord.xy/resolution.xy;float uz=unzoom*2.0*(0.5-distance(0.5,progress));vec2 p=-uz*0.5+(1.0+uz)*op;vec2 fromP=xskew((p-vec2(progress,0.0))/vec2(1.0-progress,1.0),1.0-mix(progress,0.0,persp),0.0);vec2 toP=xskew(p/vec2(progress,1.0),mix(pow(progress,2.0),1.0,persp),1.0);if(inBounds(fromP)){gl_FragColor=texture2D(from,fromP);}else if(inBounds(toP)){gl_FragColor=texture2D(to,toP);}else{gl_FragColor=bgColor(op,fromP,toP);}}"},{id:"9b99fc01fd5705008a5b",name:"Glitch Memories",owner:"niseh",uniforms:{},html_url:"https://gist.github.com/9b99fc01fd5705008a5b",created_at:"2014-05-29T19:32:52Z",updated_at:"2015-04-06T02:59:20Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void glitch_memories(sampler2D pic){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 block=floor(gl_FragCoord.xy/vec2(16));vec2 uv_noise=block/vec2(64);uv_noise+=floor(vec2(progress)*vec2(1200.0,3500.0))/vec2(64);float block_thresh=pow(fract(progress*1200.0),2.0)*0.2;float line_thresh=pow(fract(progress*2200.0),3.0)*0.7;vec2 red=p,green=p,blue=p,o=p;vec2 dist=(fract(uv_noise)-0.5)*0.3;red+=dist*0.1;green+=dist*0.2;blue+=dist*0.125;gl_FragColor.r=texture2D(pic,red).r;gl_FragColor.g=texture2D(pic,green).g;gl_FragColor.b=texture2D(pic,blue).b;gl_FragColor.a=1.0;}void main(void){float smoothed=smoothstep(0.,1.,progress);if((smoothed<0.4&&smoothed>0.1)){glitch_memories(from);}else if((smoothed>0.6&&smoothed<0.9)){glitch_memories(to);}else{vec2 p=gl_FragCoord.xy/resolution.xy;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),progress);}}"},{id:"fe67b3b5149738069537",name:"potleaf",owner:"Flexi23",uniforms:{},html_url:"https://gist.github.com/fe67b3b5149738069537",created_at:"2014-05-28T09:58:30Z",updated_at:"2015-04-06T02:58:24Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(){vec2 uv=gl_FragCoord.xy/resolution.xy;vec2 leaf_uv=(uv-vec2(0.5))/10./pow(progress,3.5);leaf_uv.y+=0.35;float r=0.18;float o=atan(leaf_uv.y,leaf_uv.x);gl_FragColor=mix(texture2D(from,uv),texture2D(to,uv),1.-step(1.-length(leaf_uv)+r*(1.+sin(o))*(1.+0.9*cos(8.*o))*(1.+0.1*cos(24.*o))*(0.9+0.05*cos(200.*o)),1.));}"},{id:"b86b90161503a0023231",name:"CrossZoom",owner:"rectalogic",uniforms:{strength:.4},html_url:"https://gist.github.com/b86b90161503a0023231",created_at:"2014-05-25T01:24:39Z",updated_at:"2015-04-06T02:59:37Z",stars:2,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float strength;const float PI=3.141592653589793;float Linear_ease(in float begin,in float change,in float duration,in float time){return change*time/duration+begin;}float Exponential_easeInOut(in float begin,in float change,in float duration,in float time){if(time==0.0) return begin;else if(time==duration) return begin+change;time=time/(duration/2.0);if(time<1.0) return change/2.0*pow(2.0,10.0*(time-1.0))+begin;return change/2.0*(-pow(2.0,-10.0*(time-1.0))+2.0)+begin;}float Sinusoidal_easeInOut(in float begin,in float change,in float duration,in float time){return -change/2.0*(cos(PI*time/duration)-1.0)+begin;}float random(in vec3 scale,in float seed){return fract(sin(dot(gl_FragCoord.xyz+seed,scale))*43758.5453+seed);}vec3 crossFade(in vec2 uv,in float dissolve){return mix(texture2D(from,uv).rgb,texture2D(to,uv).rgb,dissolve);}void main(){vec2 texCoord=gl_FragCoord.xy/resolution.xy;vec2 center=vec2(Linear_ease(0.25,0.5,1.0,progress),0.5);float dissolve=Exponential_easeInOut(0.0,1.0,1.0,progress);float strength=Sinusoidal_easeInOut(0.0,strength,0.5,progress);vec3 color=vec3(0.0);float total=0.0;vec2 toCenter=center-texCoord;float offset=random(vec3(12.9898,78.233,151.7182),0.0);for(float t=0.0;t<=40.0;t++){float percent=(t+offset)/40.0;float weight=4.0*(percent-percent*percent);color+=crossFade(texCoord+toCenter*percent*strength,dissolve)*weight;total+=weight;}gl_FragColor=vec4(color/total,1.0);}"},{id:"ce9279de351984f0ad27",name:"Slide",owner:"rectalogic",uniforms:{translateX:1,translateY:0},html_url:"https://gist.github.com/ce9279de351984f0ad27",created_at:"2014-05-25T01:13:20Z",updated_at:"2015-04-06T02:59:55Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float translateX;uniform float translateY;void main(){vec2 texCoord=gl_FragCoord.xy/resolution.xy;float x=progress*translateX;float y=progress*translateY;if(x>=0.0&&y>=0.0){if(texCoord.x>=x&&texCoord.y>=y){gl_FragColor=texture2D(from,texCoord-vec2(x,y));}else{vec2 uv;if(x>0.0) uv=vec2(x-1.0,y);else if(y>0.0) uv=vec2(x,y-1.0);gl_FragColor=texture2D(to,texCoord-uv);}}else if(x<=0.0&&y<=0.0){if(texCoord.x<=(1.0+x)&&texCoord.y<=(1.0+y)) gl_FragColor=texture2D(from,texCoord-vec2(x,y));else{vec2 uv;if(x<0.0) uv=vec2(x+1.0,y);else if(y<0.0) uv=vec2(x,y+1.0);gl_FragColor=texture2D(to,texCoord-uv);}}else gl_FragColor=vec4(0.0);}"},{id:"154a99fbe5300fb5c279",name:"pinwheel",owner:"mrspeaker",uniforms:{},html_url:"https://gist.github.com/154a99fbe5300fb5c279",created_at:"2014-05-23T21:56:59Z",updated_at:"2015-04-06T03:00:00Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float circPos=atan(p.y-0.5,p.x-0.5)+progress;float modPos=mod(circPos,3.1415/4.);float signed=sign(progress-modPos);float smoothed=smoothstep(0.,1.,signed);if(smoothed>0.5){gl_FragColor=texture2D(to,p);}else{gl_FragColor=texture2D(from,p);}}"},{id:"e54a807cdb66c8b16a34",name:"Kaleidoscope",owner:"nwoeanhinnogaehr",uniforms:{speed:1,angle:2,power:2},html_url:"https://gist.github.com/e54a807cdb66c8b16a34",created_at:"2014-05-23T19:02:46Z",updated_at:"2015-04-06T02:55:53Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float speed;uniform float angle;uniform float power;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 q=p;float t=pow(progress,power)*speed;p=p-0.5;for(int i=0;i<7;i++){p=vec2(sin(t)*p.x+cos(t)*p.y,sin(t)*p.y-cos(t)*p.x);t+=angle;p=abs(mod(p,2.0)-1.0);}abs(mod(p,1.0));gl_FragColor=mix(mix(texture2D(from,q),texture2D(to,q),progress),mix(texture2D(from,p),texture2D(to,p),progress),1.0-2.0*abs(progress-0.5));}"},{id:"408045772d255df97520",name:"SimpleFlip",owner:"nwoeanhinnogaehr",uniforms:{},html_url:"https://gist.github.com/408045772d255df97520",created_at:"2014-05-23T18:42:58Z",updated_at:"2015-04-06T02:55:54Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 q=p;p.x=(p.x-0.5)/abs(progress-0.5)*0.5+0.5;vec4 a=texture2D(from,p);vec4 b=texture2D(to,p);gl_FragColor=vec4(mix(a,b,step(0.5,progress)).rgb*step(abs(q.x-0.5),abs(progress-0.5)),1.0);}"},{id:"a070cbd69e2535e757f1",name:"DoomScreenTransition",owner:"zeh",uniforms:{barWidth:10,noise:.2,amplitude:2,frequency:1},html_url:"https://gist.github.com/a070cbd69e2535e757f1",created_at:"2014-05-23T18:00:18Z",updated_at:"2015-04-06T02:51:48Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform int barWidth;uniform float amplitude;uniform float noise;uniform float frequency;float rand(int num){return fract(mod(float(num)*67123.313,12.0)*sin(float(num)*10.3)*cos(float(num)));}float wave(int num){float fn=float(num)*frequency*0.1*float(barWidth);return cos(fn*0.5)*cos(fn*0.13)*sin((fn+10.0)*0.3)/2.0+0.5;}float pos(int num){return noise==0.0?wave(num):mix(wave(num),rand(num),noise);}void main(){int bar=int(gl_FragCoord.x)/barWidth;float scale=1.0+pos(bar)*amplitude;float phase=progress*scale;float posY=gl_FragCoord.y/resolution.y;vec2 p;vec4 c;if(phase+posY<1.0){p=vec2(gl_FragCoord.x,gl_FragCoord.y+mix(0.0,resolution.y,phase))/resolution.xy;c=texture2D(from,p);}else{p=gl_FragCoord.xy/resolution.xy;c=texture2D(to,p);}gl_FragColor=c;}"},{id:"a830822b23e846e25d2d",name:"DreamyZoom",owner:"zeh",uniforms:{rotation:6,scale:1.2},html_url:"https://gist.github.com/a830822b23e846e25d2d",created_at:"2014-05-23T15:27:25Z",updated_at:"2015-04-06T02:54:39Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define DEG2RAD 0.03926990816987241548078304229099 // 1/180*PI\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float rotation;uniform float scale;void main(){float phase=progress<0.5?progress*2.0:(progress-0.5)*2.0;float angleOffset=progress<0.5?mix(0.0,rotation*DEG2RAD,phase):mix(-rotation*DEG2RAD,0.0,phase);float newScale=progress<0.5?mix(1.0,scale,phase):mix(scale,1.0,phase);vec2 center=vec2(0,0);float maxRes=max(resolution.x,resolution.y);float resX=resolution.x/maxRes*0.5;float resY=resolution.y/maxRes*0.5;vec2 p=(gl_FragCoord.xy/maxRes-vec2(resX,resY))/newScale;float angle=atan(p.y,p.x)+angleOffset;float dist=distance(center,p);p.x=cos(angle)*dist+resX;p.y=sin(angle)*dist+resY;vec4 c=progress<0.5?texture2D(from,p):texture2D(to,p);gl_FragColor=c+(progress<0.5?mix(0.0,1.0,phase):mix(1.0,0.0,phase));}"},{id:"b6720916aa3f035949bc",name:"squareswipe",owner:"gre",uniforms:{squares:[10,10],direction:[1,-.5],smoothness:1.6},html_url:"https://gist.github.com/b6720916aa3f035949bc",created_at:"2014-05-23T12:09:38Z",updated_at:"2015-04-06T02:56:48Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform ivec2 squares;uniform vec2 direction;uniform float smoothness;const vec2 center=vec2(0.5,0.5);void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 v=normalize(direction);if(v!=vec2(0.0)) v/=abs(v.x)+abs(v.y);float d=v.x*center.x+v.y*center.y;float offset=smoothness;float pr=smoothstep(-offset,0.0,v.x*p.x+v.y*p.y-(d-0.5+progress*(1.+offset)));vec2 squarep=fract(p*vec2(squares));vec2 squaremin=vec2(pr/2.0);vec2 squaremax=vec2(1.0-pr/2.0);float a=all(lessThan(squaremin,squarep))&&all(lessThan(squarep,squaremax))?1.0:0.0;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),a);}"},{id:"169781bb76f310e2bfde",name:"TilesWaveBottomLeftToTopRight",owner:"numb3r23",uniforms:{},html_url:"https://gist.github.com/169781bb76f310e2bfde",created_at:"2014-05-21T22:50:48Z",updated_at:"2015-04-06T02:52:49Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;const vec2 tileSize=vec2(64,64);const float checkerDistance=0.015;const bool flipX=true;const bool flipY=false;const bool preTileSingleColor=false;const bool postTileSingleColor=false;vec2 tile2Global(vec2 tex,vec2 tileNum,bool tileSingleColor){vec2 perTile=tileSize/resolution.xy;return tileNum*perTile+(tileSingleColor?vec2(0):tex*perTile);}void main(void){vec2 uv=gl_FragCoord.xy/resolution.xy;vec4 fragColor=vec4(1,1,0,1);vec2 posInTile=mod(vec2(gl_FragCoord),tileSize);vec2 tileNum=floor(vec2(gl_FragCoord)/tileSize);int num=int(tileNum.x);vec2 totalTiles=ceil(resolution.xy/tileSize);float countTiles=totalTiles.x*totalTiles.y;vec2 perTile=ceil(tileSize/resolution.xy);float offset=0.0;offset=(tileNum.y+tileNum.x*perTile.y)/(sqrt(countTiles)*2.0);float timeOffset=(progress-offset)*countTiles;timeOffset=clamp(timeOffset,0.0,0.5);float sinTime=1.0-abs(cos(fract(timeOffset)*3.1415926));fragColor.rg=uv;fragColor.b=sinTime;vec2 texC=posInTile/tileSize;if(sinTime<=0.5){if(flipX){if((texC.x1.0-sinTime)){discard;}if(texC.x<0.5){texC.x=(texC.x-sinTime)*0.5/(0.5-sinTime);}else{texC.x=(texC.x-0.5)*0.5/(0.5-sinTime)+0.5;}}if(flipY){if((texC.y1.0-sinTime)){discard;}if(texC.y<0.5){texC.y=(texC.y-sinTime)*0.5/(0.5-sinTime);}else{texC.y=(texC.y-0.5)*0.5/(0.5-sinTime)+0.5;}}fragColor=texture2D(from,tile2Global(texC,tileNum,preTileSingleColor));}else{if(flipX){if((texC.x>sinTime)||(texC.x<1.0-sinTime)){discard;}if(texC.x<0.5){texC.x=(texC.x-sinTime)*0.5/(0.5-sinTime);}else{texC.x=(texC.x-0.5)*0.5/(0.5-sinTime)+0.5;}texC.x=1.0-texC.x;}if(flipY){if((texC.y>sinTime)||(texC.y<1.0-sinTime)){discard;}if(texC.y<0.5){texC.y=(texC.y-sinTime)*0.5/(0.5-sinTime);}else{texC.y=(texC.y-0.5)*0.5/(0.5-sinTime)+0.5;}texC.y=1.0-texC.y;}fragColor.rgb=texture2D(to,tile2Global(texC,tileNum,postTileSingleColor)).rgb;}gl_FragColor=fragColor;}"},{id:"5ebd3442a208861c7a8a",name:"TilesScanline",owner:"numb3r23",uniforms:{},html_url:"https://gist.github.com/5ebd3442a208861c7a8a",created_at:"2014-05-21T22:49:22Z",updated_at:"2015-04-06T02:57:17Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;const vec2 tileSize=vec2(64,64);const float checkerDistance=0.015;const bool flipX=true;const bool flipY=false;const bool preTileSingleColor=false;const bool postTileSingleColor=false;vec2 tile2Global(vec2 tex,vec2 tileNum,bool tileSingleColor){vec2 perTile=tileSize/resolution.xy;return tileNum*perTile+(tileSingleColor?vec2(0):tex*perTile);}void main(void){vec2 uv=gl_FragCoord.xy/resolution.xy;vec4 fragColor=vec4(1,1,0,1);vec2 posInTile=mod(vec2(gl_FragCoord),tileSize);vec2 tileNum=floor(vec2(gl_FragCoord)/tileSize);int num=int(tileNum.x);vec2 totalTiles=ceil(resolution.xy/tileSize);float countTiles=totalTiles.x*totalTiles.y;vec2 perTile=ceil(tileSize/resolution.xy);float offset=0.0;offset=(tileNum.x+tileNum.y*totalTiles.x)/countTiles;float timeOffset=(progress-offset)*countTiles;timeOffset=clamp(timeOffset,0.0,0.5);float sinTime=1.0-abs(cos(fract(timeOffset)*3.1415926));fragColor.rg=uv;fragColor.b=sinTime;vec2 texC=posInTile/tileSize;if(sinTime<=0.5){if(flipX){if((texC.x1.0-sinTime)){discard;}if(texC.x<0.5){texC.x=(texC.x-sinTime)*0.5/(0.5-sinTime);}else{texC.x=(texC.x-0.5)*0.5/(0.5-sinTime)+0.5;}}if(flipY){if((texC.y1.0-sinTime)){discard;}if(texC.y<0.5){texC.y=(texC.y-sinTime)*0.5/(0.5-sinTime);}else{texC.y=(texC.y-0.5)*0.5/(0.5-sinTime)+0.5;}}fragColor=texture2D(from,tile2Global(texC,tileNum,preTileSingleColor));}else{if(flipX){if((texC.x>sinTime)||(texC.x<1.0-sinTime)){discard;}if(texC.x<0.5){texC.x=(texC.x-sinTime)*0.5/(0.5-sinTime);}else{texC.x=(texC.x-0.5)*0.5/(0.5-sinTime)+0.5;}texC.x=1.0-texC.x;}if(flipY){if((texC.y>sinTime)||(texC.y<1.0-sinTime)){discard;}if(texC.y<0.5){texC.y=(texC.y-sinTime)*0.5/(0.5-sinTime);}else{texC.y=(texC.y-0.5)*0.5/(0.5-sinTime)+0.5;}texC.y=1.0-texC.y;}fragColor.rgb=texture2D(to,tile2Global(texC,tileNum,postTileSingleColor)).rgb;}gl_FragColor=fragColor;}"},{id:"9e86d2712e123542758b",name:"Dreamy",owner:"mikolalysenko",uniforms:{},html_url:"https://gist.github.com/9e86d2712e123542758b",created_at:"2014-05-21T14:55:01Z",updated_at:"2015-04-06T02:56:18Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;vec2 offset(float progress,float x,float theta){float phase=progress*progress+progress+theta;float shifty=0.03*progress*cos(10.0*(progress+x));return vec2(0,shifty);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;gl_FragColor=mix(texture2D(from,p+offset(progress,p.x,0.0)),texture2D(to,p+offset(1.0-progress,p.x,3.14)),progress);}"},{id:"21d2fdd24c706952dc8c",name:"AdvancedMosaic",owner:"corporateshark",uniforms:{},html_url:"https://gist.github.com/21d2fdd24c706952dc8c",created_at:"2014-05-21T14:45:52Z",updated_at:"2015-04-06T02:58:57Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(void){vec2 p=gl_FragCoord.xy/resolution.xy;float T=progress;float S0=1.0;float S1=50.0;float S2=1.0;float Half=0.5;float PixelSize=(Tprogress?fTex:tTex,tTex,pow(progress,interpolationPower));}"},{id:"b93818de23d4511fde10",name:"Dissolve",owner:"nwoeanhinnogaehr",uniforms:{blocksize:1},html_url:"https://gist.github.com/b93818de23d4511fde10",created_at:"2014-05-20T23:40:57Z",updated_at:"2015-04-06T03:00:06Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float blocksize;float rand(vec2 co){return fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;gl_FragColor=mix(texture2D(from,p),texture2D(to,p),step(rand(floor(gl_FragCoord.xy/blocksize)),progress));}"},{id:"b185145363d65751009b",name:"HSVfade",owner:"nwoeanhinnogaehr",uniforms:{},html_url:"https://gist.github.com/b185145363d65751009b",created_at:"2014-05-20T23:21:27Z",updated_at:"2015-04-06T02:58:24Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;vec3 hsv2rgb(vec3 c){const vec4 K=vec4(1.0,2.0/3.0,1.0/3.0,3.0);vec3 p=abs(fract(c.xxx+K.xyz)*6.0-K.www);return c.z*mix(K.xxx,clamp(p-K.xxx,0.0,1.0),c.y);}vec3 rgb2hsv(vec3 c){const vec4 K=vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);vec4 p=mix(vec4(c.bg,K.wz),vec4(c.gb,K.xy),step(c.b,c.g));vec4 q=mix(vec4(p.xyw,c.r),vec4(c.r,p.yzx),step(p.x,c.r));float d=q.x-min(q.w,q.y);return vec3(abs(q.z+(q.w-q.y)/(6.0*d+0.001)),d/(q.x+0.001),q.x);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec3 a=rgb2hsv(texture2D(from,p).rgb);vec3 b=rgb2hsv(texture2D(to,p).rgb);vec3 m=mix(a,b,progress);gl_FragColor=vec4(hsv2rgb(m),1.0);}"},{id:"f6fc39f4cfcbb97f96a6",name:"Fold",owner:"nwoeanhinnogaehr",uniforms:{},html_url:"https://gist.github.com/f6fc39f4cfcbb97f96a6",created_at:"2014-05-20T23:14:23Z",updated_at:"2015-04-06T02:57:16Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec4 a=texture2D(from,(p-vec2(progress,0.0))/vec2(1.0-progress,1.0));vec4 b=texture2D(to,p/vec2(progress,1.0));gl_FragColor=mix(a,b,step(p.x,progress));}"},{id:"80c2d40cac3f98453176",name:"linearblur",owner:"gre",uniforms:{intensity:.1},html_url:"https://gist.github.com/80c2d40cac3f98453176",created_at:"2014-05-20T22:02:35Z",updated_at:"2015-04-06T02:56:20Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float intensity;const int PASSES=8;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec4 c1=vec4(0.0),c2=vec4(0.0);float disp=intensity*(0.5-distance(0.5,progress));for(int xi=0;xi2.0) return color1;float dd=pow(1.0-distanc/2.0,sharpness);return ((color2-color1)*dd)+color1;}float distanceToEdge(vec3 point){float dx=abs(point.x>0.5?1.0-point.x:point.x);float dy=abs(point.y>0.5?1.0-point.y:point.y);if(point.x<0.0) dx=-point.x;if(point.x>1.0) dx=point.x-1.0;if(point.y<0.0) dy=-point.y;if(point.y>1.0) dy=point.y-1.0;if((point.x<0.0||point.x>1.0)&&(point.y<0.0||point.y>1.0)) return sqrt(dx*dx+dy*dy);return min(dx,dy);}vec4 seeThrough(float yc,vec2 p,mat3 rotation,mat3 rrotation){float hitAngle=PI-(acos(yc/cylinderRadius)-cylinderAngle);vec3 point=hitPoint(hitAngle,yc,rotation*vec3(p,1.0),rrotation);if(yc<=0.0&&(point.x<0.0||point.y<0.0||point.x>1.0||point.y>1.0)){vec2 texCoord=gl_FragCoord.xy/resolution.xy;return texture2D(to,texCoord);}if(yc>0.0) return texture2D(from,p);vec4 color=texture2D(from,point.xy);vec4 tcolor=vec4(0.0);return antiAlias(color,tcolor,distanceToEdge(point));}vec4 seeThroughWithShadow(float yc,vec2 p,vec3 point,mat3 rotation,mat3 rrotation){float shadow=distanceToEdge(point)*30.0;shadow=(1.0-shadow)/3.0;if(shadow<0.0) shadow=0.0;else shadow*=amount;vec4 shadowColor=seeThrough(yc,p,rotation,rrotation);shadowColor.r-=shadow;shadowColor.g-=shadow;shadowColor.b-=shadow;return shadowColor;}vec4 backside(float yc,vec3 point){vec4 color=texture2D(from,point.xy);float gray=(color.r+color.b+color.g)/15.0;gray+=(8.0/10.0)*(pow(1.0-abs(yc/cylinderRadius),2.0/10.0)/2.0+(5.0/10.0));color.rgb=vec3(gray);return color;}vec4 behindSurface(float yc,vec3 point,mat3 rrotation){float shado=(1.0-((-cylinderRadius-yc)/amount*7.0))/6.0;shado*=1.0-abs(point.x-0.5);yc=(-cylinderRadius-cylinderRadius-yc);float hitAngle=(acos(yc/cylinderRadius)+cylinderAngle)-PI;point=hitPoint(hitAngle,yc,point,rrotation);if(yc<0.0&&point.x>=0.0&&point.y>=0.0&&point.x<=1.0&&point.y<=1.0&&(hitAngle0.5)){shado=1.0-(sqrt(pow(point.x-0.5,2.0)+pow(point.y-0.5,2.0))/(71.0/100.0));shado*=pow(-yc/cylinderRadius,3.0);shado*=0.5;}else{shado=0.0;}vec2 texCoord=gl_FragCoord.xy/resolution.xy;return vec4(texture2D(to,texCoord).rgb-shado,1.0);}void main(){vec2 texCoord=gl_FragCoord.xy/resolution.xy;const float angle=30.0*PI/180.0;float c=cos(-angle);float s=sin(-angle);mat3 rotation=mat3(c,s,0,-s,c,0,0.12,0.258,1);c=cos(angle);s=sin(angle);mat3 rrotation=mat3(c,s,0,-s,c,0,0.15,-0.5,1);vec3 point=rotation*vec3(texCoord,1.0);float yc=point.y-cylinderCenter;if(yc<-cylinderRadius){gl_FragColor=behindSurface(yc,point,rrotation);return;}if(yc>cylinderRadius){gl_FragColor=texture2D(from,texCoord);return;}float hitAngle=(acos(yc/cylinderRadius)+cylinderAngle)-PI;float hitAngleMod=mod(hitAngle,2.0*PI);if((hitAngleMod>PI&&amount<0.5)||(hitAngleMod>PI/2.0&&amount<0.0)){gl_FragColor=seeThrough(yc,texCoord,rotation,rrotation);return;}point=hitPoint(hitAngle,yc,point,rrotation);if(point.x<0.0||point.y<0.0||point.x>1.0||point.y>1.0){gl_FragColor=seeThroughWithShadow(yc,texCoord,point,rotation,rrotation);return;}vec4 color=backside(yc,point);vec4 otherColor;if(yc<0.0){float shado=1.0-(sqrt(pow(point.x-0.5,2.0)+pow(point.y-0.5,2.0))/0.71);shado*=pow(-yc/cylinderRadius,3.0);shado*=0.5;otherColor=vec4(0.0,0.0,0.0,shado);}else{otherColor=texture2D(from,texCoord);}color=antiAlias(color,otherColor,cylinderRadius-abs(yc));vec4 cl=seeThroughWithShadow(yc,texCoord,point,rotation,rrotation);float dist=distanceToEdge(point);gl_FragColor=antiAlias(color,cl,dist);}"
5 | },{id:"06450f79cab706705bf9",name:"Polka_dots",owner:"bobylito",uniforms:{dots:5},html_url:"https://gist.github.com/06450f79cab706705bf9",created_at:"2014-05-20T12:09:38Z",updated_at:"2015-04-06T02:55:49Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float dots;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float x=progress;bool nextImage=distance(fract(p*dots),vec2(0.5,0.5)).5){gl_FragColor=texture2D(to,mrp);}else{gl_FragColor=texture2D(from,mrp);}}"},{id:"ce1d48f0ce00bb379750",name:"Radial",owner:"Xaychru",uniforms:{},html_url:"https://gist.github.com/ce1d48f0ce00bb379750",created_at:"2014-05-19T15:18:28Z",updated_at:"2015-04-06T02:59:31Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define PI 3.141592653589\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 rp=p*2.-1.;float a=atan(rp.y,rp.x);float pa=progress*PI*2.5-PI*1.25;vec4 fromc=texture2D(from,p);vec4 toc=texture2D(to,p);if(a>pa){gl_FragColor=mix(toc,fromc,smoothstep(0.,1.,(a-pa)));}else{gl_FragColor=toc;}}"},{id:"c3bc914de09227713787",name:"ButterflyWaveScrawler",owner:"mandubian",uniforms:{amplitude:1,waves:30,colorSeparation:.3},html_url:"https://gist.github.com/c3bc914de09227713787",created_at:"2014-05-19T11:48:15Z",updated_at:"2015-04-06T02:59:13Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float amplitude;uniform float waves;uniform float colorSeparation;float PI=3.14159265358979323846264;float compute(vec2 p,float progress,vec2 center){vec2 o=p*sin(progress*amplitude)-center;vec2 h=vec2(1.,0.);float theta=acos(dot(o,h))*waves;return (exp(cos(theta))-2.*cos(4.*theta)+pow(sin((2.*theta-PI)/24.),5.))/10.;}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float inv=1.-progress;vec2 dir=p-vec2(.5);float dist=length(dir);float disp=compute(p,progress,vec2(0.5,0.5));vec4 texTo=texture2D(to,p+inv*disp);vec4 texFrom=vec4(texture2D(from,p+progress*disp*(1.0-colorSeparation)).r,texture2D(from,p+progress*disp).g,texture2D(from,p+progress*disp*(1.0+colorSeparation)).b,1.0);gl_FragColor=texTo*progress+texFrom*inv;}"},{id:"4268c81d39bd4ca00ae2",name:"CrazyParametricFun",owner:"mandubian",uniforms:{a:4,b:1,amplitude:120,smoothness:.1},html_url:"https://gist.github.com/4268c81d39bd4ca00ae2",created_at:"2014-05-19T08:04:52Z",updated_at:"2015-04-06T02:56:12Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float a;uniform float b;uniform float amplitude;uniform float smoothness;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 dir=p-vec2(.5);float dist=length(dir);float x=(a-b)*cos(progress)+b*cos(progress*((a/b)-1.));float y=(a-b)*sin(progress)-b*sin(progress*((a/b)-1.));vec2 offset=dir*vec2(sin(progress*dist*amplitude*x),sin(progress*dist*amplitude*y))/smoothness;gl_FragColor=mix(texture2D(from,p+offset),texture2D(to,p),smoothstep(0.2,1.0,progress));}"},{id:"2bcfb59096fcaed82355",name:"powerdisformation",owner:"gre",uniforms:{power:3,powerDest:!0},html_url:"https://gist.github.com/2bcfb59096fcaed82355",created_at:"2014-05-17T10:58:29Z",updated_at:"2015-04-06T02:59:28Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from,to;uniform float progress;uniform vec2 resolution;uniform float power;uniform bool powerDest;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 p2=mix(p,vec2(pow(p.x,power),pow(p.y,power)),(powerDest?0.5:1.0)-distance(progress,powerDest?0.5:1.0));gl_FragColor=mix(texture2D(from,p2),texture2D(to,powerDest?p2:p),progress);}"},{id:"2a3f2e907e1c0a152e60",name:"swap",owner:"gre",uniforms:{reflection:.4,perspective:.2,depth:3},html_url:"https://gist.github.com/2a3f2e907e1c0a152e60",created_at:"2014-05-16T13:59:07Z",updated_at:"2015-04-06T02:54:44Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float reflection;uniform float perspective;uniform float depth;const vec4 black=vec4(0.0,0.0,0.0,1.0);const vec2 boundMin=vec2(0.0,0.0);const vec2 boundMax=vec2(1.0,1.0);bool inBounds(vec2 p){return all(lessThan(boundMin,p))&&all(lessThan(p,boundMax));}vec2 project(vec2 p){return p*vec2(1.0,-1.2)+vec2(0.0,-0.02);}vec4 bgColor(vec2 p,vec2 pfr,vec2 pto){vec4 c=black;pfr=project(pfr);if(inBounds(pfr)){c+=mix(black,texture2D(from,pfr),reflection*mix(1.0,0.0,pfr.y));}pto=project(pto);if(inBounds(pto)){c+=mix(black,texture2D(to,pto),reflection*mix(1.0,0.0,pto.y));}return c;}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 pfr,pto=vec2(-1.);float size=mix(1.0,depth,progress);float persp=perspective*progress;pfr=(p+vec2(-0.0,-0.5))*vec2(size/(1.0-perspective*progress),size/(1.0-size*persp*p.x))+vec2(0.0,0.5);size=mix(1.0,depth,1.-progress);persp=perspective*(1.-progress);pto=(p+vec2(-1.0,-0.5))*vec2(size/(1.0-perspective*(1.0-progress)),size/(1.0-size*persp*(0.5-p.x)))+vec2(1.0,0.5);bool fromOver=progress<0.5;if(fromOver){if(inBounds(pfr)){gl_FragColor=texture2D(from,pfr);}else if(inBounds(pto)){gl_FragColor=texture2D(to,pto);}else{gl_FragColor=bgColor(p,pfr,pto);}}else{if(inBounds(pto)){gl_FragColor=texture2D(to,pto);}else if(inBounds(pfr)){gl_FragColor=texture2D(from,pfr);}else{gl_FragColor=bgColor(p,pfr,pto);}}}"},{id:"94ffa2725b65aa8b9979",name:"ripple",owner:"gre",uniforms:{amplitude:100,speed:50},html_url:"https://gist.github.com/94ffa2725b65aa8b9979",created_at:"2014-05-16T13:58:42Z",updated_at:"2015-04-06T02:53:18Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float amplitude;uniform float speed;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 dir=p-vec2(.5);float dist=length(dir);vec2 offset=dir*(sin(progress*dist*amplitude-progress*speed)+.5)/30.;gl_FragColor=mix(texture2D(from,p+offset),texture2D(to,p),smoothstep(0.2,1.0,progress));}"},{id:"99bced7d9b5311fd166e",name:"flash",owner:"gre",uniforms:{flashPhase:.3,flashIntensity:3,flashZoomEffect:.5},html_url:"https://gist.github.com/99bced7d9b5311fd166e",created_at:"2014-05-16T13:58:17Z",updated_at:"2015-04-06T02:52:58Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float flashPhase;uniform float flashIntensity;uniform float flashZoomEffect;const vec3 flashColor=vec3(1.0,0.8,0.3);const float flashVelocity=3.0;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec4 fc=texture2D(from,p);vec4 tc=texture2D(to,p);float intensity=mix(1.0,2.0*distance(p,vec2(0.5,0.5)),flashZoomEffect)*flashIntensity*pow(smoothstep(flashPhase,0.0,distance(0.5,progress)),flashVelocity);vec4 c=mix(texture2D(from,p),texture2D(to,p),smoothstep(0.5*(1.0-flashPhase),0.5*(1.0+flashPhase),progress));c+=intensity*vec4(flashColor,1.0);gl_FragColor=c;}"},{id:"81c6f2e6fce88f9075d2",name:"flyeye",owner:"gre",uniforms:{size:.04,zoom:30,colorSeparation:.3},html_url:"https://gist.github.com/81c6f2e6fce88f9075d2",created_at:"2014-05-16T13:56:53Z",updated_at:"2015-04-06T02:56:15Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float size;uniform float zoom;uniform float colorSeparation;void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float inv=1.-progress;vec2 disp=size*vec2(cos(zoom*p.x),sin(zoom*p.y));vec4 texTo=texture2D(to,p+inv*disp);vec4 texFrom=vec4(texture2D(from,p+progress*disp*(1.0-colorSeparation)).r,texture2D(from,p+progress*disp).g,texture2D(from,p+progress*disp*(1.0+colorSeparation)).b,1.0);gl_FragColor=texTo*progress+texFrom*inv;}"},{id:"979934722820b5e715fa",name:"doorway",owner:"gre",uniforms:{reflection:.4,perspective:.4,depth:3},html_url:"https://gist.github.com/979934722820b5e715fa",created_at:"2014-05-16T13:54:38Z",updated_at:"2015-04-06T02:51:25Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float reflection;uniform float perspective;uniform float depth;const vec4 black=vec4(0.0,0.0,0.0,1.0);const vec2 boundMin=vec2(0.0,0.0);const vec2 boundMax=vec2(1.0,1.0);bool inBounds(vec2 p){return all(lessThan(boundMin,p))&&all(lessThan(p,boundMax));}vec2 project(vec2 p){return p*vec2(1.0,-1.2)+vec2(0.0,-0.02);}vec4 bgColor(vec2 p,vec2 pto){vec4 c=black;pto=project(pto);if(inBounds(pto)){c+=mix(black,texture2D(to,pto),reflection*mix(1.0,0.0,pto.y));}return c;}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 pfr=vec2(-1.),pto=vec2(-1.);float middleSlit=2.0*abs(p.x-0.5)-progress;if(middleSlit>0.0){pfr=p+(p.x>0.5?-1.0:1.0)*vec2(0.5*progress,0.0);float d=1.0/(1.0+perspective*progress*(1.0-middleSlit));pfr.y-=d/2.;pfr.y*=d;pfr.y+=d/2.;}float size=mix(1.0,depth,1.-progress);pto=(p+vec2(-0.5,-0.5))*vec2(size,size)+vec2(0.5,0.5);if(inBounds(pfr)){gl_FragColor=texture2D(from,pfr);}else if(inBounds(pto)){gl_FragColor=texture2D(to,pto);}else{gl_FragColor=bgColor(p,pto);}}"},{id:"731fcad4f8956866f34a",name:"randomsquares",owner:"gre",uniforms:{size:[10,10],smoothness:.5},html_url:"https://gist.github.com/731fcad4f8956866f34a",created_at:"2014-05-16T13:52:46Z",updated_at:"2015-04-06T02:58:04Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform ivec2 size;uniform float smoothness;float rand(vec2 co){return fract(sin(dot(co.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float r=rand(floor(vec2(size)*p));float m=smoothstep(0.0,-smoothness,r-(progress*(1.0+smoothness)));gl_FragColor=mix(texture2D(from,p),texture2D(to,p),m);}"},{id:"df8797fd112e8e429064",name:"squeeze",owner:"gre",uniforms:{colorSeparation:.02},html_url:"https://gist.github.com/df8797fd112e8e429064",created_at:"2014-05-16T13:51:39Z",updated_at:"2015-04-06T02:54:05Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float colorSeparation;float progressY(float y){return 0.5+(y-0.5)/(1.0-progress);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float y=progressY(p.y);if(y<0.0||y>1.0){gl_FragColor=texture2D(to,p);}else{vec2 fp=vec2(p.x,y);vec3 c=vec3(texture2D(from,fp-progress*vec2(0.0,colorSeparation)).r,texture2D(from,fp).g,texture2D(from,fp+progress*vec2(0.0,colorSeparation)).b);gl_FragColor=vec4(c,1.0);}}"},{id:"90000743fedc953f11a4",name:"directionalwipe",owner:"gre",uniforms:{direction:[1,-1],smoothness:.5},html_url:"https://gist.github.com/90000743fedc953f11a4",created_at:"2014-05-16T13:50:51Z",updated_at:"2015-04-06T02:57:08Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform vec2 direction;uniform float smoothness;const vec2 center=vec2(0.5,0.5);void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec2 v=normalize(direction);v/=abs(v.x)+abs(v.y);float d=v.x*center.x+v.y*center.y;float m=smoothstep(-smoothness,0.0,v.x*p.x+v.y*p.y-(d-0.5+progress*(1.+smoothness)));gl_FragColor=mix(texture2D(to,p),texture2D(from,p),m);}"},{id:"7de3f4b9482d2b0bf7bb",name:"wind",owner:"gre",uniforms:{size:.2},html_url:"https://gist.github.com/7de3f4b9482d2b0bf7bb",created_at:"2014-05-16T13:49:36Z",updated_at:"2015-04-06T02:56:20Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float size;float rand(vec2 co){return fract(sin(dot(co.xy,vec2(12.9898,78.233)))*43758.5453);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;float r=rand(vec2(0,p.y));float m=smoothstep(0.0,-size,p.x*(1.0-size)+size*r-(progress*(1.0+size)));gl_FragColor=mix(texture2D(from,p),texture2D(to,p),m);}"},{id:"d9f8b4df19584f1f0474",name:"fadegrayscale",owner:"gre",uniforms:{grayPhase:.3},html_url:"https://gist.github.com/d9f8b4df19584f1f0474",created_at:"2014-05-16T13:49:13Z",updated_at:"2015-04-06T02:59:50Z",stars:0,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float grayPhase;vec3 grayscale(vec3 color){return vec3(0.2126*color.r+0.7152*color.g+0.0722*color.b);}void main(){vec2 p=gl_FragCoord.xy/resolution.xy;vec4 fc=texture2D(from,p);vec4 tc=texture2D(to,p);gl_FragColor=mix(mix(vec4(grayscale(fc.rgb),1.0),texture2D(from,p),smoothstep(1.0-grayPhase,0.0,progress)),mix(vec4(grayscale(tc.rgb),1.0),texture2D(to,p),smoothstep(grayPhase,1.0,progress)),progress);}"},{id:"206b96128ad6085f9911",name:"dispersionblur",owner:"gre",uniforms:{size:.6},html_url:"https://gist.github.com/206b96128ad6085f9911",created_at:"2014-05-16T13:47:09Z",updated_at:"2015-04-06T02:57:31Z",stars:1,glsl:"\n#ifdef GL_ES\nprecision highp float;\n#endif\n\n#define QUALITY 32\nuniform sampler2D from;uniform sampler2D to;uniform float progress;uniform vec2 resolution;uniform float size;const float GOLDEN_ANGLE=2.399963229728653;vec4 blur(sampler2D t,vec2 c,float radius){vec4 sum=vec4(0.0);float q=float(QUALITY);for(int i=0;i=Y&&fe>=o}function u(){if(Z)try{throw new Error}catch(e){var t=e.stack.split("\n"),r=t[0].indexOf("@")>0?t[1]:t[2],o=s(r);if(!o)return;return G=o[0],o[1]}}function l(e,t,r){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(t+" is deprecated, use "+r+" instead.",new Error("").stack),e.apply(e,arguments)}}function c(e){return e instanceof g?e:_(e)?S(e):D(e)}function p(){function e(e){t=e,i.source=e,K(r,function(t,r){c.nextTick(function(){e.promiseDispatch.apply(e,r)})},void 0),r=void 0,o=void 0}var t,r=[],o=[],n=ee(p.prototype),i=ee(g.prototype);if(i.promiseDispatch=function(e,n,i){var a=Q(arguments);r?(r.push(a),"when"===n&&i[1]&&o.push(i[1])):c.nextTick(function(){t.promiseDispatch.apply(t,a)})},i.valueOf=function(){if(r)return i;var e=v(t);return y(e)&&(t=e),e},i.inspect=function(){return t?t.inspect():{state:"pending"}},c.longStackSupport&&Z)try{throw new Error}catch(a){i.stack=a.stack.substring(a.stack.indexOf("\n")+1)}return n.promise=i,n.resolve=function(r){t||e(c(r))},n.fulfill=function(r){t||e(D(r))},n.reject=function(r){t||e(A(r))},n.notify=function(e){t||K(o,function(t,r){c.nextTick(function(){r(e)})},void 0)},n}function h(e){if("function"!=typeof e)throw new TypeError("resolver must be a function.");var t=p();try{e(t.resolve,t.reject,t.notify)}catch(r){t.reject(r)}return t.promise}function d(e){return h(function(t,r){for(var o=0,n=e.length;n>o;o++)c(e[o]).then(t,r)})}function g(e,t,r){void 0===t&&(t=function(e){return A(new Error("Promise does not support operation: "+e))}),void 0===r&&(r=function(){return{state:"unknown"}});var o=ee(g.prototype);if(o.promiseDispatch=function(r,n,i){var a;try{a=e[n]?e[n].apply(o,i):t.call(o,n,i)}catch(s){a=A(s)}r&&r(a)},o.inspect=r,r){var n=r();"rejected"===n.state&&(o.exception=n.reason),o.valueOf=function(){var e=r();return"pending"===e.state||"rejected"===e.state?o:e.value}}return o}function m(e,t,r,o){return c(e).then(t,r,o)}function v(e){if(y(e)){var t=e.inspect();if("fulfilled"===t.state)return t.value}return e}function y(e){return e instanceof g}function _(e){return r(e)&&"function"==typeof e.then}function x(e){return y(e)&&"pending"===e.inspect().state}function b(e){return!y(e)||"fulfilled"===e.inspect().state}function w(e){return y(e)&&"rejected"===e.inspect().state}function T(){ie.length=0,ae.length=0,se||(se=!0)}function E(e,t){se&&(ae.push(e),ie.push(t&&"undefined"!=typeof t.stack?t.stack:"(no stack) "+t))}function C(e){if(se){var t=J(ae,e);-1!==t&&(ae.splice(t,1),ie.splice(t,1))}}function A(e){var t=g({when:function(t){return t&&C(this),t?t(e):this}},function(){return this},function(){return{state:"rejected",reason:e}});return E(t,e),t}function D(e){return g({when:function(){return e},get:function(t){return e[t]},set:function(t,r){e[t]=r},"delete":function(t){delete e[t]},post:function(t,r){return null===t||void 0===t?e.apply(void 0,r):e[t].apply(e,r)},apply:function(t,r){return e.apply(t,r)},keys:function(){return re(e)}},void 0,function(){return{state:"fulfilled",value:e}})}function S(e){var t=p();return c.nextTick(function(){try{e.then(t.resolve,t.reject,t.notify)}catch(r){t.reject(r)}}),t.promise}function I(e){return g({isDef:function(){}},function(t,r){return U(e,t,r)},function(){return c(e).inspect()})}function P(e,t,r){return c(e).spread(t,r)}function F(e){return function(){function t(e,t){var a;if("undefined"==typeof StopIteration){try{a=r[e](t)}catch(s){return A(s)}return a.done?c(a.value):m(a.value,n,i)}try{a=r[e](t)}catch(s){return o(s)?c(s.value):A(s)}return m(a,n,i)}var r=e.apply(this,arguments),n=t.bind(t,"next"),i=t.bind(t,"throw");return n()}}function R(e){c.done(c.async(e)())}function j(e){throw new q(e)}function L(e){return function(){return P([this,k(arguments)],function(t,r){return e.apply(t,r)})}}function U(e,t,r){return c(e).dispatch(t,r)}function k(e){return m(e,function(e){var t=0,r=p();return K(e,function(o,n,i){var a;y(n)&&"fulfilled"===(a=n.inspect()).state?e[i]=a.value:(++t,m(n,function(o){e[i]=o,0===--t&&r.resolve(e)},r.reject,function(e){r.notify({index:i,value:e})}))},void 0),0===t&&r.resolve(e),r.promise})}function O(e){if(0===e.length)return c.resolve();var t=c.defer(),r=0;return K(e,function(o,n,i){function a(e){t.resolve(e)}function s(){r--,0===r&&t.reject(new Error("Can't get fulfillment value from any promise, all promises were rejected."))}function f(e){t.notify({index:i,value:e})}var u=e[i];r++,m(u,a,s,f)},void 0),t.promise}function N(e){return m(e,function(e){return e=$(e,c),m(k($(e,function(e){return m(e,X,X)})),function(){return e})})}function M(e){return c(e).allSettled()}function V(e,t){return c(e).then(void 0,void 0,t)}function B(e,t){return c(e).nodeify(t)}var Z=!1;try{throw new Error}catch(z){Z=!!z.stack}var G,q,Y=u(),X=function(){},H=function(){function t(){for(;r.next;){r=r.next;var e=r.task;r.task=void 0;var o=r.domain;o&&(r.domain=void 0,o.enter());try{e()}catch(i){if(a)throw o&&o.exit(),setTimeout(t,0),o&&o.enter(),i;setTimeout(function(){throw i},0)}o&&o.exit()}n=!1}var r={task:void 0,next:null},o=r,n=!1,i=void 0,a=!1;if(H=function(t){o=o.next={task:t,domain:a&&e.domain,next:null},n||(n=!0,i())},"undefined"!=typeof e&&e.nextTick)a=!0,i=function(){e.nextTick(t)};else if("function"==typeof setImmediate)i="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var s=new MessageChannel;s.port1.onmessage=function(){i=f,s.port1.onmessage=t,t()};var f=function(){s.port2.postMessage(0)};i=function(){setTimeout(t,0),f()}}else i=function(){setTimeout(t,0)};return H}(),W=Function.call,Q=t(Array.prototype.slice),K=t(Array.prototype.reduce||function(e,t){var r=0,o=this.length;if(1===arguments.length)for(;;){if(r in this){t=this[r++];break}if(++r>=o)throw new TypeError}for(;o>r;r++)r in this&&(t=e(t,this[r],r));return t}),J=t(Array.prototype.indexOf||function(e){for(var t=0;t2?Q(arguments,1):r)}},c.Promise=h,c.promise=h,h.race=d,h.all=k,h.reject=A,h.resolve=c,c.passByCopy=function(e){return e},g.prototype.passByCopy=function(){return this},c.join=function(e,t){return c(e).join(t)},g.prototype.join=function(e){return c([this,e]).spread(function(e,t){if(e===t)return e;throw new Error("Can't join: not the same: "+e+" "+t)})},c.race=d,g.prototype.race=function(){return this.then(c.race)},c.makePromise=g,g.prototype.toString=function(){return"[object Promise]"},g.prototype.then=function(e,t,r){function o(t){try{return"function"==typeof e?e(t):t}catch(r){return A(r)}}function i(e){if("function"==typeof t){n(e,s);try{return t(e)}catch(r){return A(r)}}return A(e)}function a(e){return"function"==typeof r?r(e):e}var s=this,f=p(),u=!1;return c.nextTick(function(){s.promiseDispatch(function(e){u||(u=!0,f.resolve(o(e)))},"when",[function(e){u||(u=!0,f.resolve(i(e)))}])}),s.promiseDispatch(void 0,"when",[void 0,function(e){var t,r=!1;try{t=a(e)}catch(o){if(r=!0,!c.onerror)throw o;c.onerror(o)}r||f.notify(t)}]),f.promise},c.tap=function(e,t){return c(e).tap(t)},g.prototype.tap=function(e){return e=c(e),this.then(function(t){return e.fcall(t).thenResolve(t)})},c.when=m,g.prototype.thenResolve=function(e){return this.then(function(){return e})},c.thenResolve=function(e,t){return c(e).thenResolve(t)},g.prototype.thenReject=function(e){return this.then(function(){throw e})},c.thenReject=function(e,t){return c(e).thenReject(t)},c.nearer=v,c.isPromise=y,c.isPromiseAlike=_,c.isPending=x,g.prototype.isPending=function(){return"pending"===this.inspect().state},c.isFulfilled=b,g.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},c.isRejected=w,g.prototype.isRejected=function(){return"rejected"===this.inspect().state};var ie=[],ae=[],se=!0;c.resetUnhandledRejections=T,c.getUnhandledReasons=function(){return ie.slice()},c.stopUnhandledRejectionTracking=function(){T(),se=!1},T(),c.reject=A,c.fulfill=D,c.master=I,c.spread=P,g.prototype.spread=function(e,t){return this.all().then(function(t){return e.apply(void 0,t)},t)},c.async=F,c.spawn=R,c["return"]=j,c.promised=L,c.dispatch=U,g.prototype.dispatch=function(e,t){var r=this,o=p();return c.nextTick(function(){r.promiseDispatch(o.resolve,e,t)}),o.promise},c.get=function(e,t){return c(e).dispatch("get",[t])},g.prototype.get=function(e){return this.dispatch("get",[e])},c.set=function(e,t,r){return c(e).dispatch("set",[t,r])},g.prototype.set=function(e,t){return this.dispatch("set",[e,t])},c.del=c["delete"]=function(e,t){return c(e).dispatch("delete",[t])},g.prototype.del=g.prototype["delete"]=function(e){return this.dispatch("delete",[e])},c.mapply=c.post=function(e,t,r){return c(e).dispatch("post",[t,r])},g.prototype.mapply=g.prototype.post=function(e,t){return this.dispatch("post",[e,t])},c.send=c.mcall=c.invoke=function(e,t){return c(e).dispatch("post",[t,Q(arguments,2)])},g.prototype.send=g.prototype.mcall=g.prototype.invoke=function(e){return this.dispatch("post",[e,Q(arguments,1)])},c.fapply=function(e,t){return c(e).dispatch("apply",[void 0,t])},g.prototype.fapply=function(e){return this.dispatch("apply",[void 0,e])},c["try"]=c.fcall=function(e){return c(e).dispatch("apply",[void 0,Q(arguments,1)])},g.prototype.fcall=function(){return this.dispatch("apply",[void 0,Q(arguments)])},c.fbind=function(e){var t=c(e),r=Q(arguments,1);return function(){return t.dispatch("apply",[this,r.concat(Q(arguments))])}},g.prototype.fbind=function(){var e=this,t=Q(arguments);return function(){return e.dispatch("apply",[this,t.concat(Q(arguments))])}},c.keys=function(e){return c(e).dispatch("keys",[])},g.prototype.keys=function(){return this.dispatch("keys",[])},c.all=k,g.prototype.all=function(){return k(this)},c.any=O,g.prototype.any=function(){return O(this)},c.allResolved=l(N,"allResolved","allSettled"),g.prototype.allResolved=function(){return N(this)},c.allSettled=M,g.prototype.allSettled=function(){return this.then(function(e){return k($(e,function(e){function t(){return e.inspect()}return e=c(e),e.then(t,t)}))})},c.fail=c["catch"]=function(e,t){return c(e).then(void 0,t)},g.prototype.fail=g.prototype["catch"]=function(e){return this.then(void 0,e)},c.progress=V,g.prototype.progress=function(e){return this.then(void 0,void 0,e)},c.fin=c["finally"]=function(e,t){return c(e)["finally"](t)},g.prototype.fin=g.prototype["finally"]=function(e){return e=c(e),this.then(function(t){return e.fcall().then(function(){return t})},function(t){return e.fcall().then(function(){throw t})})},c.done=function(e,t,r,o){return c(e).done(t,r,o)},g.prototype.done=function(t,r,o){var i=function(e){c.nextTick(function(){if(n(e,a),!c.onerror)throw e;c.onerror(e)})},a=t||r||o?this.then(t,r,o):this;"object"==typeof e&&e&&e.domain&&(i=e.domain.bind(i)),a.then(void 0,i)},c.timeout=function(e,t,r){return c(e).timeout(t,r)},g.prototype.timeout=function(e,t){var r=p(),o=setTimeout(function(){t&&"string"!=typeof t||(t=new Error(t||"Timed out after "+e+" ms"),t.code="ETIMEDOUT"),r.reject(t)},e);return this.then(function(e){clearTimeout(o),r.resolve(e)},function(e){clearTimeout(o),r.reject(e)},r.notify),r.promise},c.delay=function(e,t){return void 0===t&&(t=e,e=void 0),c(e).delay(t)},g.prototype.delay=function(e){return this.then(function(t){var r=p();return setTimeout(function(){r.resolve(t)},e),r.promise})},c.nfapply=function(e,t){return c(e).nfapply(t)},g.prototype.nfapply=function(e){var t=p(),r=Q(e);return r.push(t.makeNodeResolver()),this.fapply(r).fail(t.reject),t.promise},c.nfcall=function(e){var t=Q(arguments,1);return c(e).nfapply(t)},g.prototype.nfcall=function(){var e=Q(arguments),t=p();return e.push(t.makeNodeResolver()),this.fapply(e).fail(t.reject),t.promise},c.nfbind=c.denodeify=function(e){var t=Q(arguments,1);
6 |
7 | return function(){var r=t.concat(Q(arguments)),o=p();return r.push(o.makeNodeResolver()),c(e).fapply(r).fail(o.reject),o.promise}},g.prototype.nfbind=g.prototype.denodeify=function(){var e=Q(arguments);return e.unshift(this),c.denodeify.apply(void 0,e)},c.nbind=function(e,t){var r=Q(arguments,2);return function(){function o(){return e.apply(t,arguments)}var n=r.concat(Q(arguments)),i=p();return n.push(i.makeNodeResolver()),c(o).fapply(n).fail(i.reject),i.promise}},g.prototype.nbind=function(){var e=Q(arguments,0);return e.unshift(this),c.nbind.apply(void 0,e)},c.nmapply=c.npost=function(e,t,r){return c(e).npost(t,r)},g.prototype.nmapply=g.prototype.npost=function(e,t){var r=Q(t||[]),o=p();return r.push(o.makeNodeResolver()),this.dispatch("post",[e,r]).fail(o.reject),o.promise},c.nsend=c.nmcall=c.ninvoke=function(e,t){var r=Q(arguments,2),o=p();return r.push(o.makeNodeResolver()),c(e).dispatch("post",[t,r]).fail(o.reject),o.promise},g.prototype.nsend=g.prototype.nmcall=g.prototype.ninvoke=function(e){var t=Q(arguments,1),r=p();return t.push(r.makeNodeResolver()),this.dispatch("post",[e,t]).fail(r.reject),r.promise},c.nodeify=B,g.prototype.nodeify=function(e){return e?void this.then(function(t){c.nextTick(function(){e(null,t)})},function(t){c.nextTick(function(){e(t)})}):this};var fe=u();return c})}).call(this,e("_process"))},{_process:5}],23:[function(e,t,r){!function(o){"object"==typeof r?t.exports=o(e("q")):window.Qimage=o(window.Q)}(function(e){var t=function(r,o){if(o=o||{},!t.Image)throw new Error("You must define Qimage.Image if not in window context.");var n=new t.Image;o.crossOrigin&&(n.crossOrigin=o.crossOrigin);var i=e.defer();return n.onload=function(){i.resolve(n)},n.onabort=function(e){i.reject(e)},n.onerror=function(e){i.reject(e)},n.src=r,i.promise};return"undefined"!=typeof window&&(t.Image=window.Image),t.anonymously=function(e){return t(e,{crossOrigin:"Anonymous"})},t})},{q:22}],24:[function(e,t){for(var r=e("performance-now"),o="undefined"==typeof window?{}:window,n=["moz","webkit"],i="AnimationFrame",a=o["request"+i],s=o["cancel"+i]||o["cancelRequest"+i],f=!0,u=0;u=0){for(var T=0|w.type.charAt(w.type.length-1),E=new Array(T),C=0;T>C;++C)E[C]=x.length,_.push(w.name+"["+C+"]"),x.push("number"==typeof w.location?w.location+C:Array.isArray(w.location)&&w.location.length===T&&"number"==typeof w.location[C]?0|w.location[C]:-1);y.push({name:w.name,type:w.type,locations:E})}else y.push({name:w.name,type:w.type,locations:[x.length]}),_.push(w.name),x.push("number"==typeof w.location?0|w.location:-1)}for(var A=0,b=0;b=0;)A+=1;x[b]=A}var D=new Array(r.length);l(),p._relink=l,p.types={uniforms:s(r),attributes:s(n)},p.attributes=a(h,p,y,x),Object.defineProperty(p,"uniforms",i(h,p,r,D))},t.exports=n},{"./lib/create-attributes":28,"./lib/create-uniforms":29,"./lib/reflect":30,"./lib/runtime-reflect":31,"./lib/shader-cache":32}],28:[function(e,t){"use strict";function r(e,t,r,o,n,i){this._gl=e,this._wrapper=t,this._index=r,this._locations=o,this._dimension=n,this._constFunc=i}function o(e,t,o,n,i,a,s){for(var f=["gl","v"],u=[],l=0;i>l;++l)f.push("x"+l),u.push("x"+l);f.push("if(x0.length===void 0){return gl.vertexAttrib"+i+"f(v,"+u.join()+")}else{return gl.vertexAttrib"+i+"fv(v,x0)}");var c=Function.apply(null,f),p=new r(e,t,o,n,i,c);Object.defineProperty(a,s,{set:function(t){return e.disableVertexAttribArray(n[o]),c(e,n[o],t),t},get:function(){return p},enumerable:!0})}function n(e,t,r,n,i,a,s){for(var f=new Array(i),u=new Array(i),l=0;i>l;++l)o(e,t,r[l],n,i,f,l),u[l]=f[l];Object.defineProperty(f,"location",{set:function(e){if(Array.isArray)for(var t=0;i>t;++t)u[t].location=e[t];else for(var t=0;i>t;++t)result[t]=u[t].location=e+t;return e},get:function(){for(var e=new Array(i),t=0;i>t;++t)e[t]=n[r[t]];return e},enumerable:!0}),f.pointer=function(t,o,a,s){t=t||e.FLOAT,o=!!o,a=a||i*i,s=s||0;for(var f=0;i>f;++f){var u=n[r[f]];e.vertexAttribPointer(u,i,t,o,a,s+f*i),e.enableVertexAttribArray(u)}};var c=new Array(i),p=e["vertexAttrib"+i+"fv"];Object.defineProperty(a,s,{set:function(t){for(var o=0;i>o;++o){var a=n[r[o]];if(e.disableVertexAttribArray(a),Array.isArray(t[0]))p.call(e,a,t[o]);else{for(var s=0;i>s;++s)c[s]=t[i*o+s];p.call(e,a,c)}}return t},get:function(){return f},enumerable:!0})}function i(e,t,r,i){for(var a={},s=0,f=r.length;f>s;++s){var u=r[s],l=u.name,c=u.type,p=u.locations;switch(c){case"bool":case"int":case"float":o(e,t,p[0],i,1,a,l);break;default:if(c.indexOf("vec")>=0){var h=c.charCodeAt(c.length-1)-48;if(2>h||h>4)throw new Error("gl-shader: Invalid data type for attribute "+l+": "+c);o(e,t,p[0],i,h,a,l)}else{if(!(c.indexOf("mat")>=0))throw new Error("gl-shader: Unknown data type for attribute "+l+": "+c);var h=c.charCodeAt(c.length-1)-48;if(2>h||h>4)throw new Error("gl-shader: Invalid data type for attribute "+l+": "+c);n(e,t,p,i,h,a,l)}}}return a}t.exports=i;var a=r.prototype;a.pointer=function(e,t,r,o){var n=this,i=n._gl,a=n._locations[n._index];i.vertexAttribPointer(a,n._dimension,e||i.FLOAT,!!t,r||0,o||0),i.enableVertexAttribArray(a)},a.set=function(e,t,r,o){return this._constFunc(this._locations[this._index],e,t,r,o)},Object.defineProperty(a,"location",{get:function(){return this._locations[this._index]},set:function(e){return e!==this._locations[this._index]&&(this._locations[this._index]=0|e,this._wrapper.program=null),0|e}})},{}],29:[function(e,t){"use strict";function r(e){var t=new Function("y","return function(){return y}");return t(e)}function o(e,t){for(var r=new Array(e),o=0;e>o;++o)r[o]=t;return r}function n(e,t,n,a){function s(r){var o=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+r+"])}");return o(e,t,a)}function f(e,t,r){switch(r){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+t+"],obj"+e+")";case"float":return"gl.uniform1f(locations["+t+"],obj"+e+")";default:var o=r.indexOf("vec");if(!(o>=0&&1>=o&&r.length===4+o)){if(0===r.indexOf("mat")&&4===r.length){var n=r.charCodeAt(r.length-1)-48;if(2>n||n>4)throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+r);return"gl.uniformMatrix"+n+"fv(locations["+t+"],false,obj"+e+")"}throw new Error("gl-shader: Unknown uniform data type for "+name+": "+r)}var n=r.charCodeAt(r.length-1)-48;if(2>n||n>4)throw new Error("gl-shader: Invalid data type");switch(r.charAt(0)){case"b":case"i":return"gl.uniform"+n+"iv(locations["+t+"],obj"+e+")";case"v":return"gl.uniform"+n+"fv(locations["+t+"],obj"+e+")";default:throw new Error("gl-shader: Unrecognized data type for vector "+name+": "+r)}}}function u(e,t){if("object"!=typeof t)return[[e,t]];var r=[];for(var o in t){var n=t[o],i=e;i+=parseInt(o)+""===o?"["+o+"]":"."+o,"object"==typeof n?r.push.apply(r,u(i,n)):r.push([i,n])}return r}function l(t){for(var r=["return function updateProperty(obj){"],o=u("",t),i=0;i=0&&1>=t&&e.length===4+t){var r=e.charCodeAt(e.length-1)-48;if(2>r||r>4)throw new Error("gl-shader: Invalid data type");return"b"===e.charAt(0)?o(r,!1):o(r,0)}if(0===e.indexOf("mat")&&4===e.length){var r=e.charCodeAt(e.length-1)-48;if(2>r||r>4)throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+e);return o(r*r,0)}throw new Error("gl-shader: Unknown uniform data type for "+name+": "+e)}}function p(e,t,o){if("object"==typeof o){var i=h(o);Object.defineProperty(e,t,{get:r(i),set:l(o),enumerable:!0,configurable:!1})}else a[o]?Object.defineProperty(e,t,{get:s(o),set:l(o),enumerable:!0,configurable:!1}):e[t]=c(n[o].type)}function h(e){var t;if(Array.isArray(e)){t=new Array(e.length);for(var r=0;r1){f[0]in a||(a[f[0]]=[]),a=a[f[0]];for(var u=1;ui;++i){var a=e.getActiveUniform(t,i);a&&n.push({name:a.name,type:o(e,a.type)})}return n}function i(e,t){for(var r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES),n=[],i=0;r>i;++i){var a=e.getActiveAttrib(t,i);a&&n.push({name:a.name,type:o(e,a.type)})}return n}r.uniforms=n,r.attributes=i;var a={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},s=null},{}],32:[function(e,t,r){"use strict";function o(e,t,r,o,n,i,a){this.id=e,this.src=t,this.type=r,this.shader=o,this.count=i,this.programs=[],this.cache=a}function n(e){this.gl=e,this.shaders=[{},{}],this.programs={}}function i(e,t,r){var o=e.createShader(t);if(e.shaderSource(o,r),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS)){var n=e.getShaderInfoLog(o);throw console.error("gl-shader: Error compiling shader:",n),new Error("gl-shader: Error compiling shader:"+n)}return o}function a(e,t,r,o,n){var i=e.createProgram();e.attachShader(i,t),e.attachShader(i,r);for(var a=0;ao;++o){var i=e.programs[r[o]];i&&(delete e.programs[o],t.deleteProgram(i))}t.deleteShader(this.shader),delete e.shaders[this.type===t.FRAGMENT_SHADER|0][this.src]}};var h=n.prototype;h.getShaderReference=function(e,t){var r=this.gl,n=this.shaders[e===r.FRAGMENT_SHADER|0],a=n[t];if(a)a.count+=1;else{var s=i(r,e,t);a=n[t]=new o(p++,t,e,s,[],1,this)}return a},h.getProgram=function(e,t,r,o){var n=[e.id,t.id,r.join(":"),o.join(":")].join("@"),i=this.programs[n];return i||(this.programs[n]=i=a(this.gl,e.shader,t.shader,r,o),e.programs.push(n),t.programs.push(n)),i}},{"weakmap-shim":35}],33:[function(e,t){function r(){var e={};return function(t){if(("object"!=typeof t||null===t)&&"function"!=typeof t)throw new Error("Weakmap-shim: Key must be object");var r=t.valueOf(e);return r&&r.identity===e?r:o(t,e)}}var o=e("./hidden-store.js");t.exports=r},{"./hidden-store.js":34}],34:[function(e,t){function r(e,t){var r={identity:t},o=e.valueOf;return Object.defineProperty(e,"valueOf",{value:function(e){return e!==t?o.apply(this,arguments):r},writable:!0}),r}t.exports=r},{}],35:[function(e,t){function r(){var e=o();return{get:function(t,r){var o=e(t);return o.hasOwnProperty("value")?o.value:r},set:function(t,r){e(t).value=r},has:function(t){return"value"in e(t)},"delete":function(t){return delete e(t).value}}}var o=e("./create-store.js");t.exports=r},{"./create-store.js":33}]},{},[6]);
--------------------------------------------------------------------------------