From ffdb159d57db46f6428e5d609f1ee19833287a4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20T=C3=A4kker?= Date: Mon, 5 Oct 2026 21:14:46 +0200 Subject: [PATCH] Randomize fullscreen gradient motion --- .../Player/Fullscreen/Background/Wash.vue | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/components/Player/Fullscreen/Background/Wash.vue b/app/components/Player/Fullscreen/Background/Wash.vue index 161951d..34ffc43 100644 --- a/app/components/Player/Fullscreen/Background/Wash.vue +++ b/app/components/Player/Fullscreen/Background/Wash.vue @@ -37,6 +37,9 @@ function loadArtwork() { function setPalette(next: AlbumPalette) { palette.value = next +} + +function randomizeMotion() { random = Array.from({ length: 2 }, () => Math.random() * Math.PI * 2) angleJitter = (Math.random() - 0.5) * 0.3 flowParams = [ @@ -47,6 +50,14 @@ function setPalette(next: AlbumPalette) { ] } +function startAnimation() { + cancelAnimationFrame(frame) + startedAt = 0 + lastFrameAt = 0 + randomizeMotion() + frame = requestAnimationFrame(draw) +} + function gradientHash(x: number, y: number): [number, number] { const hash = (a: number, b: number, xScale: number, yScale: number) => { const value = Math.sin(a * xScale + b * yScale) * 43758.5453 @@ -155,11 +166,8 @@ watch(() => props.src, loadArtwork) watch( () => props.active, (active) => { - if (active) { - startedAt = 0 - lastFrameAt = 0 - frame = requestAnimationFrame(draw) - } else { + if (active) startAnimation() + else { cancelAnimationFrame(frame) } }, @@ -167,7 +175,7 @@ watch( onMounted(() => { loadArtwork() - if (props.active) frame = requestAnimationFrame(draw) + if (props.active) startAnimation() }) onBeforeUnmount(() => {