diff options
author | Devine Lu Linvega <[email protected]> | 2019-04-19 20:42:25 +0900 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2019-04-19 20:42:25 +0900 |
commit | 9730c21db400fecd3012589ca81988b2479d80a9 (patch) | |
tree | 6b6528c823b6a9dd1655eb7ae321d5568a128d6e | |
parent | 0a4a3a84093c38f3f152a1d0b322846739227dca (diff) | |
download | Orca-Renderer.tar.gz Orca-Renderer.zip |
-rw-r--r-- | desktop/main.js | 1 | ||||
-rw-r--r-- | desktop/sources/scripts/renderer.js | 17 |
2 files changed, 12 insertions, 6 deletions
diff --git a/desktop/main.js b/desktop/main.js index 62f6a2e..933faa2 100644 --- a/desktop/main.js +++ b/desktop/main.js @@ -24,6 +24,7 @@ app.on('ready', () => { }) app.win.loadURL(`file://${__dirname}/sources/index.html`) + app.inspect() app.win.on('closed', () => { win = null diff --git a/desktop/sources/scripts/renderer.js b/desktop/sources/scripts/renderer.js index a8e7125..20532c2 100644 --- a/desktop/sources/scripts/renderer.js +++ b/desktop/sources/scripts/renderer.js @@ -172,10 +172,7 @@ function Spritesheet (terminal) { const rect = this.makeRect(glyph, type) const style = this.styles[type] - if (!this.cache[glyph]) { - this.cache[glyph] = {} - } - this.cache[glyph][type] = rect + this.store(glyph, type, rect) if (style.bg) { this.context.fillStyle = style.bg ? style.bg : 'black' @@ -188,6 +185,13 @@ function Spritesheet (terminal) { } } + this.store = function (glyph, type, rect) { + if (!this.cache[glyph]) { + this.cache[glyph] = {} + } + this.cache[glyph][type] = rect + } + this.clear = function () { this.context.clearRect(0, 0, this.el.width, this.el.height) } @@ -209,8 +213,9 @@ function Spritesheet (terminal) { this.draw = function (context, x, y, glyph, type) { const rect = this.getRect(glyph, type) - if (!rect) { return } - context.drawImage(this.el, rect.x, rect.y, this.tile.w * this.scale, this.tile.h * this.scale, x * this.tile.w * this.scale, y * this.tile.h * this.scale, this.tile.w * this.scale, this.tile.h * this.scale) + if (rect) { + context.drawImage(this.el, rect.x, rect.y, this.tile.w * this.scale, this.tile.h * this.scale, x * this.tile.w * this.scale, y * this.tile.h * this.scale, this.tile.w * this.scale, this.tile.h * this.scale) + } } this.print = function (context) { |