Dough Git

commit

aaa

commit
29fa7841024788582926fcd8952f94a49707e365
author
Clove Twilight <[email protected]>
date
2026-10-10 10:52

diff --git a/src/lib/components/BetaWarning.svelte b/src/lib/components/BetaWarning.svelte
deleted file mode 100644
index 638d4e1..0000000
--- a/src/lib/components/BetaWarning.svelte
+++ /dev/null
@@ -1,121 +0,0 @@
-<!-- src/lib/components/BetaWarning.svelte
-     DASL-1.2 — (c) Clove Twilight
--->
-
-<script lang="ts">
-	let open = $state(true);
-
-	function close() {
-		open = false;
-	}
-</script>
-
-<svelte:window onkeydown={(e) => open && e.key === 'Escape' && close()} />
-
-{#if open}
-	<div class="overlay" role="presentation" onclick={(e) => e.target === e.currentTarget && close()}>
-		<div
-			class="card"
-			role="alertdialog"
-			aria-modal="true"
-			aria-labelledby="beta-title"
-			aria-describedby="beta-body"
-		>
-			<div class="banner" aria-hidden="true"></div>
-			<p class="eyebrow">
-				<iconsax-icon name="warning-2" type="bulk" size="24" class="icon"></iconsax-icon>Beta
-			</p>
-			<h2 id="beta-title">This is a beta website</h2>
-			<p id="beta-body">
-				It's unfinished, so some pages may be missing, look wrong, or break entirely.
-			</p>
-			<!-- svelte-ignore a11y_autofocus -->
-			<button type="button" onclick={close} autofocus>I understand</button>
-		</div>
-	</div>
-{/if}
-
-<style>
-	.overlay {
-		position: fixed;
-		inset: 0;
-		z-index: 1000;
-		display: grid;
-		place-items: center;
-		padding: 1rem;
-		background: rgb(0 0 0 / 70%);
-		backdrop-filter: blur(4px);
-	}
-
-	.card {
-		width: 100%;
-		max-width: 28rem;
-		padding: 1.75rem;
-		border: 1px solid var(--line);
-		border-radius: 0.75rem;
-		background: var(--bg);
-		box-shadow: 0 1rem 3rem rgb(0 0 0 / 50%);
-		overflow: hidden;
-	}
-
-	/* Same image and fade as the header backdrop */
-	.banner {
-		height: 7rem;
-		margin: -1.75rem -1.75rem 1.25rem;
-		background:
-			linear-gradient(rgb(11 10 13 / 30%), var(--bg)),
-			radial-gradient(70% 60% at 20% 30%, rgb(235 69 158 / 12%), transparent 70%),
-			url('../assets/background.avif') center / cover no-repeat;
-	}
-
-	.eyebrow {
-		display: inline-flex;
-		align-items: center;
-		gap: 0.4rem;
-		margin: 0;
-		padding: 0.2rem 0.65rem;
-		border-radius: 999px;
-		background: var(--accent-dim);
-		color: var(--accent);
-		font-size: 0.8rem;
-		font-weight: 600;
-		letter-spacing: 0.06em;
-		text-transform: uppercase;
-	}
-
-	.eyebrow :global(.icon svg) {
-		width: 1em;
-		height: 1em;
-	}
-
-	h2 {
-		margin: 0.9rem 0 0.4rem;
-		line-height: 1.25;
-	}
-
-	p:not(.eyebrow) {
-		margin: 0 0 1.5rem;
-		color: var(--muted);
-	}
-
-	button {
-		width: 100%;
-		padding: 0.7rem 1rem;
-		border: 0;
-		border-radius: 0.5rem;
-		background: var(--accent);
-		color: #fff;
-		font: inherit;
-		font-weight: 600;
-		cursor: pointer;
-	}
-
-	button:hover {
-		filter: brightness(1.1);
-	}
-
-	button:focus-visible {
-		outline: 2px solid var(--text);
-		outline-offset: 2px;
-	}
-</style>
diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte
index 82b8671..4e06b16 100644
--- a/src/lib/components/Footer.svelte
+++ b/src/lib/components/Footer.svelte
@@ -3,7 +3,6 @@
 -->
 
 <script lang="ts">
-	import noAi from '#lib/assets/no-ai.svg';
 	import '#lib/styles/footer.css';
 	import { websiteDomain } from '#lib';
 </script>
@@ -24,6 +23,6 @@
 	</p>
 
 	<a class="no-ai" href="/ai" title="Read my AI statement">
-		<img src={noAi} alt="Developed by a human, not by AI" width="131" height="42" />
+		<img src='/no-ai.svg' alt="Developed by a human, not by AI" width="131" height="42" />
 	</a>
 </footer>
diff --git a/src/lib/components/SelfieDust.svelte b/src/lib/components/SelfieDust.svelte
new file mode 100644
index 0000000..019bc50
--- /dev/null
+++ b/src/lib/components/SelfieDust.svelte
@@ -0,0 +1,216 @@
+<!-- src/lib/components/SelfieDust.svelte
+     DASL-1.2 — (c) Clove Twilight
+-->
+
+<script lang="ts">
+	import { untrack } from 'svelte';
+
+	// Two stacked photos. Swapping between them breaks the shown one into dust
+	// and blows it into the other. The real <img>s sit on top of the canvas and
+	// only fade out right at the ends, so at rest the page shows crisp images,
+	// not a mosaic
+
+	type Photo = { src: string; alt: string; width: number; height: number; focusY?: number };
+
+	let { from, to, revealed }: { from: Photo; to: Photo; revealed: boolean } = $props();
+
+	const COLS = 48;
+	const ROWS = 60;
+	const DURATION = 1400;
+	// How much of the run is spent staggering particle start times
+	const SPREAD = 0.45;
+	// How far past the frame the dust can fly, in CSS px
+	const BLEED = 12;
+	// Share of t at each end used to crossfade the real image with the mosaic
+	const EDGE = 0.08;
+
+	type Particle = {
+		ax: number;
+		ay: number;
+		bx: number;
+		by: number;
+		cx: number;
+		cy: number;
+		ca: number[];
+		cb: number[];
+		delay: number;
+	};
+
+	let canvas: HTMLCanvasElement | undefined = $state();
+	let box: HTMLDivElement | undefined = $state();
+
+	// 0 is showing `from`, 1 is showing `to`
+	let t = $state(0);
+	let particles: Particle[] | null = null;
+	let animated = $state(false);
+	let frame = 0;
+	let last = 0;
+
+	const fromOpacity = $derived(Math.max(0, 1 - t / EDGE));
+	const toOpacity = $derived(Math.max(0, (t - (1 - EDGE)) / EDGE));
+
+	function load(src: string): Promise<HTMLImageElement> {
+		return new Promise((resolve, reject) => {
+			const img = new Image();
+			img.onload = () => resolve(img);
+			img.onerror = reject;
+			img.src = src;
+		});
+	}
+
+	// Same maths as object-fit: cover, so the mosaic lines up with the <img>
+	function sample(img: HTMLImageElement, focusY: number): Uint8ClampedArray {
+		const c = document.createElement('canvas');
+		c.width = COLS;
+		c.height = ROWS;
+		const ctx = c.getContext('2d', { willReadFrequently: true })!;
+		const scale = Math.max(COLS / img.naturalWidth, ROWS / img.naturalHeight);
+		const w = img.naturalWidth * scale;
+		const h = img.naturalHeight * scale;
+		ctx.imageSmoothingQuality = 'high';
+		ctx.drawImage(img, (COLS - w) / 2, (ROWS - h) * focusY, w, h);
+		return ctx.getImageData(0, 0, COLS, ROWS).data;
+	}
+
+	function build(a: Uint8ClampedArray, b: Uint8ClampedArray): Particle[] {
+		const n = COLS * ROWS;
+		// Each speck of the first photo lands somewhere random in the second
+		const targets = Array.from({ length: n }, (_, i) => i);
+		for (let i = n - 1; i > 0; i--) {
+			const j = Math.floor(Math.random() * (i + 1));
+			[targets[i], targets[j]] = [targets[j], targets[i]];
+		}
+
+		return targets.map((target, i) => {
+			const ax = (i % COLS) / COLS;
+			const ay = Math.floor(i / COLS) / ROWS;
+			const bx = (target % COLS) / COLS;
+			const by = Math.floor(target / COLS) / ROWS;
+			return {
+				ax,
+				ay,
+				bx,
+				by,
+				// Pulled up and to the right like it's caught by a breeze
+				cx: (ax + bx) / 2 + 0.35 + (Math.random() - 0.5) * 0.9,
+				cy: (ay + by) / 2 - 0.3 + (Math.random() - 0.5) * 0.9,
+				ca: Array.from(a.subarray(i * 4, i * 4 + 4)),
+				cb: Array.from(b.subarray(target * 4, target * 4 + 4)),
+				// Sweeps left to right, ragged
+				delay: (ax * 0.75 + Math.random() * 0.25) * SPREAD
+			};
+		});
+	}
+
+	const ease = (p: number) => (p < 0.5 ? 4 * p * p * p : 1 - (-2 * p + 2) ** 3 / 2);
+
+	function draw() {
+		if (!canvas || !box || !particles) return;
+		const dpr = devicePixelRatio || 1;
+		const { width, height } = box.getBoundingClientRect();
+		const cw = width + BLEED * 2;
+		const ch = height + BLEED * 2;
+		if (canvas.width !== Math.round(cw * dpr) || canvas.height !== Math.round(ch * dpr)) {
+			canvas.width = Math.round(cw * dpr);
+			canvas.height = Math.round(ch * dpr);
+		}
+		const ctx = canvas.getContext('2d')!;
+		ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
+		ctx.clearRect(0, 0, cw, ch);
+		if (t <= 0 || t >= 1) return;
+
+		const cell = width / COLS;
+		for (const p of particles) {
+			const raw = Math.min(1, Math.max(0, t * (1 + SPREAD) - p.delay));
+			const k = ease(raw);
+			const u = 1 - k;
+			// Quadratic bezier through the scattered control point
+			const x = u * u * p.ax + 2 * u * k * p.cx + k * k * p.bx;
+			const y = u * u * p.ay + 2 * u * k * p.cy + k * k * p.by;
+			const alpha = (p.ca[3] + (p.cb[3] - p.ca[3]) * k) / 255;
+			if (alpha < 0.02) continue;
+			const r = Math.round(p.ca[0] + (p.cb[0] - p.ca[0]) * k);
+			const g = Math.round(p.ca[1] + (p.cb[1] - p.ca[1]) * k);
+			const bl = Math.round(p.ca[2] + (p.cb[2] - p.ca[2]) * k);
+			// Specks shrink mid-flight so it reads as dust, not tiles
+			const size = cell * (1 - 0.65 * Math.sin(Math.PI * k)) + 0.5;
+			ctx.fillStyle = `rgb(${r} ${g} ${bl} / ${alpha})`;
+			ctx.fillRect(BLEED + x * width, BLEED + y * height, size, size);
+		}
+	}
+
+	function step(time: number) {
+		const dt = last ? time - last : 16;
+		last = time;
+		const target = revealed ? 1 : 0;
+		const move = dt / DURATION;
+		t = target > t ? Math.min(target, t + move) : Math.max(target, t - move);
+		draw();
+		if (t !== target) {
+			frame = requestAnimationFrame(step);
+		} else {
+			frame = 0;
+		}
+	}
+
+	$effect(() => {
+		if (matchMedia('(prefers-reduced-motion: reduce)').matches) return;
+		let cancelled = false;
+		Promise.all([load(from.src), load(to.src)])
+			.then(([a, b]) => {
+				if (cancelled) return;
+				particles = build(sample(a, from.focusY ?? 0.5), sample(b, to.focusY ?? 0.5));
+				animated = true;
+			})
+			.catch(() => {
+				// Falls back to the plain crossfade
+			});
+		return () => {
+			cancelled = true;
+		};
+	});
+
+	$effect(() => {
+		const target = revealed ? 1 : 0;
+		if (!animated) {
+			t = target;
+			return;
+		}
+		// step() reads `revealed` itself, so a swap mid-flight just turns round
+		if (!frame && untrack(() => t) !== target) {
+			last = 0;
+			frame = requestAnimationFrame(step);
+		}
+	});
+
+	$effect(() => () => cancelAnimationFrame(frame));
+</script>
+
+<div class="selfie-stack" class:selfie-fade={!animated} bind:this={box}>
+	<canvas
+		class="selfie-dust"
+		bind:this={canvas}
+		style:inset="-{BLEED}px"
+		style:width="calc(100% + {BLEED * 2}px)"
+		style:height="calc(100% + {BLEED * 2}px)"
+		aria-hidden="true"
+	></canvas>
+	<img
+		class="selfie selfie-pixel"
+		style:object-position="center {(from.focusY ?? 0.5) * 100}%"
+		src={from.src}
+		alt={from.alt}
+		width={from.width}
+		height={from.height}
+		style:opacity={fromOpacity}
+	/>
+	<img
+		class="selfie"
+		style:object-position="center {(to.focusY ?? 0.5) * 100}%"
+		src={to.src}
+		alt=""
+		width={to.width}
+		height={to.height}
+		style:opacity={toOpacity}
+	/>
+</div>
diff --git a/src/lib/styles/header.css b/src/lib/styles/header.css
index a7d0a67..6d5a189 100644
--- a/src/lib/styles/header.css
+++ b/src/lib/styles/header.css
@@ -19,7 +19,7 @@
 	content: '';
 	position: absolute;
 	inset: 0;
-	background: url('../assets/background.avif') center / cover no-repeat;
+	background: url('/background.avif') center / cover no-repeat;
 	opacity: 0.5;
 }
 
