1const canvas = document.querySelector("canvas");
2const id = canvas?.getAttribute("data-canvas");
3if (!id) {
4 throw new Error("No canvas id found");
5}
6const func = (window as any)["canvas_" + id];
7if (!func) {
8 throw new Error("No canvas function found");
9}
10func(canvas, document.body);