summaryrefslogtreecommitdiff
path: root/js/ui/selection.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-12-11 22:26:08 -0500
committerJules Laplace <jules@okfoc.us>2014-12-11 22:26:08 -0500
commit353f109d60ca9d29af333fe91bc09edd8a69472f (patch)
tree64220b3da064f1f5b700fc650c4e34f0b5223854 /js/ui/selection.js
parentad28a48edc1ec1c9182cc455451c3b68a8c2b4bc (diff)
drag a selection around clones/copies it
Diffstat (limited to 'js/ui/selection.js')
-rw-r--r--js/ui/selection.js14
1 files changed, 12 insertions, 2 deletions
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
}