()
| 20 | } |
| 21 | |
| 22 | constructor() { |
| 23 | this.canvas = document.createElement('canvas'); |
| 24 | |
| 25 | this.canvas.style.position = 'absolute'; |
| 26 | this.canvas.style.top = '0'; |
| 27 | this.canvas.style.left = '0'; |
| 28 | |
| 29 | this.canvas.style.imageRendering = 'crisp-edges'; |
| 30 | |
| 31 | this.ctx = this.canvas.getContext('2d', { alpha: false }); |
| 32 | |
| 33 | this.ctx.imageSmoothingEnabled = false; |
| 34 | |
| 35 | this.canvas.style.width = cWidth + "px"; |
| 36 | this.canvas.style.height = cHeight + "px"; |
| 37 | this.canvas.width = cWidth * renderScale; |
| 38 | this.canvas.height = cHeight * renderScale; |
| 39 | |
| 40 | this.ctx.scale(renderScale, renderScale); |
| 41 | |
| 42 | document.body.appendChild(this.canvas); |
| 43 | |
| 44 | const _update = this.update.bind(this); |
| 45 | this.update = (() => { |
| 46 | try { |
| 47 | _update(); |
| 48 | } catch (e) { |
| 49 | error(e); |
| 50 | requestAnimationFrame(this.update); |
| 51 | } |
| 52 | }).bind(this); |
| 53 | this.update(); |
| 54 | |
| 55 | if (globalThis.node) { |
| 56 | this.measureCanvas = this.canvas; |
| 57 | this.measureCtx = this.ctx; |
| 58 | } |
| 59 | |
| 60 | globalThis._renderer = this; |
| 61 | } |
| 62 | |
| 63 | makeCanvas() { |
| 64 | const el = document.createElement('canvas'); |
nothing calls this directly
no test coverage detected