BoxOfColors commited on
Commit
977875e
Β·
1 Parent(s): b94a4ba

fix: centre crossfade hatch on color boundary, not after it

Browse files

Hatch was drawn at [seg[i+1].start, seg[i].end] which sat entirely inside
seg i+1's color block β€” visually after the edge. The color boundary IS at
seg[i+1].start, so hatch is now centred there: half crossfade on each side.

Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -1750,16 +1750,14 @@ def _build_waveform_html(audio_path: str, segments: list, slot_id: str,
1750
  }});
1751
 
1752
  // ── Crossfade overlap indicators ──
1753
- // The overlap region spans [segments[i+1][0], segments[i][1]]:
1754
- // - last crossfadeSec of seg i fades OUT
1755
- // - first crossfadeSec of seg i+1 fades IN
1756
- // Both halves are the same duration (crossfadeSec) and occupy the same
1757
- // time range, so we draw the hatch centred on the join boundary.
1758
  if (crossfadeSec > 0 && segments.length > 1) {{
1759
  for (let i = 0; i < segments.length - 1; i++) {{
1760
- // The actual overlap window in time
1761
- const overlapStart = segments[i+1][0]; // = seg_i.end - crossfadeSec
1762
- const overlapEnd = segments[i][1]; // = seg_i.end
 
1763
  const xL = (overlapStart / duration) * W;
1764
  const xR = (overlapEnd / duration) * W;
1765
  // Diagonal hatch pattern over the overlap zone
 
1750
  }});
1751
 
1752
  // ── Crossfade overlap indicators ──
1753
+ // The color boundary is at segments[i+1][0] (= seg_i.end - crossfadeSec).
1754
+ // We centre the hatch on that edge: half the crossfade on each color side.
 
 
 
1755
  if (crossfadeSec > 0 && segments.length > 1) {{
1756
  for (let i = 0; i < segments.length - 1; i++) {{
1757
+ // Color edge = segments[i+1][0], hatch spans half on each side
1758
+ const edgeT = segments[i+1][0];
1759
+ const overlapStart = edgeT - crossfadeSec / 2;
1760
+ const overlapEnd = edgeT + crossfadeSec / 2;
1761
  const xL = (overlapStart / duration) * W;
1762
  const xR = (overlapEnd / duration) * W;
1763
  // Diagonal hatch pattern over the overlap zone