From 72ccfc7ca4f71987f69a5734d49a93ab78d9ebe8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 30 Jun 2015 00:12:31 -0400 Subject: selection no longer requires grid --- js/app.js | 1 - js/matrix.js | 9 +++++---- js/ui/selection.js | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'js') diff --git a/js/app.js b/js/app.js index f41b7a6..a98ee84 100644 --- a/js/app.js +++ b/js/app.js @@ -5,7 +5,6 @@ var erasing = false var selecting = false var filling = false var changed = false -var grid = false var focused var canvas, tools, palette, controls, brush, mode, current_tool, current_canvas diff --git a/js/matrix.js b/js/matrix.js index 0f38eeb..649321a 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -185,12 +185,13 @@ Matrix.prototype.resize = function(w,h){ this.rapper && this.resize_rapper() } Matrix.prototype.resize_rapper = function(){ - var cw = this.aa[0][0].span.offsetWidth - var ch = this.aa[0][0].span.offsetHeight - if (this.grid) { cw++; ch++ } + var cell = canvas.aa[0][0].span + var cw = cell.offsetWidth + var ch = cell.offsetHeight + if (canvas.grid) { cw++; ch++ } var width = cw * this.aa[0].length var height = ch * this.aa.length - if (this.grid) { width++; height++ } + if (canvas.grid) { width++; height++ } if (this.rotated) { this.rapper.parentNode.classList.add("rotated") this.rapper.parentNode.style.height = (width) + "px" diff --git a/js/ui/selection.js b/js/ui/selection.js index a3c3694..2ef2941 100644 --- a/js/ui/selection.js +++ b/js/ui/selection.js @@ -54,16 +54,15 @@ var selection = (function(){ var cell = canvas.aa[top(aa, bb)][left(aa, bb)].span var cell_left = cell.offsetLeft var cell_top = cell.offsetTop - var cell_width = 9 - var cell_height = 16 - if (!document.body.classList.contains("grid")){ - cell_width -= 1 - cell_height -= 1 - } + var cell_width = cell.offsetWidth + var cell_height = cell.offsetHeight + if (canvas.grid) { cell_width++; cell_height++ } + var w = width(aa, bb) var h = height(aa, bb) + selector_el.style.top = (cell_top-1) + "px" - selector_el.style.left = (cell_left-2) + "px" + selector_el.style.left = (cell_left-1) + "px" selector_el.style.width = (cell_width*w+1) + "px" selector_el.style.height = (cell_height*h+1) + "px" } @@ -111,6 +110,7 @@ var selection = (function(){ if (creating) { orient(a,b) selection_canvas.resize(width(a,b), height(a,b)) + reposition(a,b) blit.copy_from( canvas, selection_canvas, a[0], a[1] ) selection_canvas.build() selector_el.classList.remove("creating") -- cgit v1.2.3-70-g09d2