add autodraw flag

This commit is contained in:
Felix Roos 2023-12-16 16:19:18 +01:00
parent 7fcd9d8a83
commit c29d032027
2 changed files with 4 additions and 3 deletions

View File

@ -87,7 +87,7 @@ export function initEditor({ initialCode = '', onChange, onEvaluate, onStop, set
export class StrudelMirror {
constructor(options) {
const { root, initialCode = '', onDraw, drawTime = [-2, 2], prebake, settings, ...replOptions } = options;
const { root, initialCode = '', onDraw, drawTime = [-2, 2], autodraw, prebake, settings, ...replOptions } = options;
this.code = initialCode;
this.root = root;
this.miniLocations = [];
@ -110,7 +110,7 @@ export class StrudelMirror {
};
this.prebaked = prebake();
// this.drawFirstFrame();
autodraw && this.drawFirstFrame();
this.repl = repl({
...replOptions,
@ -169,7 +169,7 @@ export class StrudelMirror {
try {
await this.repl.evaluate(this.code, false);
this.drawer.invalidate(this.repl.scheduler);
this.onDraw?.(this.drawer.visibleHaps, 0, []);
this.onDraw?.(this.drawer.visibleHaps, 0, [], this.painters);
} catch (err) {
console.warn('first frame could not be painted');
}

View File

@ -52,6 +52,7 @@ export function MicroRepl({
defaultOutput: webaudioOutput,
getTime: () => getAudioContext().currentTime,
transpiler,
autodraw: !!shouldDraw,
root: containerRef.current,
initialCode: '// LOADING',
pattern: silence,