diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-22 10:24:05 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-22 10:24:05 -0500 |
| commit | e1cbb0d9034358b5191a4d6da0900b9504950e69 (patch) | |
| tree | 073ffd49ec6aced9b0df920f2dca00645d9046b3 /js/app.js | |
| parent | 9ab497b693d34e10b9db2d7603917d8d1296e350 (diff) | |
toggle grid
Diffstat (limited to 'js/app.js')
| -rw-r--r-- | js/app.js | 29 |
1 files changed, 8 insertions, 21 deletions
@@ -90,6 +90,10 @@ function build () { canvas.clear() } + controls.grid = new Tool (grid_el) + controls.grid.use = function(){ + document.body.classList.toggle('grid') + } controls.width = new Lex (width_el) controls.height = new Lex (height_el) @@ -151,7 +155,7 @@ function bind () { }) }); - [controls.square, controls.circle, controls.text, controls.clear].forEach(function(tool){ + [controls.square, controls.circle, controls.text, controls.clear, controls.grid].forEach(function(tool){ tool.span.addEventListener('mousedown', function(e){ tool.focus() }) @@ -197,7 +201,7 @@ function bind () { if (! e.metaKey && ! e.ctrlKey && ! e.altKey) { e.preventDefault() } - console.log(e.keyCode) + // console.log(e.keyCode) switch (e.keyCode) { case 27: // esc if (focused) focused.blur() @@ -218,6 +222,8 @@ function bind () { } }) } + + function int_key (f) { return function (key, keyCode) { var n = parseInt(key) @@ -225,25 +231,6 @@ function int_key (f) { } } - -function draw (lex, x, y, erasing) { - stamp (canvas, brush, x, y, erasing) -} -function stamp (canvas, brush, x, y, erasing) { - hh = brush.w/2|0 - brush.forEach(function(lex, s, t){ - s += x-hh - t += y-hh - if (s >= 0 && s < canvas.w && t >= 0 && t < canvas.h) { - if (erasing) { - canvas.aa[t][s].erase(lex) - } - else { - canvas.aa[t][s].clone(lex) - } - } - }) -} function clamp (n,a,b){ return n < a ? a : n < b ? n : b } function mod (i,n) { return i - n * Math.floor(i / n) } |
