diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-03-24 18:16:36 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-03-24 18:16:36 -0400 |
| commit | 8410a217e2a02257bd3a9d05e26c51cc8ae33086 (patch) | |
| tree | d7d5d5e536153234b8641ece8b3ee46cc193f879 /js/shader.js | |
| parent | 5f5127573a185e8070ecff31c2b69e8911843b7e (diff) | |
no tabs
Diffstat (limited to 'js/shader.js')
| -rw-r--r-- | js/shader.js | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/js/shader.js b/js/shader.js index 55bb2c7..8d13546 100644 --- a/js/shader.js +++ b/js/shader.js @@ -1,46 +1,46 @@ var shader = (function(){ - var fn_str, fn, lex - var exports = {} - var animating = false - - exports.init = function(){ - lex = new Lex (0, 0) - exports.build(demo_shader.innerHTML) - } - exports.build = function (fn_str){ - try { - new_fn = new Function('lex', 'x', 'y', 'w', 'h', 't', fn_str) - new_fn(lex, 0, 0, 1, 1, 0) - } - catch (e) { - throw 'Shader execution error' - } - exports.fn = fn = new_fn - return fn - } - exports.run = function(canvas){ - var t = +new Date, w = canvas.w, h = canvas.h - canvas.forEach(function(lex, x, y){ - fn(lex, x, y, w, h, t) - lex.build() - }) - } - exports.toggle = function(state){ - animating = typeof state == "boolean" ? state : ! animating - return animating - } - exports.pause = function(){ - animating = false - } - exports.play = function(){ - animating = true - } - exports.animate = function (t){ - requestAnimationFrame(exports.animate) - if (! animating) { return } - exports.run(canvas) - } - - return exports + var fn_str, fn, lex + var exports = {} + var animating = false + + exports.init = function(){ + lex = new Lex (0, 0) + exports.build(demo_shader.innerHTML) + } + exports.build = function (fn_str){ + try { + new_fn = new Function('lex', 'x', 'y', 'w', 'h', 't', fn_str) + new_fn(lex, 0, 0, 1, 1, 0) + } + catch (e) { + throw 'Shader execution error' + } + exports.fn = fn = new_fn + return fn + } + exports.run = function(canvas){ + var t = +new Date, w = canvas.w, h = canvas.h + canvas.forEach(function(lex, x, y){ + fn(lex, x, y, w, h, t) + lex.build() + }) + } + exports.toggle = function(state){ + animating = typeof state == "boolean" ? state : ! animating + return animating + } + exports.pause = function(){ + animating = false + } + exports.play = function(){ + animating = true + } + exports.animate = function (t){ + requestAnimationFrame(exports.animate) + if (! animating) { return } + exports.run(canvas) + } + + return exports })() |
