diff options
| author | jules <jules@okfoc.us> | 2014-01-20 22:48:50 -0500 |
|---|---|---|
| committer | jules <jules@okfoc.us> | 2014-01-20 22:48:50 -0500 |
| commit | a16f1daaa4294c66ed16a9a6fd6abe85b5b049a9 (patch) | |
| tree | 82c80e647209320feb11b64031193a5cb00e7020 | |
| parent | e3f9a2a3b385382ae72258c216b068a53717c224 (diff) | |
chisel out shader-animate to use library
| -rw-r--r-- | shader-animate.html | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/shader-animate.html b/shader-animate.html index 2525088..6591d6d 100644 --- a/shader-animate.html +++ b/shader-animate.html @@ -45,47 +45,22 @@ $(init) function init(){ $("#url").change(load) - $("#demo").click(function(){ demo("#first") }) - $("#dither-demo").click(function(){ demo("#second") }) - demo('#first') + $("#demo").click(function(){ run("#first") }) + $("#dither-demo").click(function(){ run("#second") }) + run('#first') + load() - draw() document.getElementById('shader').addEventListener('input', shader_build); shader_build() requestAnimationFrame(animate) } -function demo(el){ - $el = $(el) - s = $el.html() - $("#shader").html(s) -} -function load(){ - loading = true - var imageURL = $("#url").val() - loadImage(imageURL, ready) -} - -var frame; -function ready(){ - loading = false - if (window.gif) { - frame = gif.frames[0] - } - else { - fc = cq(img.width, img.height) - fc.drawImage(img, 0, 0) - frame = { ctx: fc.context } - } - w = cc.canvas.width = frame.ctx.canvas.width - h = cc.canvas.height = frame.ctx.canvas.height -} - -var timeout = null; -function animate(t){ - requestAnimationFrame(animate); - shade(frame, t) +function run(el){ + $el = $(el) + s = $el.html() + $("#shader").html(s) + shader_build() } </script> |
