RemiFabre commited on
Commit
9f9ff6a
·
1 Parent(s): 4a1ed33

QoL changes and removing the visualization for now

Browse files
SimpleDances/main.py CHANGED
@@ -120,7 +120,11 @@ DANCE_CATALOG: dict[
120
  }
121
 
122
  DANCE_ORDER = sorted(DANCE_CATALOG.keys())
123
- DEFAULT_DANCE = "simple_nod" if "simple_nod" in DANCE_CATALOG else DANCE_ORDER[0]
 
 
 
 
124
  ANTENNA_CHOICES = sorted(AVAILABLE_ANTENNA_MOVES.keys())
125
 
126
 
@@ -414,7 +418,7 @@ class Simpledances(ReachyMiniApp):
414
 
415
  runtime_state: dict[str, Any] = {
416
  "selected": DEFAULT_DANCE,
417
- "playing": False,
418
  "bpm": clamp(persisted["globals"].get("bpm", DEFAULT_GLOBALS["bpm"]), BPM_RANGE),
419
  "dance_params": dance_params,
420
  "factory_params": factory_params,
 
120
  }
121
 
122
  DANCE_ORDER = sorted(DANCE_CATALOG.keys())
123
+ DEFAULT_DANCE = (
124
+ "groovy_sway_and_roll"
125
+ if "groovy_sway_and_roll" in DANCE_CATALOG
126
+ else DANCE_ORDER[0]
127
+ )
128
  ANTENNA_CHOICES = sorted(AVAILABLE_ANTENNA_MOVES.keys())
129
 
130
 
 
418
 
