From 353f109d60ca9d29af333fe91bc09edd8a69472f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 11 Dec 2014 22:26:08 -0500 Subject: drag a selection around clones/copies it --- js/ui/selection.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'js/ui/selection.js') diff --git a/js/ui/selection.js b/js/ui/selection.js index 43b1a75..6f8f7db 100644 --- a/js/ui/selection.js +++ b/js/ui/selection.js @@ -22,11 +22,14 @@ var selection = (function(){ // - drag the selection to move it -- this "cuts" it and leaves a blank space on the canvas. // - shift-drag the selection to copy it - var a = [-1, -1] + var a = [0, 0] var b = [0, 0] var c = [0, 0] var d = [0, 0] + function reset () { + a[0] = a[1] = b[0] = b[1] = 0 + } function left (a,b) { return min(a[0],b[0]) } function top (a,b) { return min(a[1],b[1]) } function right (a,b) { return max(a[0],b[0]) } @@ -101,7 +104,8 @@ var selection = (function(){ if (creating) { orient(a,b) selection_canvas.resize(width(a,b), height(a,b)) - // copy canvas here.. + blit.copy_from( canvas, selection_canvas, a[0], a[1] ) + selection_canvas.build() selector_el.classList.remove("creating") } if (moving) { @@ -111,6 +115,7 @@ var selection = (function(){ a[1] += dy b[0] += dx b[1] += dy + blit.copy_to( canvas, selection_canvas, a[0], a[1] ) } if (copying) { } @@ -122,6 +127,11 @@ var selection = (function(){ selecting = true } function hide () { + reset() + selector_el.style.top = "-9999px" + selector_el.style.left = "-9999px" + selector_el.style.width = "0px" + selector_el.style.height = "0px" selecting = false } -- cgit v1.2.3-70-g09d2