diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-12-29 00:03:45 +0000 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-12-29 00:03:45 +0000 |
commit | 72b0ebea8bbeaf895343284b990e1643ba540f6e (patch) | |
tree | 6be981a991e61cfaf05bad8bda98fb03f5802551 /js | |
parent | cd83ca3058dac4caa8bb214a244fa45fbb75488c (diff) | |
download | js-canvas-2023-72b0ebea8bbeaf895343284b990e1643ba540f6e.tar.gz js-canvas-2023-72b0ebea8bbeaf895343284b990e1643ba540f6e.zip |
Clear canvas, preserve state
Diffstat (limited to 'js')
-rw-r--r-- | js/game.js | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -163,6 +163,9 @@ class Game { let ctx = this.canvas.getContext("2d"); + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + ctx.save(); + if (this.loadingError == true) { ctx.fillStyle = "rgb(255, 128, 128)"; ctx.font = "caption"; @@ -180,6 +183,8 @@ class Game { Math.floor(ctx.canvas.resSize * (ctx.canvas.width - Math.floor(ctx.canvas.width * 0.2)) / ctx.canvas.dataSize) ), h); + ctx.restore(); + // we don't do this on update because we want // the progress bar to finish drawing if (this.resSize == this.dataSize) { |