diff options
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) |