diff --git a/src/lib/styles/index.css b/src/lib/styles/index.css
index 45bf5d7..e9b16e8 100644
--- a/src/lib/styles/index.css
+++ b/src/lib/styles/index.css
@@ -19,19 +19,50 @@
 	}
 }
 
+/* Pixel art and the real selfie are stacked. SelfieDust blows one into the
+   other as dust on a canvas behind them. No overflow: hidden here, or the
+   status badge on the corner and the flying dust get clipped */
+
+.selfie-photo {
+	position: relative;
+	aspect-ratio: 4 / 5;
+}
+
+.selfie-stack {
+	position: absolute;
+	inset: 0;
+}
+
+.selfie-dust {
+	position: absolute;
+	pointer-events: none;
+}
+
 .selfie {
+	position: absolute;
+	inset: 0;
 	display: block;
 	width: 100%;
-	height: auto;
-	aspect-ratio: 4 / 5;
+	height: 100%;
 	object-fit: cover;
-	object-position: center 25%;
 	border-radius: 0.6rem;
 }
 
-/* Polaroid-style caption under the photo, inside the frame */
+.selfie-pixel {
+	image-rendering: pixelated;
+}
+
+/* No canvas (reduced motion, or the images failed to load): plain crossfade */
+
+.selfie-fade .selfie {
+	transition: opacity 350ms ease;
+}
+
+/* Polaroid-style caption under the photo, inside the frame. Both captions
+   share one grid cell so swapping them doesn't shift the layout */
 
 .selfie-box figcaption {
+	display: grid;
 	padding: 0.45rem 0 0.1rem;
 	color: var(--muted);
 	font-size: 0.8rem;
@@ -39,16 +70,27 @@
 	text-align: center;
 }
 
