From eaacd74ea95f9b04675068a8ad5ee774c463bbb9 Mon Sep 17 00:00:00 2001 From: Peihong Guo Date: Thu, 28 Nov 2013 02:40:30 -0600 Subject: [PATCH] added a fast mosaic effect --- index.html | 6 ++++++ pixastic.effects.js | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 89b2612..9dc5884 100644 --- a/index.html +++ b/index.html @@ -137,6 +137,12 @@ options : { amount : 0.5 } + }, + { + effect : 'mosaic', + options : { + blockSize : 8 + } } ]; diff --git a/pixastic.effects.js b/pixastic.effects.js index dd9f62b..9789e61 100644 --- a/pixastic.effects.js +++ b/pixastic.effects.js @@ -1184,8 +1184,45 @@ Pixastic.Effects = (function() { } } } + }, + + mosaic : function(inData, outData, width, height, options, progress) { + + var blockSize = clamp(options.blockSize, 1, Math.max(width, height)), + yBlocks = Math.ceil(height / blockSize), + xBlocks = Math.ceil(width / blockSize), + y0, y1, x0, x1, idx, pidx, + n = yBlocks * xBlocks, + prog, lastProg = 0; + + for (i=0, y0=0, bidx=0;i> 0) / 100; + if (prog > lastProg) { + lastProg = progress(prog); + } + } + } + y0 = y1; + } } - }; })();