aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDevine Lu Linvega <[email protected]>2018-12-13 14:27:48 +1200
committerDevine Lu Linvega <[email protected]>2018-12-13 14:27:48 +1200
commit38daf9ca4441e633b91302044670ece068b06d4c (patch)
treed65b119d963458bb10e57f30efb3142761befda6
parentb06ad57f55b0ca9bbbb2bfbb5b3659842c046317 (diff)
downloadOrca-38daf9ca4441e633b91302044670ece068b06d4c.tar.gz
Orca-38daf9ca4441e633b91302044670ece068b06d4c.zip
Don't request the context each time
-rw-r--r--desktop/sources/scripts/terminal.js9
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'