]>
git.r.bdr.sh - rbdr/lissajous/blob - lib/systems/frequency_adjuster.js
b92bab6af4ad665e1add2dd1755bfdc812cba996
1 import { System
} from '@serpentity/serpentity';
2 import Frequent
from '../nodes/frequent';
3 import { settingsContainer
, slider
} from '../factories/ui';
13 export default class FrequencyAdjuster
extends System
{
15 constructor(container
) {
18 this.container
= container
;
23 this.nodes
= engine
.getNodes(Frequent
);
24 this.adjusterContainer
= settingsContainer({
25 id: 'frequency-adjuster',
30 for (const node
of this.nodes
) {
31 const nodeElement
= settingsContainer({
32 id: `frequency-adjuster-${i}`,
37 ['a', 'b', 'c'].forEach(key
=> {
38 nodeElement
.appendChild(slider({
39 id: `frequency-adjuster-${i}-slider-${key}`,
41 max: (2 * Math
.PI
).toString(),
43 shiftStep: (Math
.PI
/ 8).toString(),
44 label: internals
.symbols
[key
],
45 className: `frequency`,
46 get: () => node
.frequency
[key
].toString(),
47 set: (value
) => (node
.frequency
[key
] = parseFloat(value
))
51 this.adjusterContainer
.appendChild(nodeElement
);
55 this.container
.appendChild(this.adjusterContainer
);
60 this.container
.removeChild(this.adjusterContainer
);
61 delete this.adjusterContainer
;