diff options
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 })() |
