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

@ -284,12 +284,14 @@ export function pianoroll({
return this;
}
Pattern.prototype.noteroll = function (options = { fold: 1 }) {
return this.onPaint((ctx, time, haps, drawTime) => {
let [lookbehind, lookahead] = drawTime;
lookbehind = Math.abs(lookbehind);
const cycles = lookahead + lookbehind;
const playhead = lookbehind / cycles;
pianoroll({ ctx, time, haps, ...options, cycles, playhead });
});
function getOptions(drawTime, options) {
let [lookbehind, lookahead] = drawTime;
lookbehind = Math.abs(lookbehind);
const cycles = lookahead + lookbehind;
const playhead = lookbehind / cycles;
return { ...options, cycles, playhead };
}
Pattern.prototype.punchcard = function (options = { fold: 1 }) {
return this.onPaint((ctx, time, haps, drawTime) => pianoroll({ ctx, time, haps, ...getOptions(drawTime, options) }));
};