419
  runtime_state: dict[str, Any] = {
420
  "selected": DEFAULT_DANCE,
421
+ "playing": True,
422
  "bpm": clamp(persisted["globals"].get("bpm", DEFAULT_GLOBALS["bpm"]), BPM_RANGE),
423
  "dance_params": dance_params,
424
  "factory_params": factory_params,
SimpleDances/static/index.html CHANGED
@@ -82,13 +82,12 @@
82
  <div class="card-header">
83
  <div>
84
  <h2>Kinesthetic Visualizer</h2>
85
- <p>Every DoF feeds the glow. Watch orientation, translation, and antennas carve luminous trails.</p>
86
  </div>
87
  <span class="chip" id="vizBpm">0 BPM</span>
88
  </div>
89
- <div class="viz-stage">
90
- <canvas id="vizCanvas"></canvas>
91
- <div class="viz-legend" id="vizLegend"></div>
92
  </div>
93
  </section>
94
  </main>
 
82
  <div class="card-header">
83
  <div>
84
  <h2>Kinesthetic Visualizer</h2>
85
+ <p>The kinetic drawing is temporarily removed. Ping the author if this feature matters to you!</p>
86
  </div>
87
  <span class="chip" id="vizBpm">0 BPM</span>
88
  </div>
89
+ <div class="viz-placeholder">
90
+ <p>¯\_(ツ)_/¯</p>
 
91
  </div>
92
  </section>
93
  </main>
SimpleDances/static/main.js CHANGED
@@ -12,8 +12,6 @@ const saveParamsBtn = document.getElementById('saveParams');
12
  const applyParamsBtn = document.getElementById('applyParams');
13
  const resetParamsBtn = document.getElementById('resetParams');
14
  const toast = document.getElementById('toast');
15
- const vizCanvas = document.getElementById('vizCanvas');
16
- const vizLegend = document.getElementById('vizLegend');
17
  const vizBpm = document.getElementById('vizBpm');
18
 
19
  const currentUrl = new URL(window.location.href);
@@ -43,159 +41,6 @@ let applyInFlight = false;
43
  let saveInFlight = false;
44
  let resetInFlight = false;
45
  let pendingBpmValue = null;
46
- const vizNodes = [];
47
- const vizConfig = [
48
- {
49
- key: 'orientation',
50
- index: 0,
51
- label: 'Roll Orbit',
52
- subtitle: 'Head roll',
53
- type: 'angle',
54
- shape: 'rose',
55
- petals: 4,
56
- color: '#ff8ba7',
57
- glow: '#ffd4e0',
58
- scale: Math.PI / 2,
59
- phaseScale: 1.0,
60
- baseRadius: 60,
61
- amplitude: 36,
62
- layoutAngle: 0,
63
- layoutRadius: 0,
64
- },
65
- {
66
- key: 'orientation',
67
- index: 1,
68
- label: 'Pitch Bloom',
69
- subtitle: 'Head pitch',
70
- type: 'angle',
71
- shape: 'lemniscate',
72
- color: '#ffc16b',
73
- glow: '#ffe1ab',
74
- scale: Math.PI / 2,
75
- phaseScale: 0.9,
76
- baseRadius: 70,
77
- amplitude: 42,
78
- layoutAngle: Math.PI / 4,
79
- layoutRadius: 40,
80
- },
81
- {
82
- key: 'orientation',
83
- index: 2,
84
- label: 'Yaw Halo',
85
- subtitle: 'Head yaw',
86
- type: 'angle',
87
- shape: 'cardioid',
88
- color: '#cab0ff',
89
- glow: '#e8dcff',
90
- scale: Math.PI / 2,
91
- phaseScale: 1.15,
92
- baseRadius: 55,
93
- amplitude: 34,
94
- layoutAngle: Math.PI / 2,
95
- layoutRadius: 30,
96
- },
97
- {
98
- key: 'position',
99
- index: 0,
100
- label: 'X Dance',
101
- subtitle: 'X shift',
102
- type: 'linear',
103
- shape: 'lissajous',
104
- color: '#7cf5ff',
105
- glow: '#c4fbff',
106
- scale: 0.03,
107
- multiplier: 40,
108
- ampX: 70,
109
- ampY: 40,
110
- freqX: 3,
111
- freqY: 2,
112
- phaseShift: Math.PI / 4,
113
- baseSpeed: 0.01,
114
- speedScale: 0.02,
115
- layoutAngle: Math.PI,
116
- layoutRadius: 20,
117
- },
118
- {
119
- key: 'position',
120
- index: 1,
121
- label: 'Y Bloom',
122
- subtitle: 'Y shift',
123
- type: 'linear',
124
- shape: 'epitrochoid',
125
- color: '#6df9d5',
126
- glow: '#b7ffe8',
127
- scale: 0.03,
128
- multiplier: 38,
129
- R: 50,
130
- r: 12,
131
- d: 18,
132
- baseSpeed: 0.012,
133
- speedScale: 0.018,
134
- layoutAngle: (3 * Math.PI) / 4,
135
- layoutRadius: 30,
136
- },
137
- {
138
- key: 'position',
139
- index: 2,
140
- label: 'Z Bloom',
141
- subtitle: 'Z lift',
142
- type: 'linear',
143
- shape: 'butterfly',
144
- color: '#8dff8a',
145
- glow: '#d2ffd0',
146
- scale: 0.03,
147
- multiplier: 35,
148
- amplitude: 40,
149
- baseSpeed: 0.013,
150
- speedScale: 0.02,
151
- layoutAngle: (5 * Math.PI) / 4,
152
- layoutRadius: 30,
153
- },
154
- {
155
- key: 'antennas',
156
- index: 0,
157
- label: 'Left Antenna',
158
- subtitle: 'Left antenna',
159
- type: 'angle',
160
- shape: 'star',
161
- petals: 5,
162
- color: '#ff8cda',
163
- glow: '#ffc2ef',
164
- scale: Math.PI / 2,
165
- phaseScale: 1.1,
166
- baseRadius: 45,
167
- amplitude: 30,
168
- layoutAngle: (7 * Math.PI) / 4,
169
- layoutRadius: 35,
170
- },
171
- {
172
- key: 'antennas',
173
- index: 1,
174
- label: 'Right Antenna',
175
- subtitle: 'Right antenna',
176
- type: 'angle',
177
- shape: 'astroid',
178
- color: '#ffb8ad',
179
- glow: '#ffd5cf',
180
- scale: Math.PI / 2,
181
- phaseScale: 1.05,
182
- baseRadius: 50,
183
- amplitude: 28,
184
- layoutAngle: (3 * Math.PI) / 2,
185
- layoutRadius: 20,
186
- },
187
- ];
188
-
189
- function angleDiff(a, b) {
190
- let d = a - b;
191
- const twoPi = Math.PI * 2;
192
- d = ((d + Math.PI) % twoPi + twoPi) % twoPi - Math.PI;
193
- return d;
194
- }
195
-
196
- function clamp(value, min, max) {
197
- return Math.min(Math.max(value, min), max);
198
- }
199
 
200
  function debounce(fn, delay) {
201
  let timer;
@@ -553,216 +398,21 @@ function updateGlobalsUI() {
553
  bpmRange.value = state.bpm;
554
  bpmInput.value = state.bpm.toFixed(0);
555
  bpmDisplay.textContent = `${Math.round(state.bpm)} BPM`;
556
- vizBpm.textContent = `${Math.round(state.bpm)} BPM`;
557
- }
558
-
559
- let vizCtx;
560
- let vizWidth = 900;
561
- let vizHeight = 520;
562
-
563
- function initVisualizationStage() {
564
- if (!vizCanvas || !vizLegend) {
565
- return;
566
  }
567
-
568
- const parentWidth = vizCanvas.parentElement ? vizCanvas.parentElement.clientWidth : 900;
569
- vizWidth = Math.max(500, parentWidth);
570
- vizHeight = window.innerWidth < 820 ? 420 : 520;
571
- const dpr = window.devicePixelRatio || 1;
572
- vizCanvas.width = vizWidth * dpr;
573
- vizCanvas.height = vizHeight * dpr;
574
- vizCanvas.style.width = `${vizWidth}px`;
575
- vizCanvas.style.height = `${vizHeight}px`;
576
- vizCtx = vizCanvas.getContext('2d');
577
- vizCtx.scale(dpr, dpr);
578
- vizCtx.fillStyle = '#05060a';
579
- vizCtx.fillRect(0, 0, vizWidth, vizHeight);
580
-
581
- vizLegend.innerHTML = '';
582
- vizNodes.length = 0;
583
-
584
- vizConfig.forEach((cfg) => {
585
- const layoutRadius = cfg.layoutRadius || 0;
586
- const angle = cfg.layoutAngle || 0;
587
- const centerX = vizWidth / 2 + Math.cos(angle) * layoutRadius;
588
- const centerY = vizHeight / 2 + Math.sin(angle) * layoutRadius;
589
-
590
- const legendItem = document.createElement('div');
591
- legendItem.className = 'viz-legend-item';
592
- const dot = document.createElement('span');
593
- dot.className = 'viz-dot';
594
- dot.style.background = cfg.color;
595
- const text = document.createElement('div');
596
- const title = document.createElement('strong');
597
- title.textContent = cfg.label;
598
- const subtitle = document.createElement('p');
599
- subtitle.textContent = cfg.subtitle;
600
- text.appendChild(title);
601
- text.appendChild(subtitle);
602
- legendItem.appendChild(dot);
603
- legendItem.appendChild(text);
604
- vizLegend.appendChild(legendItem);
605
-
606
- vizNodes.push({
607
- config: cfg,
608
- centerX,
609
- centerY,
610
- currentValue: 0,
611
- targetValue: 0,
612
- lastRaw: 0,
613
- hasRaw: false,
614
- unwrappedRadians: 0,
615
- timePhase: 0,
616
- prevPoint: { x: centerX, y: centerY },
617
- });
618
- });
619
- }
620
-
621
- function updateVisualizationTargets(offsets) {
622
- vizNodes.forEach((node) => {
623
- const cfg = node.config;
624
- const values = offsets[cfg.key] || [];
625
- const raw = Number(values[cfg.index] || 0);
626
- if (cfg.type === 'angle') {
627
- if (node.hasRaw) {
628
- node.unwrappedRadians += angleDiff(raw, node.lastRaw);
629
- } else {
630
- node.unwrappedRadians = raw;
631
- node.hasRaw = true;
632
- }
633
- node.lastRaw = raw;
634
- node.targetValue = node.unwrappedRadians;
635
- } else {
636
- node.targetValue = raw;
637
- }
638
- });
639
- }
640
-
641
- function computeStagePoint(node, theta, normalized) {
642
- const cfg = node.config;
643
- const cx = node.centerX;
644
- const cy = node.centerY;
645
- const amp = (cfg.amplitude || 40) * (0.6 + 0.4 * Math.abs(normalized));
646
- switch (cfg.shape) {
647
- case 'rose': {
648
- const petals = cfg.petals || 4;
649
- const r = cfg.baseRadius + amp * Math.sin(petals * theta);
650
- return {
651
- x: cx + r * Math.cos(theta),
652
- y: cy + r * Math.sin(theta),
653
- };
654
- }
655
- case 'lemniscate': {
656
- const a = cfg.baseRadius + amp;
657
- const x = cx + a * Math.sin(theta);
658
- const y = cy + a * Math.sin(theta) * Math.cos(theta);
659
- return { x, y };
660
- }
661
- case 'cardioid': {
662
- const r = cfg.baseRadius + amp * (1 - Math.sin(theta));
663
- return {
664
- x: cx + r * Math.cos(theta),
665
- y: cy + r * Math.sin(theta),
666
- };
667
- }
668
- case 'lissajous': {
669
- const ampX = (cfg.ampX || 60) * (0.5 + Math.abs(normalized));
670
- const ampY = (cfg.ampY || 40) * (0.5 + Math.abs(normalized));
671
- return {
672
- x: cx + ampX * Math.sin((cfg.freqX || 3) * theta + (cfg.phaseShift || 0)),
673
- y: cy + ampY * Math.sin((cfg.freqY || 2) * theta),
674
- };
675
- }
676
- case 'epitrochoid': {
677
- const R = cfg.R || 60;
678
- const r = cfg.r || 10;
679
- const d = cfg.d || 20;
680
- const scale = 0.8 + Math.abs(normalized);
681
- const x = cx + ((R + r) * Math.cos(theta) - scale * d * Math.cos(((R + r) / r) * theta));
682
- const y = cy + ((R + r) * Math.sin(theta) - scale * d * Math.sin(((R + r) / r) * theta));
683
- return { x, y };
684
- }
685
- case 'butterfly': {
686
- const mod = normalized + 1;
687
- const r = amp * (Math.exp(Math.sin(theta)) - 2 * Math.cos(4 * theta) + Math.pow(Math.sin((2 * theta - Math.PI) / 24), 5));
688
- return {
689
- x: cx + r * Math.cos(theta) * mod,
690
- y: cy + r * Math.sin(theta) * mod,
691
- };
692
- }
693
- case 'star': {
694
- const petals = cfg.petals || 5;
695
- const r = cfg.baseRadius + amp * Math.cos(petals * theta);
696
- return {
697
- x: cx + r * Math.cos(theta),
698
- y: cy + r * Math.sin(theta),
699
- };
700
- }
701
- case 'astroid': {
702
- const a = cfg.baseRadius + amp;
703
- return {
704
- x: cx + a * Math.pow(Math.cos(theta), 3),
705
- y: cy + a * Math.pow(Math.sin(theta), 3),
706
- };
707
- }
708
- default:
709
- return { x: cx, y: cy };
710
- }
711
- }
712
-
713
- function animateVisualization() {
714
- if (!vizCtx) {
715
- requestAnimationFrame(animateVisualization);
716
- return;
717
- }
718
- vizCtx.fillStyle = 'rgba(5, 6, 10, 0.01)';
719
- vizCtx.fillRect(0, 0, vizWidth, vizHeight);
720
-
721
- vizNodes.forEach((node) => {
722
- const cfg = node.config;
723
- node.currentValue += (node.targetValue - node.currentValue) * 0.08;
724
- let theta;
725
- if (cfg.type === 'angle') {
726
- theta = node.currentValue * (cfg.phaseScale || 1);
727
- } else {
728
- node.timePhase += (cfg.baseSpeed || 0.01) + Math.abs(node.currentValue) * (cfg.speedScale || 0.02);
729
- theta = node.timePhase;
730
- }
731
- const normalized = clamp(node.currentValue / (cfg.scale || 1), -1, 1);
732
- const point = computeStagePoint(node, theta, normalized);
733
- vizCtx.lineCap = 'round';
734
- vizCtx.strokeStyle = cfg.color;
735
- vizCtx.lineWidth = 1.2 + Math.abs(normalized) * 2.5;
736
- vizCtx.beginPath();
737
- vizCtx.moveTo(node.prevPoint.x, node.prevPoint.y);
738
- vizCtx.lineTo(point.x, point.y);
739
- vizCtx.stroke();
740
-
741
- vizCtx.fillStyle = cfg.color;
742
- vizCtx.shadowColor = cfg.glow || cfg.color;
743
- vizCtx.shadowBlur = 10;
744
- vizCtx.beginPath();
745
- vizCtx.arc(point.x, point.y, 2 + Math.abs(normalized) * 2.5, 0, Math.PI * 2);
746
- vizCtx.fill();
747
- vizCtx.shadowBlur = 0;
748
-
749
- node.prevPoint = point;
750
- });
751
-
752
- requestAnimationFrame(animateVisualization);
753
  }
754
 
755
  async function pollVisualization() {
756
  try {
757
  const data = await apiRequest('api/visualization');
758
- if (data && data.offsets) {
759
- updateVisualizationTargets(data.offsets);
760
- }
761
  if (typeof data?.playing === 'boolean') {
762
  updatePlayingChip(data.playing);
763
  }
764
  if (typeof data?.bpm === 'number') {
765
- vizBpm.textContent = `${Math.round(data.bpm)} BPM`;
 
 
766
  }
767
  } catch (error) {
768
  // Swallow visualization errors to avoid noisy UI.
@@ -882,13 +532,11 @@ function attachEventListeners() {
882
 
883
  async function init() {
884
  setStatus('Booting UI…');
885
- initVisualizationStage();
886
  attachEventListeners();
887
  updateActionButtons();
888
  await loadDances();
889
  await refreshState();
890
  pollVisualization();
891
- requestAnimationFrame(animateVisualization);
892
  }
893
 
894
  init();
 
12
  const applyParamsBtn = document.getElementById('applyParams');
13
  const resetParamsBtn = document.getElementById('resetParams');
14
  const toast = document.getElementById('toast');
 
 
15
  const vizBpm = document.getElementById('vizBpm');
16
 
17
  const currentUrl = new URL(window.location.href);
 
41
  let saveInFlight = false;
42
  let resetInFlight = false;
43
  let pendingBpmValue = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  function debounce(fn, delay) {
46
  let timer;
 
398
  bpmRange.value = state.bpm;
399
  bpmInput.value = state.bpm.toFixed(0);
400
  bpmDisplay.textContent = `${Math.round(state.bpm)} BPM`;
401
+ if (vizBpm) {
402
+ vizBpm.textContent = `${Math.round(state.bpm)} BPM`;
 
 
 
 
 
 
 
 
403
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  }
405
 
406
  async function pollVisualization() {
407
  try {
408
  const data = await apiRequest('api/visualization');
 
 
 
409
  if (typeof data?.playing === 'boolean') {
410
  updatePlayingChip(data.playing);
411
  }
412
  if (typeof data?.bpm === 'number') {
413
+ if (vizBpm) {
414
+ vizBpm.textContent = `${Math.round(data.bpm)} BPM`;
415
+ }
416
  }
417
  } catch (error) {
418
  // Swallow visualization errors to avoid noisy UI.
 
532
 
533
  async function init() {
534
  setStatus('Booting UI…');
 
535
  attachEventListeners();
536
  updateActionButtons();
537
  await loadDances();
538
  await refreshState();
539
  pollVisualization();
 
540
  }
541
 
542
  init();
SimpleDances/static/style.css CHANGED
@@ -295,70 +295,15 @@ input[type="number"]:focus {
295
  margin-bottom: 24px;
296
  }
297
 
298
- .viz-stage {
299
- display: flex;
300
- flex-direction: column;
301
- gap: 16px;
302
- margin-top: 16px;
303
- }
304
-
305
- .viz-stage canvas {
306
- width: 100%;
307
- min-height: 360px;
308
- border-radius: 22px;
309
- border: 1px solid rgba(255, 255, 255, 0.08);
310
- background: #05060a;
311
- box-shadow: 0 25px 70px rgba(0, 0, 0, 0.45);
312
- }
313
-
314
- .viz-legend {
315
- display: flex;
316
- flex-wrap: wrap;
317
- gap: 10px;
318
- }
319
-
320
- .viz-legend-item {
321
- display: flex;
322
- align-items: center;
323
- gap: 10px;
324
- padding: 8px 12px;
325
- border-radius: 12px;
326
- border: 1px solid rgba(255, 255, 255, 0.08);
327
  background: rgba(255, 255, 255, 0.03);
328
- box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.02);
329
- }
330
-
331
- .viz-legend-item strong {
332
- display: block;
333
- font-size: 0.95rem;
334
- }
335
-
336
- .viz-legend-item p {
337
- margin: 2px 0 0;
338
- font-size: 0.8rem;
339
  color: var(--text-muted);
340
- }
341
-
342
- .viz-dot {
343
- width: 12px;
344
- height: 12px;
345
- border-radius: 50%;
346
- }
347
-
348
- @media (min-width: 960px) {
349
- .viz-stage {
350
- flex-direction: row;
351
- align-items: flex-start;
352
- }
353
-
354
- .viz-stage canvas {
355
- flex: 3;
356
- }
357
-
358
- .viz-legend {
359
- flex: 1;
360
- flex-direction: column;
361
- }
362
  }
363
 
364
  .params-grid {
 
295
  margin-bottom: 24px;
296
  }
297
 
298
+ .viz-placeholder {
299
+ margin-top: 12px;
300
+ padding: 24px;
301
+ border-radius: 16px;
302
+ border: 1px dashed rgba(255, 255, 255, 0.2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  background: rgba(255, 255, 255, 0.03);
 
 
 
 
 
 
 
 
 
 
 
304
  color: var(--text-muted);
305
+ font-size: 0.95rem;
306
+ line-height: 1.4;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  }
308
 
309
  .params-grid {