1 | import { findDOM } from '../../utils';
|
2 | import { CanvasContext } from './CanvasContext';
|
3 |
|
4 |
|
5 |
|
6 | export const createCanvasContext = (canvasId, inst) => {
|
7 | const el = findDOM(inst);
|
8 | const canvas = el === null || el === void 0 ? void 0 : el.querySelector(`canvas[canvas-id="${canvasId}"]`);
|
9 | const ctx = canvas === null || canvas === void 0 ? void 0 : canvas.getContext('2d');
|
10 | const context = new CanvasContext(canvas, ctx);
|
11 | if (!ctx)
|
12 | return context;
|
13 | context.canvas = canvas;
|
14 | context.ctx = ctx;
|
15 | return context;
|
16 | };
|