diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-03-24 18:16:36 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-03-24 18:16:36 -0400 |
| commit | 8410a217e2a02257bd3a9d05e26c51cc8ae33086 (patch) | |
| tree | d7d5d5e536153234b8641ece8b3ee46cc193f879 /js/ui/canvas.js | |
| parent | 5f5127573a185e8070ecff31c2b69e8911843b7e (diff) | |
no tabs
Diffstat (limited to 'js/ui/canvas.js')
| -rw-r--r-- | js/ui/canvas.js | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/js/ui/canvas.js b/js/ui/canvas.js index e157623..67250b8 100644 --- a/js/ui/canvas.js +++ b/js/ui/canvas.js @@ -1,53 +1,53 @@ var canvas = current_canvas = (function(){ - var cols = 100 - var rows = 24 + var cols = 100 + var rows = 24 - var exports = new Matrix (cols, rows, function(x,y){ - var lex = new Lex (x,y) - lex.build() - return lex - }) + var exports = new Matrix (cols, rows, function(x,y){ + var lex = new Lex (x,y) + lex.build() + return lex + }) exports.bind = function(){ - exports.forEach(function(lex, x, y){ + exports.forEach(function(lex, x, y){ - if (lex.bound) return - lex.bound = true - var point = [x,y] - lex.span.addEventListener('contextmenu', function(e){ - e.preventDefault() - }) - lex.span.addEventListener('mousedown', function(e){ - e.preventDefault() - dragging = true - current_canvas = canvas - if (drawing) { - draw.down(e, lex, point) - } - else if (selecting) { - selection.down(e, lex, point) - } - else if (filling) { - draw.fill(brush, x, y) - } - lex.focus() - }) - lex.span.addEventListener("mousemove", function(e){ - if (! dragging) return - if (drawing) { + if (lex.bound) return + lex.bound = true + var point = [x,y] + lex.span.addEventListener('contextmenu', function(e){ + e.preventDefault() + }) + lex.span.addEventListener('mousedown', function(e){ + e.preventDefault() + dragging = true + current_canvas = canvas + if (drawing) { + draw.down(e, lex, point) + } + else if (selecting) { + selection.down(e, lex, point) + } + else if (filling) { + draw.fill(brush, x, y) + } + lex.focus() + }) + lex.span.addEventListener("mousemove", function(e){ + if (! dragging) return + if (drawing) { draw.move(e, lex, point) - } - else if (selecting) { - selection.move(e, lex, point) - } - lex.focus() - }) + } + else if (selecting) { + selection.move(e, lex, point) + } + lex.focus() + }) - }) - } + }) + } - return exports + return exports })() |
