Files
sideline/engine/pipeline_viz.py
David Gwilliam 996ba14b1d feat(demo): use beautiful-mermaid for pipeline visualization
- Add beautiful-mermaid library (single-file ASCII renderer)
- Update pipeline_viz to generate mermaid graphs and render with beautiful-mermaid
- Creates dimensional network visualization with arrows connecting nodes
- Animates through effects and highlights active camera mode
2026-03-16 02:12:03 -07:00

134 lines
3.3 KiB
Python

"""
Pipeline visualization - Uses beautiful-mermaid to render the pipeline as ASCII network.
"""
def generate_mermaid_graph(frame: int = 0) -> str:
"""Generate Mermaid flowchart for the pipeline."""
effects = ["NOISE", "FADE", "GLITCH", "FIREHOSE"]
active_effect = effects[(frame // 10) % 4]
cam_modes = ["VERTICAL", "HORIZONTAL", "OMNI", "FLOATING"]
active_cam = cam_modes[(frame // 40) % 4]
return f"""graph LR
subgraph SOURCES
RSS[RSS Feeds]
Poetry[Poetry DB]
Ntfy[Ntfy Msg]
Mic[Microphone]
end
subgraph FETCH
Fetch(fetch_all)
Cache[(Cache)]
end
subgraph SCROLL
Scroll(StreamController)
Camera({active_cam})
end
subgraph EFFECTS
Noise[NOISE]
Fade[FADE]
Glitch[GLITCH]
Fire[FIREHOSE]
Hud[HUD]
end
subgraph DISPLAY
Term[Terminal]
Web[WebSocket]
Pygame[PyGame]
Sixel[Sixel]
end
RSS --> Fetch
Poetry --> Fetch
Fetch --> Cache
Cache --> Scroll
Scroll --> Noise
Scroll --> Fade
Scroll --> Glitch
Scroll --> Fire
Scroll --> Hud
Noise --> Term
Fade --> Term
Glitch --> Term
Fire --> Term
Hud --> Term
Noise --> Web
Fade --> Web
Glitch --> Web
Fire --> Web
Hud --> Web
Noise --> Pygame
Fade --> Pygame
Glitch --> Pygame
Fire --> Pygame
Hud --> Pygame
Noise --> Sixel
Fade --> Sixel
Glitch --> Sixel
Fire --> Sixel
Hud --> Sixel
style {active_effect} fill:#90EE90
style Camera fill:#87CEEB
"""
def generate_network_pipeline(
width: int = 80, height: int = 24, frame: int = 0
) -> list[str]:
"""Generate dimensional ASCII network visualization using beautiful-mermaid."""
try:
from engine.beautiful_mermaid import render_mermaid_ascii
mermaid_graph = generate_mermaid_graph(frame)
ascii_output = render_mermaid_ascii(mermaid_graph, padding_x=3, padding_y=2)
lines = ascii_output.split("\n")
result = []
for y in range(height):
if y < len(lines):
line = lines[y]
if len(line) < width:
line = line + " " * (width - len(line))
elif len(line) > width:
line = line[:width]
result.append(line)
else:
result.append(" " * width)
status_y = height - 2
if status_y < height:
fps = 60 - (frame % 15)
frame_time = 16.6 + (frame % 5) * 0.1
cam_modes = ["VERTICAL", "HORIZONTAL", "OMNI", "FLOATING"]
cam = cam_modes[(frame // 40) % 4]
effects = ["NOISE", "FADE", "GLITCH", "FIREHOSE"]
eff = effects[(frame // 10) % 4]
anim = "▓▒░ "[frame % 4]
status = f" FPS:{fps:3.0f} │ Frame:{frame_time:4.1f}ms │ {anim} {eff} │ Camera:{cam}"
status = status[: width - 4].ljust(width - 4)
result[status_y] = "" + status + ""
if height > 0:
result[0] = "" * width
result[height - 1] = "" * width
return result
except Exception as e:
return [
f"Error: {e}" + " " * (width - len(f"Error: {e}")) for _ in range(height)
]