MCPcopy Create free account
hub / github.com/CanadaHonk/shadow / constructor

Method constructor

engine/renderer.js:22–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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');

Callers

nothing calls this directly

Calls 5

updateMethod · 0.95
errorFunction · 0.85
getContextMethod · 0.80
createElementMethod · 0.45
appendChildMethod · 0.45

Tested by

no test coverage detected