File size: 1,046 Bytes
0cb9b63
8f47cbe
0cb9b63
8f47cbe
9c9e96e
0cb9b63
 
 
 
 
 
 
 
 
 
9c9e96e
 
 
 
 
 
 
 
8f47cbe
9c9e96e
8f47cbe
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# waveform_renderer.py
# Author: Liam Grinstead
# Collapse gradient waveform (safe)

def render_waveform(agent: dict, score: float) -> str:
    overlay = agent.get("collapse_overlay", {}) or {}
    tau = overlay.get("tau_eff", 1.2)
    beta = overlay.get("beta_band", 0.5)

    try:
        amp = min(40, 12 + float(tau) * 10)
        hue = int(20 + float(beta) * 220)
        speed = max(1.2, 2.4 - float(beta))
    except Exception:
        amp, hue, speed = 18, 140, 2.0

    return f"""
    <svg width="420" height="140" xmlns="http://www.w3.org/2000/svg">
      <text x="10" y="24" font-size="16">Collapse Gradient</text>
      <path d="M10 80 Q80 {80-amp} 150 80 T290 80 T410 80"
            stroke="hsl({hue},80%,50%)" fill="none" stroke-width="3">
        <animate attributeName="stroke" values="hsl({hue},80%,50%);hsl({hue},80%,65%);hsl({hue},80%,50%)"
                 dur="{speed}s" repeatCount="indefinite"/>
      </path>
      <text x="10" y="120" font-size="12">τ_eff={tau} · β={beta} · score={score}</text>
    </svg>
    """