-/* Discord status badge, sat on the photo's corner like a Discord avatar */
+.selfie-caption {
+	grid-area: 1 / 1;
+	transition: opacity 350ms ease;
+}
 
-.selfie-photo {
-	position: relative;
+.selfie-caption-hover,
+.selfie-box.revealed .selfie-caption:not(.selfie-caption-hover) {
+	opacity: 0;
 }
 
+.selfie-box.revealed .selfie-caption-hover {
+	opacity: 1;
+}
+
+/* Discord status badge, sat on the photo's corner like a Discord avatar */
+
 .selfie-status {
 	position: absolute;
 	right: -0.6rem;
 	bottom: -0.6rem;
+	z-index: 2;
 	width: 1.9rem;
 	height: 1.9rem;
 	border: 0.35rem solid var(--bg);
@@ -63,6 +105,7 @@
 }
 
 @media (prefers-reduced-motion: reduce) {
+	.selfie-caption,
 	.selfie-status {
 		transition: none;
 	}
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte
index fd282c0..6117a53 100644
--- a/src/routes/+layout.svelte
+++ b/src/routes/+layout.svelte
@@ -9,16 +9,13 @@
 	let { children } = $props();
 	import Header from '#lib/components/Header.svelte';
 	import Footer from '#lib/components/Footer.svelte';
-	import BetaWarning from '#lib/components/BetaWarning.svelte';
 	import { websiteUrl } from '#lib';
-	import background from '#lib/assets/background.avif';
 </script>
 
 <svelte:head>
 	<link rel="icon" href="/favicon.ico" sizes="32x32" />
 	<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
 	<link rel="apple-touch-icon" href="/favicon.png" />
-	<link rel="preload" as="image" href={background} type="image/avif" fetchpriority="high" />
 
 	<meta property="og:site_name" content="Clove Twilight" />
 	<meta property="og:type" content="website" />
@@ -31,7 +28,6 @@
 	<meta name="twitter:site" content="@DoughminCEO" />
 </svelte:head>
 
-<BetaWarning />
 <Header />
 <main>
 	{@render children()}
diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 24ec92d..524bcc4 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -6,11 +6,11 @@
 	import Meta from '#lib/components/Meta.svelte';
 	import '#lib/styles/index.css';
 	import '#lib/styles/presence.css';
-	import selfie from '#lib/assets/selfie.avif';
 	import { untrack } from 'svelte';
 	import { fly } from 'svelte/transition';
 	import ListeningIcon from '#lib/components/ListeningIcon.svelte';
 	import LyricWords from '#lib/components/LyricWords.svelte';
+	import SelfieDust from '#lib/components/SelfieDust.svelte';
 	import { STATUS_LABEL, clamp, subscribePresence, type Presence } from '#lib/scripts/discord.ts';
 	import {
 		fetchLyrics,
@@ -41,6 +41,8 @@
 	let phone = $state<Device | null>(null);
 
 	let reduceMotion = $state(false);
+	// Hover, keyboard focus or a tap on phones swaps to the real selfie
+	let revealed = $state(false);
 	let lyricsRequest = 0;
 
 	$effect(() => {
@@ -156,9 +158,28 @@
 				Looking for the old site? It&apos;s still up at
 				<a href="https://v1.doughmination.gay">v1.doughmination.gay</a>.
 			</p>
-			<figure class="selfie-box">
+			<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
+			<figure
+				class="selfie-box"
+				class:revealed
+				onpointerenter={(e) => e.pointerType !== 'touch' && (revealed = true)}
+				onpointerleave={(e) => e.pointerType !== 'touch' && (revealed = false)}
+				onpointerup={(e) => e.pointerType === 'touch' && (revealed = !revealed)}
+				onfocusin={() => (revealed = true)}
+				onfocusout={() => (revealed = false)}
+			>
 				<div class="selfie-photo">
-					<img class="selfie" src={selfie} alt="Clove&apos;s face" width="560" height="996" />
+					<SelfieDust
+						{revealed}
+						from={{
+							src: '/pixel-image.avif',
+							alt: 'Pixel art portrait of Clove',
+							width: 560,
+							height: 700
+						}}
+						to={{ src: '/selfie.avif', alt: '', width: 560, height: 996, focusY: 0.25 }}
+					/>
+
 					{#if status}
 						<a
 							class="selfie-status"
@@ -169,7 +190,13 @@
 						></a>
 					{/if}
 				</div>
-				<figcaption>My fave selfie ♡</figcaption>
+
+				<figcaption>
+					<span class="selfie-caption">Pixel art ♡</span>
+					<span class="selfie-caption selfie-caption-hover" aria-hidden="true"
+						>My fave selfie ♡</span
+					>
+				</figcaption>
 			</figure>
 		</div>
 		<p class="now">
diff --git a/src/lib/assets/background.avif b/static/background.avif
similarity index 100%
rename from src/lib/assets/background.avif
rename to static/background.avif
diff --git a/src/lib/assets/no-ai.svg b/static/no-ai.svg
similarity index 100%
rename from src/lib/assets/no-ai.svg
rename to static/no-ai.svg
diff --git a/static/pixel-image.avif b/static/pixel-image.avif
new file mode 100644
index 0000000..073594f
Binary files /dev/null and b/static/pixel-image.avif differ
diff --git a/src/lib/assets/selfie.avif b/static/selfie.avif
similarity index 100%
rename from src/lib/assets/selfie.avif
rename to static/selfie.avif