| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Astralis;
- using Invercargill;
- using Invercargill.DataStructures;
- using Inversion;
- using Spry;
- /**
- * AuroraCanvasEndpoint - Returns just the aurora waves for HTMX polling
- *
- * This endpoint is polled every 5 seconds by the demo page.
- * It evolves the aurora state and returns fresh wave HTML.
- */
- public class AuroraCanvasEndpoint : Component {
-
- private AuroraState aurora_state = inject<AuroraState>();
- private ComponentFactory factory = inject<ComponentFactory>();
-
- public override string markup { get {
- return """
- <spry-outlet sid="waves"/>
- """;
- }}
-
- public override async void prepare() throws Error {
- // Create wave components
- var waves = new Series<Renderable>();
- foreach (var wave in aurora_state.get_waves()) {
- var component = factory.create<AuroraWaveComponent>();
- component.y_offset = wave.y_offset;
- component.amplitude = wave.amplitude;
- component.frequency = wave.frequency;
- component.color1 = wave.color1;
- component.color2 = wave.color2;
- component.opacity = wave.opacity;
- component.animation_delay = wave.animation_delay;
- waves.add(component);
- }
- set_outlet_children("waves", waves);
- }
-
- public async override void handle_action(string action) throws Error {
- if (action == "Poll") {
- // Evolve the aurora naturally when polled
- aurora_state.evolve();
- // prepare() will be called automatically to render the waves
- }
- }
- }
|