]> git.r.bdr.sh - rbdr/lissajous/blame_incremental - lib/systems/amplitude_adjuster.js
Update mobile CSS
[rbdr/lissajous] / lib / systems / amplitude_adjuster.js
... / ...
CommitLineData
1import { System } from '@serpentity/serpentity';
2import Ample from '../nodes/ample';
3import { settingsContainer, slider } from '../factories/ui';
4
5const internals = {
6 symbols: {
7 a: '𝛢',
8 b: '𝛣',
9 c: '𝛧'
10 }
11};
12
13export default class AmplitudeAdjuster extends System {
14
15 constructor(container) {
16
17 super();
18 this.container = container;
19 }
20
21 added(engine){
22
23 this.nodes = engine.getNodes(Ample);
24 this.adjusterContainer = settingsContainer({
25 id: 'amplitude-adjuster',
26 label: 'Amplitude'
27 });
28
29 let i = 0;
30 for (const node of this.nodes) {
31 const nodeElement = settingsContainer({
32 id: `amplitude-adjuster-${i}`,
33 label: `ɣ${i + 1}`,
34 level: 3
35 });
36
37 ['a', 'b', 'c'].forEach(key => {
38 nodeElement.appendChild(slider({
39 id: `amplitude-adjuster-${i}-slider-${key}`,
40 min: '0',
41 max: '1',
42 step: '0.01',
43 label: internals.symbols[key],
44 className: `amplitude`,
45 get: () => node.amplitude[key].toString(),
46 set: (value) => (node.amplitude[key] = parseFloat(value))
47 }));
48 });
49
50 this.adjusterContainer.appendChild(nodeElement);
51 ++i;
52 }
53
54 this.container.appendChild(this.adjusterContainer);
55 }
56
57 removed(){
58
59 this.container.removeChild(this.adjusterContainer);
60 delete this.adjusterContainer;
61 delete this.nodes;
62 }
63
64 update(){}
65};