From 8829a743db3ec88182f3034d077971ba5c2a5cbf Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 29 Dec 2013 18:26:12 -0500 Subject: dither picker --- pattern.html | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pattern.html') diff --git a/pattern.html b/pattern.html index f622cce..a88bdc1 100644 --- a/pattern.html +++ b/pattern.html @@ -24,6 +24,7 @@ var algo = 'random'; var urls = ["img/abyss.png","img/building.png","img/gradient.jpg"] var imgs = [] var complete = 0 + urls.forEach(function(src){ var img = new Image () img.onload = ready @@ -31,6 +32,7 @@ urls.forEach(function(src){ imgs.push(img) if (img.complete) ready() }) + function ready(){ complete += 1 if (complete < imgs.length) return; @@ -45,10 +47,12 @@ function ready(){ } build() } + function build(){ document.getElementById("images").innerHTML = "" imgs.forEach(dither) } + function dither(img){ var w = img.naturalWidth, h = img.naturalHeight; var cc = cq(w, h) -- cgit v1.2.3-70-g09d2