function* show(scene) {
window.onkeydown = function(e) {
if (typeof scene[e.key] === 'function') {
scene[e.key]();
} else if (typeof scene.key === 'function') {
scene.key(e.key);
}
};
const ctx = DOM.context2d(width, width / 1920 * 1024);
while (true) {
const dpi = window.devicePixelRatio;
const width = ctx.canvas.width / dpi;
const height = ctx.canvas.height / dpi;
ctx.clearRect(0, 0, width, height);
ctx.save();
ctx.translate(width / 2, height / 2);
const camera = scene.cam;
const s = height / camera.h;
ctx.scale(s, s);
ctx.translate(-camera.x, -camera.y);
scene.draw(ctx);
ctx.restore();
yield ctx.canvas;
}
}