From 2b5408eace08de325583fbd09ba75b34b31d10cd Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Wed, 27 Sep 2017 12:54:26 +1300 Subject: [PATCH] Cleaned folder structure --- sources/index.html | 7 ++++--- sources/scripts/keyboard.js | 4 +++- sources/scripts/{ => layers}/grid.js | 0 sources/scripts/{ => layers}/guide.js | 0 sources/scripts/{ => layers}/render.js | 0 sources/scripts/modules/frame.js | 7 ++++--- sources/scripts/ronin.js | 14 ++++++++++++-- 7 files changed, 23 insertions(+), 9 deletions(-) rename sources/scripts/{ => layers}/grid.js (100%) rename sources/scripts/{ => layers}/guide.js (100%) rename sources/scripts/{ => layers}/render.js (100%) diff --git a/sources/index.html b/sources/index.html index 1aa4a1c..25ccf6e 100644 --- a/sources/index.html +++ b/sources/index.html @@ -7,14 +7,15 @@ - - + + + + - diff --git a/sources/scripts/keyboard.js b/sources/scripts/keyboard.js index 056d27e..604d0f4 100644 --- a/sources/scripts/keyboard.js +++ b/sources/scripts/keyboard.js @@ -14,7 +14,9 @@ function Keyboard() if(e.key == "Escape"){ e.preventDefault(); - ronin.commander.input_el.blur();; + ronin.commander.input_el.blur(); + ronin.commander.input_el.value = ""; + ronin.guide.update(); } if(e.key == "]"){ diff --git a/sources/scripts/grid.js b/sources/scripts/layers/grid.js similarity index 100% rename from sources/scripts/grid.js rename to sources/scripts/layers/grid.js diff --git a/sources/scripts/guide.js b/sources/scripts/layers/guide.js similarity index 100% rename from sources/scripts/guide.js rename to sources/scripts/layers/guide.js diff --git a/sources/scripts/render.js b/sources/scripts/layers/render.js similarity index 100% rename from sources/scripts/render.js rename to sources/scripts/layers/render.js diff --git a/sources/scripts/modules/frame.js b/sources/scripts/modules/frame.js index 00c684f..899660f 100644 --- a/sources/scripts/modules/frame.js +++ b/sources/scripts/modules/frame.js @@ -8,10 +8,11 @@ function Frame() this.methods.resize = function(q) { - if(q.indexOf("x") == -1){ return; } + var data = ronin.render.select(0,0,ronin.frame.settings.width,ronin.frame.settings.height); - var size = {width:parseInt(q.split("x")[0]),height:parseInt(q.split("x")[1])}; - ronin.frame.resize(size); + ronin.render.clear(); + ronin.frame.resize_to(q); + ronin.render.context().putImageData(data, 0, 0); } this.methods.rescale = function(p) diff --git a/sources/scripts/ronin.js b/sources/scripts/ronin.js index feee9b6..24e1b31 100644 --- a/sources/scripts/ronin.js +++ b/sources/scripts/ronin.js @@ -3,20 +3,27 @@ function Ronin() this.el = document.createElement('yu'); this.el.id = "ronin"; - this.grid = new Grid(); this.io = new IO(); this.keyboard = new Keyboard(); this.commander = new Commander(); this.cursor = new Cursor(); - this.render = new Render(); this.hint = new Hint(); + + this.grid = new Grid(); this.guide = new Guide(); + this.render = new Render(); this.brush = new Brush(); this.eraser = new Eraser(); this.frame = new Frame(); this.line = new Line(); + this.layers = { + grid : this.grid, + guide : this.guide, + render : this.render, + }; + this.modules = { brush : this.brush, eraser : this.eraser, @@ -28,6 +35,9 @@ function Ronin() { document.body.appendChild(this.el); + this.frame.settings.width = window.innerWidth; + this.frame.settings.height = window.innerHeight; + this.grid.install(); this.guide.install(); this.render.install();