AuroraWaveComponent.vala 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. using Astralis;
  2. using Inversion;
  3. using Spry;
  4. /**
  5. * AuroraWaveComponent - A single aurora wave strip
  6. *
  7. * Renders as a CSS gradient strip with wave animation.
  8. * Multiple waves layered create the aurora borealis effect.
  9. */
  10. public class AuroraWaveComponent : Component {
  11. public int wave_id { get; set; }
  12. public double y_offset { get; set; }
  13. public double amplitude { get; set; }
  14. public double frequency { get; set; }
  15. public string color1 { get; set; default = "#22c55e"; }
  16. public string color2 { get; set; default = "#7c3aed"; }
  17. public double opacity { get; set; default = 0.6; }
  18. public double animation_delay { get; set; default = 0; }
  19. public override string markup { get {
  20. return """
  21. <div sid="wave" class="aurora-wave"></div>
  22. """;
  23. }}
  24. public override async void prepare() throws Error {
  25. // Build CSS custom properties as the style attribute
  26. var style = @"--wave-y: $(y_offset)%%; --wave-amplitude: $(amplitude)px; --wave-freq: $(frequency); --wave-color1: $(color1); --wave-color2: $(color2); --wave-opacity: $(opacity); --wave-delay: $(animation_delay)s; animation-delay: var(--wave-delay);";
  27. this["wave"].set_attribute("style", style);
  28. }
  29. }