diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-21 13:50:30 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-21 13:50:30 -0500 |
| commit | e46886c6382bd2517eca07826e9a2cf6cb353962 (patch) | |
| tree | 73ac7463f82525a568d6baff09473179733f3289 /js/app.js | |
| parent | fea42b1513e321b6c397c914327a9a4a7d96e331 (diff) | |
right/left bracket to resize brush
Diffstat (limited to 'js/app.js')
| -rw-r--r-- | js/app.js | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -101,11 +101,14 @@ function build () { } function bind () { canvas.forEach(function(lex, x, y){ + lex.span.addEventListener('contextmenu', function(e){ + e.preventDefault() + }) lex.span.addEventListener('mousedown', function(e){ e.preventDefault() dragging = true if (drawing) { - erasing = e.which == "3" + erasing = (e.which == "3" || e.ctrlKey) draw(lex, x, y, erasing) } else { @@ -173,10 +176,21 @@ function bind () { if (! e.metaKey && ! e.ctrlKey && ! e.altKey) { e.preventDefault() } + console.log(e.keyCode) switch (e.keyCode) { case 27: // esc if (focused) focused.blur() break + case 219: // [ + if (! focused && current_tool.name != "text") { + brush.contract(1) + break + } + case 221: // ] + if (! focused && current_tool.name != "text") { + brush.expand(1) + break + } default: if (focused) focused.key(String.fromCharCode(e.keyCode), e.keyCode) break @@ -191,7 +205,6 @@ function int_key (f) { } - function draw (lex, x, y, erasing) { stamp (canvas, brush, x, y, erasing) } @@ -201,13 +214,17 @@ function stamp (canvas, brush, x, y, erasing) { s += x-hh t += y-hh if (s >= 0 && s < canvas.w && t >= 0 && t < canvas.h) { - canvas.aa[t][s].clone(lex) + if (erasing) { + canvas.aa[t][s].erase(lex) + } + else { + canvas.aa[t][s].clone(lex) + } } }) } -function mod (i,n) { - return i - n * Math.floor(i / n) -} +function clamp (n,a,b){ return n < a ? a : n < b ? n : b } +function mod (i,n) { return i - n * Math.floor(i / n) } document.body.addEventListener('copy', function (e) { if (e.clipboardData) { |
