@alexpeng/dsh-custom-plugin 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,57 +0,0 @@
1
- /**
2
- * A small height-field wave tank shared by interactive pieces.
3
- *
4
- * Diffusion alone only blurs an impulse; it never makes a ripple travel. This
5
- * is a two-buffer wave equation instead: height `h` and vertical velocity `v`
6
- * are advanced with a five-point Laplacian, damped, then swapped. A ring
7
- * injection therefore expands, interferes with the next ring and dies out on
8
- * its own — the property that makes dragging a finger on the water read as
9
- * water rather than as a moving spotlight.
10
- *
11
- * Both passes are O(cols × rows), allocation-free, and the field is rebuilt
12
- * only when the grid actually changes.
13
- * @module @alexpeng/dsh-custom-plugin/client/bg-wake
14
- */
15
- /** Wave coupling. Above ~0.5 the explicit scheme is unstable in 2D. */
16
- export declare const WAKE_C2 = 0.28;
17
- /** Per-step velocity damping (energy loss). */
18
- export declare const WAKE_DAMPING = 0.975;
19
- /** Per-step height decay (slow return to flat water). */
20
- export declare const WAKE_DECAY = 0.993;
21
- /** Clamp so a burst of injections can never make the surface explode. */
22
- export declare const WAKE_MAX = 1.4;
23
- /** Two height buffers and two velocity buffers, all `cols × rows`. */
24
- export interface BgWakeField {
25
- cols: number;
26
- rows: number;
27
- height: Float32Array;
28
- nextHeight: Float32Array;
29
- velocity: Float32Array;
30
- nextVelocity: Float32Array;
31
- }
32
- /** Allocate a flat field. */
33
- export declare function createWakeField(cols: number, rows: number): BgWakeField;
34
- /** Resize in place. Returns true when the grid changed and the caller must
35
- * treat the surface as freshly flat. */
36
- export declare function resizeWakeField(field: BgWakeField, cols: number, rows: number): boolean;
37
- /** Drop every wave but keep the buffers. */
38
- export declare function clearWake(field: BgWakeField): void;
39
- /**
40
- * Advance one step. The outer one-cell border is absorbing (zeroed) so the
41
- * viewport edge does not act like a bathtub wall and bounce rings back.
42
- */
43
- export declare function stepWake(field: BgWakeField): void;
44
- /**
45
- * A soft circular depression (pointer drag). `radius` and `x/y` are in cells.
46
- * The write is clamped to the field and never allocates.
47
- */
48
- export declare function injectWake(field: BgWakeField, x: number, y: number, radius: number, strength: number): void;
49
- /**
50
- * A ring impulse (a click). The profile is a Gaussian band around `radius`;
51
- * `strength` may be negative for the rebound half of a splash.
52
- */
53
- export declare function injectWakeRing(field: BgWakeField, x: number, y: number, radius: number, width: number, strength: number): void;
54
- /** A small wake behind a swimming fish. */
55
- export declare function injectWakeTrail(field: BgWakeField, x: number, y: number, strength: number): void;
56
- /** Nearest-cell height sample (used by fish steering and tests). */
57
- export declare function sampleWake(field: BgWakeField, x: number, y: number): number;
@@ -1,56 +0,0 @@
1
- /**
2
- * `whale`: a large ASCII whale that crosses the page, with a spout and bubbles.
3
- *
4
- * The scene has three layers:
5
- * 1. a very faint sea — drifting value-noise water plus two long swell lines
6
- * that roll across the lower and middle bands of the page;
7
- * 2. one whale, rasterised once from a hand-tuned outline into a cell mask
8
- * (a shader-like silhouette with a character ramp inside: dark rim, mid
9
- * spine, light belly, a hole for the eye and a darker mouth line), swimming
10
- * leftwards with a slow bob and a tail that beats;
11
- * 3. particles — a spout above the blowhole every few seconds, a bubble trail
12
- * behind the tail, and a few bubbles where the user clicks.
13
- *
14
- * Every cell of the whale is marked in `emphasis`, so the calm zone may thin it
15
- * but never erase it: a recognisable picture is the whole point of the preset,
16
- * and the 0.15 floor would leave a ghost. The sea and the automatic bubbles
17
- * are *not* marked — only the whale and the bubbles the user just caused keep
18
- * the `EFFECT_FOCUS_FLOOR` strength inside the reading column.
19
- *
20
- * The pointer is felt, not obeyed: inside a 14-cell radius the whale speeds up
21
- * a little and banks away vertically; a click inside 18 cells startles it (a
22
- * short burst of speed plus a spout). Nothing here allocates per frame — the
23
- * mask is module-level, the particle pool is fixed, the per-column swell scratch
24
- * grows only with the grid.
25
- * @module @alexpeng/dsh-custom-plugin/client/bg-whale
26
- */
27
- import { type AsciiPiece } from './bg-field.ts';
28
- /** Mask-space size of the whale in grid cells. The cells are ~1.9× taller
29
- * than wide, so 50×12 cells reads back as a ~3:1 silhouette on screen. */
30
- export declare const WHALE_ART_W = 50;
31
- export declare const WHALE_ART_H = 12;
32
- /** One baked whale cell: offset from the mask origin, ramp level (0–9, mapped
33
- * to the live ramp length at paint time), hole kind (0 none, 1 eye, 2 mouth)
34
- * and tail weight. */
35
- export interface WhaleCell {
36
- readonly dx: number;
37
- readonly dy: number;
38
- readonly level: number;
39
- readonly hole: 0 | 1 | 2;
40
- readonly wag: number;
41
- }
42
- /**
43
- * Rasterise the whale outline into cells. Runs once at module load: the rim is
44
- * one step darker than the interior (and the interior darkens toward the
45
- * spine), which is what draws the silhouette through the ramp alone, so a
46
- * ~260-cell whale costs one blit per cell and no overlay pass at all.
47
- */
48
- export declare function buildWhaleCells(): WhaleCell[];
49
- /** The baked mask, shared by every instance (it never changes). */
50
- export declare const WHALE_CELLS: readonly WhaleCell[];
51
- /**
52
- * Create the whale piece. The returned function owns the whale position, the
53
- * particle pool and the sea scratch; all three are reused for the piece's
54
- * lifetime and reset only when the grid changes.
55
- */
56
- export declare function createWhalePiece(levels: number, dither: boolean): AsciiPiece;