Files
wizwar6e/packages/web/src/fx-sprites/DieDrop.svelte
T
Eric WagonerandClaude Fable 5.1 8dfd0e0c29 The art refresh: textures, tokens, conjurations, and cel flourishes
Eric repainted the maze. The first-person materials are painterly
sandstone, flagstone, and iron; the hand-drawn token set is redrawn
with matching chests and hats; the standing conjurations — hedges,
jello, dust, safe, warp light — and the effect billboards are redone
in the same hand; and the board's flourishes trade their filters and
gradients for flat cel silhouettes cut from five shared shapes, which
read better against the counters and cost a phone nothing. Thirty
scene goldens re-blessed against the new walls.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jm2auWk6RP71CjaAb4FMoG
2026-09-14 20:28:52 -04:00

140 lines
4.4 KiB
Svelte

<script lang="ts">
import type { FxOf } from "../fx";
import { center } from "./geom";
let { fx }: { fx: FxOf<"die-drop"> } = $props();
const c = $derived(center(fx.at));
const aim = $derived(center(fx.aim));
const drifted = $derived(fx.at.x !== fx.aim.x || fx.at.y !== fx.aim.y);
const DEBRIS = [15, 80, 150, 210, 275, 340];
</script>
<!-- The aiming mark: where the caster prayed it would land -->
<circle cx={aim.x} cy={aim.y} r="15" class="aim" />
{#if drifted}
<line x1={aim.x} y1={aim.y} x2={c.x} y2={c.y} class="drift" />
{/if}
<!-- The gathering shadow, then the die itself, out of a clear sky -->
<ellipse cx={c.x} cy={c.y + 8} rx="16" ry="7" class="die-shadow" />
<g class="die" style={`transform-origin: ${c.x}px ${c.y}px`}>
<g transform={`translate(${c.x} ${c.y})`}>
<!-- A tetrahedral d4: two triangular faces share the apex-to-front edge. -->
<path d="M 0 -19 L -18 10 -2 17 17 9 Z" class="die-body" />
<path d="M 0 -19 L -2 17 17 9 Z" fill="#c4b590" />
<path d="M 0 -19 L -2 17" class="ridge" />
<path d="M -1 -14 L -14 8" fill="none" stroke="#fff7df" stroke-width="1.4" />
<!-- Apex-reading numerals: both faces share 4 at the top and 3 at the
front base vertex; the other base corners carry 1 and 2. -->
<g class="numerals">
<path d="M -3 -10 L -5 -6 -1.5 -6 M -2.5 -10 L -2.5 -3" />
<path d="M 3 -9 L 1.5 -5 5 -5 M 4 -9 L 4 -2" />
<path d="M -14 6 L -12 4 -12 10 M -14 10 L -10 11" />
<path d="M 9 5 Q 11 2 13 5 Q 14 7 9 10 L 14 9" />
<path d="M -8 10 Q -3 9 -6 12 Q -2 14 -7 14" />
<path d="M 2 10 Q 6 8 4 11 Q 7 12 2 14" />
</g>
</g>
</g>
<!-- Impact: ring and flung grit -->
<circle cx={c.x} cy={c.y} r="14" class="impact" />
{#each DEBRIS as deg, i (deg)}
<line
x1={c.x + 14 * Math.cos((deg * Math.PI) / 180)}
y1={c.y + 14 * Math.sin((deg * Math.PI) / 180)}
x2={c.x + 26 * Math.cos((deg * Math.PI) / 180)}
y2={c.y + 26 * Math.sin((deg * Math.PI) / 180)}
class={`grit g${i % 3}`}
style={`transform-origin: ${c.x}px ${c.y}px`}
/>
{/each}
<style>
.aim {
fill: none;
stroke: #8d2f23;
stroke-width: 2;
stroke-dasharray: 5 4;
opacity: 0;
animation: aim-mark 0.5s ease-out forwards;
}
.drift {
stroke: #8d2f23;
stroke-width: 1.5;
stroke-dasharray: 3 4;
opacity: 0;
animation: drift-line 0.5s ease-out 0.55s forwards;
}
.die-shadow {
fill: rgba(43, 34, 24, 0.5);
animation: shadow-loom 0.55s ease-in forwards;
transform-box: fill-box;
transform-origin: center;
}
.die {
animation: die-fall 0.55s cubic-bezier(0.5, 0, 0.9, 0.6) forwards,
die-settle 0.9s ease-out 0.55s forwards;
}
.die-body {
fill: #efe8d4;
stroke: #2b2218;
stroke-width: 2.5;
stroke-linejoin: round;
}
.ridge { fill: none; stroke: #7b694e; stroke-width: 1.2; }
.numerals {
fill: none;
stroke: #2b2218;
stroke-width: 1.05;
stroke-linecap: round;
stroke-linejoin: round;
}
.impact {
fill: none;
stroke: #7c6a4f;
stroke-width: 3;
opacity: 0;
transform-box: fill-box;
transform-origin: center;
animation: impact-ring 0.5s ease-out 0.55s forwards;
}
.grit {
stroke: #7c6a4f;
stroke-width: 2;
stroke-linecap: round;
opacity: 0;
animation: grit-fly 0.4s ease-out 0.58s forwards;
}
.grit.g1 { animation-delay: 0.62s; }
.grit.g2 { animation-delay: 0.66s; }
@keyframes aim-mark {
0% { opacity: 0; transform: scale(1.6); transform-origin: center; transform-box: fill-box; }
100% { opacity: 0.8; transform: scale(1); }
}
@keyframes drift-line {
0% { opacity: 0; }
100% { opacity: 0.7; }
}
@keyframes shadow-loom {
0% { opacity: 0; transform: scale(0.2); }
100% { opacity: 1; transform: scale(1); }
}
@keyframes die-fall {
0% { opacity: 0; transform: translateY(-150px) scale(2.4) rotate(35deg); }
30% { opacity: 1; }
100% { transform: translateY(0) scale(1) rotate(0deg); }
}
@keyframes die-settle {
0% { transform: translateY(0) scale(1.15, 0.85); }
25% { transform: translateY(-6px) scale(1); }
45% { transform: translateY(0) scale(1.05, 0.95); }
100% { transform: translateY(0) scale(1); }
}
@keyframes impact-ring {
0% { opacity: 0.9; transform: scale(0.4); }
100% { opacity: 0; transform: scale(2.4); }
}
@keyframes grit-fly {
0% { opacity: 0.9; transform: scale(0.7); }
100% { opacity: 0; transform: scale(1.8); }
}
</style>