diff options
| author | 2026-01-14 18:15:31 +0800 | |
|---|---|---|
| committer | 2026-01-14 18:15:31 +0800 | |
| commit | eed52135e7d6ffbbbd64070cf567bcf08653c7d5 (patch) | |
| tree | c6fba957f507b2368125f7c2e1dfed6cef5aad53 /ui/src/components/ParticleBackground.svelte | |
| parent | 802b8cf5c0723b606ba5936c060e01d4c83222dd (diff) | |
| download | DropOut-eed52135e7d6ffbbbd64070cf567bcf08653c7d5.tar.gz DropOut-eed52135e7d6ffbbbd64070cf567bcf08653c7d5.zip | |
feat: Enhance UI components and add visual effects
- Updated Sidebar component styles for improved aesthetics and usability.
- Refactored VersionsView component with a new layout and enhanced version filtering.
- Improved DownloadMonitor and GameConsole components for better performance and visual consistency.
- Added new settings for GPU acceleration and visual effects in settings store.
- Introduced ParticleBackground component with customizable effects (Constellation and Saturn).
- Implemented ConstellationEffect and SaturnEffect classes for dynamic background animations.
Diffstat (limited to 'ui/src/components/ParticleBackground.svelte')
| -rw-r--r-- | ui/src/components/ParticleBackground.svelte | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ui/src/components/ParticleBackground.svelte b/ui/src/components/ParticleBackground.svelte new file mode 100644 index 0000000..080f1f2 --- /dev/null +++ b/ui/src/components/ParticleBackground.svelte @@ -0,0 +1,57 @@ +<script lang="ts"> + import { onMount, onDestroy } from "svelte"; + import { ConstellationEffect } from "../lib/effects/ConstellationEffect"; + import { SaturnEffect } from "../lib/effects/SaturnEffect"; + import { settingsState } from "../stores/settings.svelte"; + + let canvas: HTMLCanvasElement; + let activeEffect: any; + + function loadEffect() { + if (activeEffect) { + activeEffect.destroy(); + } + + if (!canvas) return; + + if (settingsState.settings.active_effect === "saturn") { + activeEffect = new SaturnEffect(canvas); + } else { + activeEffect = new ConstellationEffect(canvas); + } + + // Ensure correct size immediately + activeEffect.resize(window.innerWidth, window.innerHeight); + } + + $effect(() => { + const _ = settingsState.settings.active_effect; + if (canvas) { + loadEffect(); + } + }); + + onMount(() => { + const resizeObserver = new ResizeObserver(() => { + if (canvas && activeEffect) { + activeEffect.resize(window.innerWidth, window.innerHeight); + } + }); + + resizeObserver.observe(document.body); + + return () => { + resizeObserver.disconnect(); + if (activeEffect) activeEffect.destroy(); + }; + }); + + onDestroy(() => { + if (activeEffect) activeEffect.destroy(); + }); +</script> + +<canvas + bind:this={canvas} + class="absolute inset-0 z-0 pointer-events-none" +></canvas> |