simplify draw plumbing

This commit is contained in:
Felix Roos 2024-03-28 06:25:24 +01:00
parent 1a0dff4081
commit 04a0952a22
6 changed files with 15 additions and 36 deletions

View file

@ -65,13 +65,6 @@ export function Repl({ embedded = false }) {
const init = useCallback(() => {
const drawTime = [-2, 2];
const drawContext = getDrawContext();
const onDraw = (haps, time, frame, painters) => {
painters.length && drawContext.clearRect(0, 0, drawContext.canvas.width * 2, drawContext.canvas.height * 2);
painters?.forEach((painter) => {
// ctx time haps drawTime paintOptions
painter(drawContext, time, haps, drawTime, { clear: false });
});
};
const editor = new StrudelMirror({
sync: true,
defaultOutput: webaudioOutput,
@ -84,7 +77,7 @@ export function Repl({ embedded = false }) {
initialCode: '// LOADING',
pattern: silence,
drawTime,
onDraw,
drawContext,
prebake: async () => Promise.all([modulesLoading, presets]),
onUpdateState: (state) => {
setReplState({ ...state });