From 1e9056cb5ac4e6caa601b95485d9081b304b3d83 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 8 May 2018 13:17:41 +1200 Subject: [PATCH] Removed old offset element --- desktop/sources/scripts/dotgrid.js | 12 ++-- desktop/sources/scripts/keyboard.js | 108 ---------------------------- 2 files changed, 4 insertions(+), 116 deletions(-) delete mode 100644 desktop/sources/scripts/keyboard.js diff --git a/desktop/sources/scripts/dotgrid.js b/desktop/sources/scripts/dotgrid.js index 57c94b4..67c274b 100644 --- a/desktop/sources/scripts/dotgrid.js +++ b/desktop/sources/scripts/dotgrid.js @@ -32,8 +32,7 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.wrapper.appendChild(this.element); this.element.appendChild(this.guide.el); this.wrapper.appendChild(this.render.el); - - this.offset_el = document.createElementNS("http://www.w3.org/2000/svg", "g"); + // Vector this.svg_el = document.createElementNS("http://www.w3.org/2000/svg", "svg"); this.svg_el.setAttribute("class","vector"); @@ -64,10 +63,9 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.preview_el.style.fill = this.tool.style().fill; this.element.appendChild(this.preview_el); - this.offset_el.appendChild(this.layer_3) - this.offset_el.appendChild(this.layer_2) - this.offset_el.appendChild(this.layer_1) - this.svg_el.appendChild(this.offset_el); + this.svg_el.appendChild(this.layer_3); + this.svg_el.appendChild(this.layer_2); + this.svg_el.appendChild(this.layer_1); this.theme.start(); this.tool.start(); @@ -418,8 +416,6 @@ function Dotgrid(width,height,grid_x,grid_y,block_x,block_y) this.layer_3.style.stroke = this.tool.styles[2].color; this.layer_3.style.fill = this.tool.styles[2].fill; this.layer_3.style.strokeDasharray = `${this.tool.styles[2].dash[0] * this.tool.styles[2].thickness},${this.tool.styles[2].dash[1] * this.tool.styles[2].thickness}`; - - this.offset_el.setAttribute("transform","translate(0,0)") this.preview(); this.render.draw(); diff --git a/desktop/sources/scripts/keyboard.js b/desktop/sources/scripts/keyboard.js deleted file mode 100644 index 0fa1f77..0000000 --- a/desktop/sources/scripts/keyboard.js +++ /dev/null @@ -1,108 +0,0 @@ -function Keyboard() -{ - this.memory = ""; - this.is_active = false; - - this.selector = {x:0,y:0}; - - this.start = function() - { - this.is_active = true; - dotgrid.controller.set("keyboard"); - this.select({x:10,y:10}) - dotgrid.cursor.className = "keyboard"; - } - - this.stop = function() - { - this.is_active = false; - dotgrid.controller.set(); - dotgrid.cursor.className = ""; - } - - this.select = function(pos) - { - this.selector = {x:pos.x * -dotgrid.grid_width,y:pos.y * dotgrid.grid_height}; - dotgrid.move_cursor(this.selector) - dotgrid.guide.refresh(); - dotgrid.draw(); - } - - this.deselect = function() - { - dotgrid.tool.clear(); - dotgrid.guide.refresh(); - dotgrid.draw(); - } - - this.confirm = function() - { - dotgrid.tool.add_vertex({x:this.selector.x * -1,y:this.selector.y}); - dotgrid.guide.refresh(); - dotgrid.draw(); - } - - this.erase = function() - { - dotgrid.tool.remove_segments_at(this.selector); - dotgrid.guide.refresh(); - dotgrid.draw(); - } - - this.move = function(x,y) - { - this.selector = {x:this.selector.x+(x*dotgrid.grid_width),y:this.selector.y+(-y*dotgrid.grid_height)}; - - this.selector.x = this.selector.x > 0 ? 0 : this.selector.x; - this.selector.y = this.selector.y < 0 ? 0 : this.selector.y; - dotgrid.move_cursor(this.selector) - dotgrid.guide.refresh(); - dotgrid.draw(); - } - - this.push = function(k) - { - this.memory = `${this.memory}${k}`; - if(this.memory.length > 3){ - var pos = {x:parseInt(this.memory.substr(0,2)),y:parseInt(this.memory.substr(2,2))}; - this.select(pos); - this.memory = ""; - } - } - - this.reset = function() - { - this.memory = ""; - dotgrid.update(); - } - - this.listen = function(e) - { - if(!this.is_active){ return; } - - if(e.key == "ArrowRight"){ - dotgrid.keyboard.move(-1,0); - e.preventDefault(); - } - if(e.key == "ArrowLeft"){ - dotgrid.keyboard.move(1,0); - e.preventDefault(); - } - if(e.key == "ArrowUp"){ - dotgrid.keyboard.move(0,1); - e.preventDefault(); - } - if(e.key == "ArrowDown"){ - dotgrid.keyboard.move(0,-1); - e.preventDefault(); - } - if(e.code && e.code.substr(0,5) == "Digit" && !e.metaKey && !e.ctrlKey){ - var value = parseInt(e.code.substr(5,1)); - dotgrid.keyboard.push(value); - e.preventDefault(); - } - } - - // document.onkeyup = function(event){ dotgrid.keyboard.listen(event); }; - document.onkeydown = function(event){ dotgrid.keyboard.listen(event); }; -} \ No newline at end of file