diff options
Diffstat (limited to 'gif-dither.html')
| -rw-r--r-- | gif-dither.html | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/gif-dither.html b/gif-dither.html index 84217fc..5a9cb09 100644 --- a/gif-dither.html +++ b/gif-dither.html @@ -31,6 +31,8 @@ <script type="text/javascript" src="js/util.js"></script> <script type="text/javascript"> +var algo = "random" + document.getElementById("url").onchange = load setTimeout(init) @@ -40,6 +42,8 @@ function init () { } function load(){ document.getElementById("save").style.display = "none" + document.getElementById("encode").style.display = "none" + status("loading") var imageURL = document.getElementById("url").value loadImage(imageURL, ready) } @@ -50,21 +54,10 @@ function status (s){ el.innerHTML = s + "..." } function bind(){ - var buttons = document.getElementsByTagName("button") - for (var i = 0; i < buttons.length; i++) { - (function(n){ - buttons[n].onclick = function(){ - algo = buttons[n].id; - build() - } - })(i) - } document.getElementById("save").onclick = save document.getElementById("encode").onclick = encode } - - var encoder = new GifEncoder() encoder.on("quantized", function(url){ @@ -97,9 +90,6 @@ function ready(){ build() } -var algo = "random" -var frames = [] - function build(){ status("dithering") encoder.resetFrames() @@ -112,7 +102,7 @@ function build(){ if (buttons[i].id != "save" && buttons[i].id != "encode") bz.push(buttons[i].id) } gif.frames.forEach(function(frame, i){ - var algo = bz[i % bz.length] + algo = bz[i % bz.length] var cc = dither(frame) encoder.addFrame(cc.canvas) }) |
