From 9730c21db400fecd3012589ca81988b2479d80a9 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 19 Apr 2019 20:42:25 +0900 Subject: * --- desktop/main.js | 1 + 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) { -- cgit v1.2.3