Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 2x 2x 2x 2x 2x | import { IEngineCanvas } from "../engineCanvas.js"; import { IFactory, Factory } from "../models/factory.js"; export interface IFactoryContext extends IFactory<CanvasRenderingContext2D> { } export class FactoryContext extends Factory<CanvasRenderingContext2D> implements IFactoryContext { private readonly _document: Document; private readonly _engineCanvas: IEngineCanvas; private readonly _shadowRoot: ShadowRoot; public constructor(engineCanvas: IEngineCanvas, document: Document) { super(); this._document = document; this._engineCanvas = engineCanvas; this._engineCanvas.style.width = "100%"; this._engineCanvas.style.height = "100%"; this._shadowRoot = this._engineCanvas.attachShadow({ mode: 'closed' }); const container = this._document.createElement('div'); container.style.width = "100%"; container.style.height = "100%"; container.tabIndex = 0; this._shadowRoot.innerHTML = "<style>div:focus{outline: none;}</style>" this._shadowRoot.appendChild(container); } public create(): CanvasRenderingContext2D { const canvas = this._document.createElement("canvas"); canvas.style.position = "absolute"; canvas.style.pointerEvents = "none"; this._shadowRoot.lastChild?.appendChild(canvas); return <CanvasRenderingContext2D>canvas.getContext("2d"); } } |