diff options
| author | Yuval Adam <yuval@y3xz.com> | 2015-06-21 15:47:46 +0300 |
|---|---|---|
| committer | Yuval Adam <yuval@y3xz.com> | 2015-06-21 15:47:46 +0300 |
| commit | d2a10c7d712a3f60888424f17c366ac2d5b4c265 (patch) | |
| tree | d31adc45bad2e2a61c8530837b32379f5082648e /client/effects.js | |
| parent | 1dc5c79e76bea64f2272f25bcd1826cf63a3d374 (diff) | |
Implement step 7
Diffstat (limited to 'client/effects.js')
| -rw-r--r-- | client/effects.js | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/client/effects.js b/client/effects.js index 08da3ee..63a5ab1 100644 --- a/client/effects.js +++ b/client/effects.js @@ -230,12 +230,52 @@ Effects = (function() { }) } + function drawFinalIcon() { + var canvas = document.getElementById('canvas-final'); + var p = new paper.PaperScope(); + p.setup(canvas); + + var gridSize = 35; + var gridDim = 9; + var photos = $('div.photo').length; + + var cols = []; + _.each(Session.get('photos'), function (x, i) { + var id = x.id; + cols.push(Session.get(id + ':finalcols')); + }); + + for (var y = 0; y < gridDim; y++) { + for(var x = 0; x < gridDim; x++) { + + var c = [] + for (var j = 0; j < photos; j++) { + c.push(cols[j][(y * gridDim) + x]); + } + + var freq_col = _.chain(c).countBy().pairs().max(_.last).head().value(); + freq_col = freq_col.split(','); + var nc = new paper.Color(+freq_col[0], +freq_col[1], +freq_col[2]); + + var rec = new paper.Path.Rectangle({ + point: [x * gridSize, y * gridSize], + size: [gridSize, gridSize], + strokeWidth: 0, + fillColor: nc + }); + } + } + p.view.draw(); + + } + return { pixelate: pixelate, colorize: colorize, average: average, averageColor: averageColor, - drawFinal: drawFinal + drawFinal: drawFinal, + drawFinalIcon: drawFinalIcon } })(); |
