mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-18 00:58:35 +00:00
add draw cleanup
This commit is contained in:
parent
0b206a4d50
commit
1d1d29a163
@ -41,3 +41,14 @@ export const queryEvents = (pattern, callback, seconds) => {
|
||||
queryEvents();
|
||||
}, seconds * 1.5 * 1000);
|
||||
};
|
||||
|
||||
export const cleanup = () => {
|
||||
const ctx = getDrawContext();
|
||||
ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
|
||||
if (window.strudelAnimation) {
|
||||
cancelAnimationFrame(window.strudelAnimation);
|
||||
}
|
||||
if (window.strudelScheduler) {
|
||||
clearInterval(window.strudelScheduler);
|
||||
}
|
||||
};
|
||||
|
||||
@ -39,6 +39,7 @@ Object.assign(globalThis, bootstrapped, Tone, toneHelpers, voicingHelpers, drawH
|
||||
export const evaluate: any = async (code: string) => {
|
||||
const shapeshifted = shapeshifter(code); // transform syntactically correct js code to semantically usable code
|
||||
// console.log('shapeshifted', shapeshifted);
|
||||
drawHelpers.cleanup();
|
||||
let evaluated = await eval(shapeshifted);
|
||||
if (typeof evaluated === 'function') {
|
||||
evaluated = evaluated();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user