diff --git a/apps/demo/src/routes/+page.svelte b/apps/demo/src/routes/+page.svelte
index cc88df0..d3bf886 100644
--- a/apps/demo/src/routes/+page.svelte
+++ b/apps/demo/src/routes/+page.svelte
@@ -1,2 +1,1406 @@
-
+
Asset Playground
+
+ {#if errorMsg}
+
{errorMsg}
+ {:else if !ready}
+
Loading assets…
+ {:else}
+
+
State
+
+ {#each availableStates as s}
+
+ {/each}
+
+
+
+ {#if availableEvents.length > 0}
+
Trigger event
+
+ {#each availableEvents as ev}
+ {@const key = `${ev.state}:${ev.name}`}
+ {@const cd = debug?.cooldowns[key] ?? 0}
+ {@const isQueued = debug?.queuedEvent === ev.name && debug?.state === ev.state}
+ {@const isActive = debug?.activeEvent === ev.name && debug?.state === ev.state}
+ {@const stateMismatch = currentState !== ev.state}
+
+ {/each}
+
+ {#if pendingTrigger}
+
+ Switching to {pendingTrigger.state} to queue
+ {pendingTrigger.event}…
+
+ {/if}
+ {/if}
+
+
+
Chatter test
+
+
+
+
+
+ {#if debug}
+
+ - state
+ - {debug.state}
+ - track
+ - {debug.track}
+ - frame
+ - {debug.frameIndex} / {debug.frameCount - 1}
+ - look folder
+ - {debug.lookFolder ?? '—'}
+ - matched
+ - {debug.matchedFolder ?? '—'}
+ - active event
+ - {debug.activeEvent ?? '—'}
+ - queued event
+ - {debug.queuedEvent ?? '—'}
+ {#if Object.keys(debug.cooldowns).length > 0}
+ - cooldowns
+ -
+ {#each Object.entries(debug.cooldowns) as [key, sec]}
+
{key.replace(':', ' / ')}: {sec.toFixed(1)}s
+ {/each}
+
+ {/if}
+
+ {/if}
+
+ {#if cursorInfo}
+
+
angle {cursorInfo.angle.toFixed(1)}°
+
distance {cursorInfo.distance.toFixed(0)} px
+
+ {/if}
+
+ {#if chatterLog.length > 0}
+
+ {#each chatterLog as line}
+
{line}
+ {/each}
+
+ {/if}
+
+
+
+ {#each clipSummary as clip}
+
+ {clip.role}
+ {clip.name}
+ {clip.frames}f · {clip.fps}fps
+
+ {/each}
+ {#if stats}
+
+ {/if}
+
+
+
hover to look · drop PNGs in src/lib/assets/
+ {/if}
+
+
+
\ No newline at end of file
diff --git a/packages/shimejic/src/core/animation.ts b/packages/shimejic/src/core/animation.ts
new file mode 100644
index 0000000..303d49c
--- /dev/null
+++ b/packages/shimejic/src/core/animation.ts
@@ -0,0 +1,194 @@
+/**
+ * animation.ts — frame sequencing.
+ *
+ * An AnimationClip is a list of frames + fps + loop flag. An Animator plays
+ * one clip at a time and exposes the current frame. It knows nothing about
+ * what the frames contain.
+ *
+ * `staticSprite` and `animatedSprite` produce SpriteSlot-conforming objects.
+ * Both have the same interface — the renderer can't tell them apart.
+ */
+
+import type { SpriteFrame, SpriteSlot } from "./entity.ts";
+
+export interface AnimationClip {
+ frames: CanvasImageSource[];
+ fps: number;
+ /** Default true. When false, holds the last frame after one pass. */
+ loop?: boolean;
+}
+
+/* ------------------------------------------------------------------ */
+/* Animator */
+/* ------------------------------------------------------------------ */
+
+export class Animator {
+ private clip: AnimationClip | null = null;
+ private elapsed = 0;
+ private finished = false;
+ private playing = false;
+
+ /** Begin playing a clip. No-op if it's already the current clip. */
+ play(clip: AnimationClip | null): void {
+ if (clip === this.clip) return;
+ this.clip = clip;
+ this.elapsed = 0;
+ this.finished = false;
+ this.playing = clip !== null && clip.frames.length > 0;
+ }
+
+ /** Restart the current clip from frame zero. */
+ restart(): void {
+ if (this.clip === null) return;
+ this.elapsed = 0;
+ this.finished = false;
+ this.playing = this.clip.frames.length > 0;
+ }
+
+ /** Freeze the clip. Does not clear the current frame. */
+ stop(): void {
+ this.playing = false;
+ }
+
+ /**
+ * Advance by `dt` seconds.
+ * `timeScale` multiplies the rate. Use it to make playback speed
+ * proportional to something — ground speed, for example.
+ */
+ update(dt: number, timeScale = 1): void {
+ const c = this.clip;
+ if (!this.playing || c === null || this.finished) return;
+
+ this.elapsed += dt * timeScale;
+
+ if (c.loop === false) {
+ const duration = c.frames.length / c.fps;
+ if (this.elapsed >= duration) {
+ this.elapsed = duration;
+ this.finished = true;
+ }
+ }
+ }
+
+ get frame(): CanvasImageSource | null {
+ const c = this.clip;
+ if (c === null || c.frames.length === 0) return null;
+ return c.frames[this.frameIndex] ?? null;
+ }
+
+ get frameIndex(): number {
+ const c = this.clip;
+ if (c === null || c.frames.length === 0) return 0;
+ const raw = Math.floor(this.elapsed * c.fps);
+ if (c.loop === false) return Math.min(raw, c.frames.length - 1);
+ return raw % c.frames.length;
+ }
+
+ get done(): boolean {
+ return this.finished;
+ }
+
+ get time(): number {
+ return this.elapsed;
+ }
+
+ get currentClip(): AnimationClip | null {
+ return this.clip;
+ }
+}
+
+/* ------------------------------------------------------------------ */
+/* Image sizing */
+/* ------------------------------------------------------------------ */
+
+/**
+ * Best-effort size detection across CanvasImageSource variants.
+ * HTMLImageElement uses naturalWidth/naturalHeight; everything else
+ * (canvas, ImageBitmap, OffscreenCanvas, video) uses width/height.
+ */
+export function imageSize(image: CanvasImageSource): { width: number; height: number } {
+ const anyImg = image as unknown as Record