# Examples This directory contains example scripts demonstrating how to use Mainline's features. ## Hybrid Configuration (Recommended) **`hybrid_visualization.py`** - Renders visualization using the hybrid preset-graph format. ```bash python examples/hybrid_visualization.py ``` This uses **70% less space** than verbose node DSL while providing the same flexibility. ### Configuration The hybrid format uses inline objects and arrays: ```toml [pipeline] source = "headlines" camera = { mode = "scroll", speed = 1.0 } effects = [ { name = "noise", intensity = 0.3 }, { name = "fade", intensity = 0.5 } ] display = { backend = "terminal", positioning = "mixed" } ``` See `docs/hybrid-config.md` for complete documentation. --- ## Default Visualization (Verbose Node DSL) **`default_visualization.py`** - Renders the standard Mainline visualization using the verbose graph DSL. ```bash python examples/default_visualization.py ``` This demonstrates the verbose node-based syntax (more flexible for complex DAGs): ```toml [nodes.source] type = "source" source = "headlines" [nodes.camera] type = "camera" mode = "scroll" [nodes.noise] type = "effect" effect = "noise" intensity = 0.3 [nodes.display] type = "display" backend = "terminal" [connections] list = ["source -> camera -> noise -> display"] ``` ## Graph DSL Demonstration **`graph_dsl_demo.py`** - Demonstrates the graph-based DSL in multiple ways: ```bash python examples/graph_dsl_demo.py ``` Shows: - Imperative Python API for building graphs - Dictionary-based API - Graph validation (cycles, disconnected nodes) - Different node types and configurations ## Integration Test **`test_graph_integration.py`** - Tests the graph system with actual pipeline execution: ```bash python examples/test_graph_integration.py ``` Verifies: - Graph loading from TOML - Pipeline execution - Output rendering - Comparison with preset-based pipelines ## Other Demos - **`demo-lfo-effects.py`** - LFO modulation of effect intensities (Pygame display) - **`demo_oscilloscope.py`** - Oscilloscope visualization - **`demo_image_oscilloscope.py`** - Image-based oscilloscope ## Configuration Format Comparison | Format | Use Case | Lines | Example | |--------|----------|-------|---------| | **Hybrid** | Recommended for most use cases | 20 | `hybrid_config.toml` | | **Verbose Node DSL** | Complex DAGs, branching | 39 | `default_visualization.toml` | | **Preset** | Simple configurations | 10 | `presets.toml` | ## Reference - `docs/hybrid-config.md` - Hybrid preset-graph configuration - `docs/graph-dsl.md` - Verbose node-based graph DSL - `docs/presets-usage.md` - Preset system usage