itty-bitty/docs/render/canvas.boilerplate.js
2022-07-09 07:38:32 -07:00

14 lines
No EOL
570 B
JavaScript

document.body.style = "display:flex; min-height:100vh; justify-content: center; align-items: center; margin:0;"
let canvas = window.canvas = document.createElement("canvas");
canvas.style = "max-height: 100vh; max-width: 100vw;";
document.body.append(canvas);
window.ctx = canvas.getContext("2d");
let update = () => {
var density = window.devicePixelRatio;
window.w = canvas.width = window.innerWidth * density;
window.h = canvas.height = window.innerHeight * density;
console.log("canvas", canvas.width, canvas.height)
draw();
}
(window.onresize = update)()