]>
git.r.bdr.sh - rbdr/lissajous/blob - lib/systems/amplitude_adjuster.js
aed78483b6cd643c06211083bdb8f432dc478cc7
1 import { System
} from '@serpentity/serpentity';
2 import Ample
from '../nodes/ample';
3 import { settingsContainer
, slider
} from '../factories/ui';
14 * UI that adjusts the amplitude of any compatible object
16 export default class AmplitudeAdjuster
extends System
{
18 constructor(container
) {
21 this.container
= container
;
26 this.nodes
= engine
.getNodes(Ample
);
27 this.adjusterContainer
= settingsContainer({
28 id: 'amplitude-adjuster',
33 for (const node
of this.nodes
) {
34 const nodeElement
= settingsContainer({
35 id: `amplitude-adjuster-${i}`,
40 ['a', 'b', 'c'].forEach(key
=> {
41 nodeElement
.appendChild(slider({
42 id: `amplitude-adjuster-${i}-slider-${key}`,
46 label: internals
.symbols
[key
],
47 className: `amplitude`,
48 get: () => node
.amplitude
[key
].toString(),
49 set: (value
) => (node
.amplitude
[key
] = parseFloat(value
))
53 this.adjusterContainer
.appendChild(nodeElement
);
57 this.container
.appendChild(this.adjusterContainer
);
62 this.container
.removeChild(this.adjusterContainer
);
63 delete this.adjusterContainer
;