diff options
| author | jules <jules@okfoc.us> | 2013-12-29 18:26:12 -0500 |
|---|---|---|
| committer | jules <jules@okfoc.us> | 2013-12-29 18:26:12 -0500 |
| commit | 8829a743db3ec88182f3034d077971ba5c2a5cbf (patch) | |
| tree | fd49dd91005f74e6211445da1bcc0ce58c5a860b /pattern.html | |
| parent | f483f2667690ddc89961cb163a870ce84196374e (diff) | |
dither picker
Diffstat (limited to 'pattern.html')
| -rw-r--r-- | pattern.html | 4 |
1 files changed, 4 insertions, 0 deletions
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) |
