even better sandbox

This commit is contained in:
りき萌 2024-02-18 12:10:02 +01:00
parent 0580db6c68
commit 668e9a050e
10 changed files with 169 additions and 19 deletions

View file

@ -1,3 +1,15 @@
export const internals = {
body: document.createElement("body"),
};
export function body() {
return internals.body;
}
export function addElement(element) {
body().appendChild(element);
}
export class Sketch {
constructor(width, height) {
this.canvas = document.createElement("canvas");
@ -5,6 +17,6 @@ export class Sketch {
this.canvas.height = height;
this.ctx = this.canvas.getContext("2d");
document.body.appendChild(this.canvas);
addElement(this.canvas);
}
}