diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-06-30 00:12:31 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-06-30 00:12:31 -0400 |
| commit | 72ccfc7ca4f71987f69a5734d49a93ab78d9ebe8 (patch) | |
| tree | 08d8db18f268044b932f617ba819ca2fd2178d0b /js | |
| parent | afe71482758d953d819daab995bf5400029396d3 (diff) | |
selection no longer requires grid
Diffstat (limited to 'js')
| -rw-r--r-- | js/app.js | 1 | ||||
| -rw-r--r-- | js/matrix.js | 9 | ||||
| -rw-r--r-- | js/ui/selection.js | 14 |
3 files changed, 12 insertions, 12 deletions
@@ -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") |
