mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 04:58:27 +00:00
rename inline functions to match global ones, prefixed with _
This commit is contained in:
parent
076b6f1c82
commit
be77882d70
@ -96,7 +96,6 @@ export function registerWidget(type, fn) {
|
|||||||
function getCanvasWidget(id, options = {}) {
|
function getCanvasWidget(id, options = {}) {
|
||||||
const { width = 500, height = 60, pixelRatio = window.devicePixelRatio } = options;
|
const { width = 500, height = 60, pixelRatio = window.devicePixelRatio } = options;
|
||||||
let canvas = document.getElementById(id) || document.createElement('canvas');
|
let canvas = document.getElementById(id) || document.createElement('canvas');
|
||||||
console.log('canvas', canvas);
|
|
||||||
canvas.width = width * pixelRatio;
|
canvas.width = width * pixelRatio;
|
||||||
canvas.height = height * pixelRatio;
|
canvas.height = height * pixelRatio;
|
||||||
canvas.style.width = width + 'px';
|
canvas.style.width = width + 'px';
|
||||||
@ -105,25 +104,19 @@ function getCanvasWidget(id, options = {}) {
|
|||||||
return canvas;
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerWidget('roll', (id, options = {}, pat) => {
|
registerWidget('_pianoroll', (id, options = {}, pat) => {
|
||||||
const ctx = getCanvasWidget(id, options).getContext('2d');
|
const ctx = getCanvasWidget(id, options).getContext('2d');
|
||||||
return pat.pianoroll({ fold: 1, ...options, ctx, id });
|
return pat.pianoroll({ fold: 1, ...options, ctx, id });
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWidget('twist', (id, options = {}, pat) => {
|
registerWidget('_spiral', (id, options = {}, pat) => {
|
||||||
options = { width: 200, height: 200, size: 36, ...options };
|
options = { width: 200, height: 200, size: 36, ...options };
|
||||||
const ctx = getCanvasWidget(id, options).getContext('2d');
|
const ctx = getCanvasWidget(id, options).getContext('2d');
|
||||||
return pat.spiral({ ...options, ctx, id });
|
return pat.spiral({ ...options, ctx, id });
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWidget('osci', (id, options = {}, pat) => {
|
registerWidget('_scope', (id, options = {}, pat) => {
|
||||||
options = { width: 500, height: 60, pos: 0.5, scale: 1, ...options };
|
options = { width: 500, height: 60, pos: 0.5, scale: 1, ...options };
|
||||||
const ctx = getCanvasWidget(id, options).getContext('2d');
|
const ctx = getCanvasWidget(id, options).getContext('2d');
|
||||||
// TODO: find way to clear previous analysers to avoid memory leak
|
|
||||||
// .scope passes id to Pattern.analyze, which is picked up by superdough
|
|
||||||
// .. which calls getAnalyserById(analyze), creating a new analyzer (+buffer) for that key
|
|
||||||
// the id here is the col number where the osci function ends (as passed by the transpiler)
|
|
||||||
// effectively, this means for each evaluation of .osci on a unique col, a new analyser will be created
|
|
||||||
// the problem is that the old ones will never get deleted.. this might pile up some memory
|
|
||||||
return pat.scope({ ...options, ctx, id });
|
return pat.scope({ ...options, ctx, id });
|
||||||
});
|
});
|
||||||
|
|||||||
@ -27,7 +27,7 @@ customElement('strudel-claviature', { options: '{}' }, (props, { element }) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
registerWidget('claviature', (id, options = {}, pat) => {
|
registerWidget('_claviature', (id, options = {}, pat) => {
|
||||||
options = { range: ['A0', 'C8'], scaleY: 1, scaleY: 0.5, scaleX: 0.5, ...options };
|
options = { range: ['A0', 'C8'], scaleY: 1, scaleY: 0.5, scaleX: 0.5, ...options };
|
||||||
const height = (options.upperHeight + options.lowerHeight) * options.scaleY;
|
const height = (options.upperHeight + options.lowerHeight) * options.scaleY;
|
||||||
const el = getSolidWidget('strudel-claviature', id, { ...options, height });
|
const el = getSolidWidget('strudel-claviature', id, { ...options, height });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user