diff options
author | Devine Lu Linvega <[email protected]> | 2018-12-13 14:27:48 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-12-13 14:27:48 +1200 |
commit | 38daf9ca4441e633b91302044670ece068b06d4c (patch) | |
tree | d65b119d963458bb10e57f30efb3142761befda6 | |
parent | b06ad57f55b0ca9bbbb2bfbb5b3659842c046317 (diff) | |
download | Orca-38daf9ca4441e633b91302044670ece068b06d4c.tar.gz Orca-38daf9ca4441e633b91302044670ece068b06d4c.zip |
Don't request the context each time
-rw-r--r-- | desktop/sources/scripts/terminal.js | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/desktop/sources/scripts/terminal.js b/desktop/sources/scripts/terminal.js index c5416bf..415285b 100644 --- a/desktop/sources/scripts/terminal.js +++ b/desktop/sources/scripts/terminal.js @@ -21,6 +21,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) { this.theme = new Theme(noir, pale) this.el = document.createElement('canvas') + this.context = this.el.getContext('2d') this.size = { width: tile.w * orca.w, height: tile.h * orca.h + (tile.h * 3), ratio: 0.5, grid: { w: 8, h: 8 } } this.isPaused = false this.timer = null @@ -175,12 +176,8 @@ function Terminal (orca, tile = { w: 20, h: 30 }) { // Canvas - this.context = function () { - return this.el.getContext('2d') - } - this.clear = function () { - this.context().clearRect(0, 0, this.size.width, this.size.height) + this.context.clearRect(0, 0, this.size.width, this.size.height) } this.guide = function (x, y) { @@ -216,7 +213,7 @@ function Terminal (orca, tile = { w: 20, h: 30 }) { } this.drawSprite = function (x, y, g, styles = { isCursor: false, isSelection: false, isPort: false, f: null, b: null }) { - const ctx = this.context() + const ctx = this.context ctx.textBaseline = 'bottom' ctx.textAlign = 'center' |