reset canvas when pattern changes

+ rename noteroll -> punchcard
This commit is contained in:
Felix Roos 2023-01-13 12:57:35 +01:00
parent 1ac784dc7a
commit ea0e0b4396
8 changed files with 32 additions and 19 deletions

View file

@ -54,9 +54,10 @@ evalScope(
export let loadedSamples = [];
const presets = prebake();
let drawContext;
let drawContext, clearCanvas;
if (typeof window !== 'undefined') {
drawContext = getDrawContext();
clearCanvas = () => drawContext.clearRect(0, 0, drawContext.canvas.height, drawContext.canvas.width);
}
Promise.all([...modules, presets]).then((data) => {
@ -209,6 +210,7 @@ export function Repl({ embedded = false }) {
const handleShuffle = async () => {
const { code, name } = getRandomTune();
logger(`[repl] ✨ loading random tune "${name}"`);
clearCanvas();
resetLoadedSamples();
await prebake(); // declare default samples
await evaluate(code, false);