aboutsummaryrefslogtreecommitdiffhomepage
path: root/desktop/sources/scripts/renderer.js
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2019-04-19 20:42:25 +0900
committerDevine Lu Linvega <[email protected]>2019-04-19 20:42:25 +0900
commit9730c21db400fecd3012589ca81988b2479d80a9 (patch)
tree6b6528c823b6a9dd1655eb7ae321d5568a128d6e /desktop/sources/scripts/renderer.js
parent0a4a3a84093c38f3f152a1d0b322846739227dca (diff)
downloadOrca-Renderer.tar.gz
Orca-Renderer.zip
Diffstat (limited to 'desktop/sources/scripts/renderer.js')
-rw-r--r--desktop/sources/scripts/renderer.js17
1 files changed, 11 insertions, 6 deletions
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) {