From 5907322e23673884ceb48d2a07f930337bdf18db Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 22 Nov 2014 18:32:08 -0500 Subject: stroking brush --- js/ui/canvas.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'js/ui/canvas.js') diff --git a/js/ui/canvas.js b/js/ui/canvas.js index 7e85fcf..1ee6e1c 100644 --- a/js/ui/canvas.js +++ b/js/ui/canvas.js @@ -5,15 +5,16 @@ var canvas = (function(){ var exports = new Matrix (cols, rows, function(x,y){ var lex = new Lex (x,y) -// lex.build() + lex.build() return lex }) exports.bind = function(){ + var last_point = [0,0] 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() }) @@ -23,13 +24,17 @@ var canvas = (function(){ if (drawing) { erasing = (e.which == "3" || e.ctrlKey) draw(lex, x, y, erasing) + last_point[0] = x + last_point[1] = y } lex.focus() }) lex.span.addEventListener("mousemove", function(){ if (! dragging) return if (drawing) { - draw(lex, x, y, erasing) + line(lex, last_point, point, erasing) + last_point[0] = x + last_point[1] = y } lex.focus() }) -- cgit v1.2.3-70-g09d2