@jsb188/gfx 1.1.2

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.
Files changed (65) hide show
  1. package/README.md +522 -0
  2. package/elements/Shapes.helpers.ts +204 -0
  3. package/elements/Shapes.hooks.ts +171 -0
  4. package/elements/Shapes.tsx +505 -0
  5. package/elements/Shapes.types.ts +81 -0
  6. package/elements/Stack.helpers.ts +42 -0
  7. package/elements/Stack.tsx +143 -0
  8. package/elements/Text.helpers.ts +45 -0
  9. package/elements/Text.hooks.ts +197 -0
  10. package/elements/Text.tsx +98 -0
  11. package/libs/chain.ts +174 -0
  12. package/libs/dotGrid.helpers.ts +53 -0
  13. package/libs/dotGrid.ts +954 -0
  14. package/libs/effects/dotEffects.ts +136 -0
  15. package/libs/effects/effectQuad.ts +146 -0
  16. package/libs/effects/effectRegion.ts +299 -0
  17. package/libs/effects/imageEffects.ts +599 -0
  18. package/libs/effects/index.ts +8 -0
  19. package/libs/effects/ripple.ts +160 -0
  20. package/libs/glsl.ts +134 -0
  21. package/libs/passes.ts +374 -0
  22. package/libs/pointer.ts +151 -0
  23. package/libs/runtime.ts +329 -0
  24. package/libs/texture.ts +160 -0
  25. package/libs/types.ts +94 -0
  26. package/libs/uniforms.ts +32 -0
  27. package/main.ts +4 -0
  28. package/modules/Carousel.helpers.ts +316 -0
  29. package/modules/Carousel.hooks.ts +520 -0
  30. package/modules/Carousel.tsx +631 -0
  31. package/modules/Dots.tsx +269 -0
  32. package/modules/DotsBoard.helpers.ts +388 -0
  33. package/modules/DotsBoard.hooks.ts +144 -0
  34. package/modules/DotsBoard.strings.ts +649 -0
  35. package/modules/DotsBoard.types.ts +240 -0
  36. package/modules/DotsBoardCanvas.hooks.ts +49 -0
  37. package/modules/DotsBoardCanvas.tsx +190 -0
  38. package/modules/DotsBoardElements.tsx +330 -0
  39. package/modules/Gallery.helpers.ts +32 -0
  40. package/modules/Gallery.hooks.ts +149 -0
  41. package/modules/Gallery.tsx +194 -0
  42. package/modules/GfxCanvas.hooks.ts +12 -0
  43. package/modules/GfxCanvas.tsx +189 -0
  44. package/modules/Hero.tsx +90 -0
  45. package/modules/KineticHeader.helpers.ts +44 -0
  46. package/modules/KineticHeader.hooks.ts +206 -0
  47. package/modules/KineticHeader.tsx +305 -0
  48. package/modules/KineticHeader.types.ts +56 -0
  49. package/modules/ScrollSteps.hooks.ts +138 -0
  50. package/modules/ScrollSteps.tsx +98 -0
  51. package/package.json +52 -0
  52. package/scenes/Carousel.ts +277 -0
  53. package/scenes/DotsBoard.helpers.ts +12 -0
  54. package/scenes/DotsBoard.ts +245 -0
  55. package/scenes/Hero.ts +280 -0
  56. package/tsconfig.json +13 -0
  57. package/utils/align.ts +18 -0
  58. package/utils/color.ts +112 -0
  59. package/utils/dotEffectSpecs.ts +79 -0
  60. package/utils/dotGridSpecs.ts +469 -0
  61. package/utils/easing.ts +18 -0
  62. package/utils/imageEffectSpecs.ts +89 -0
  63. package/utils/motion.ts +88 -0
  64. package/utils/random.ts +22 -0
  65. package/utils/strings.ts +116 -0
package/README.md ADDED
@@ -0,0 +1,522 @@
1
+ # @jsb188/gfx
2
+
3
+ Shared WebGL2 infrastructure for decorative graphics and hero effects, built on
4
+ [OGL](https://github.com/oframe/ogl). The package owns the renderer lifecycle, a fullscreen
5
+ pass chain, pointer tracking, a library of reusable shader passes, and the ready-made hero
6
+ modules built on them.
7
+
8
+ ## Layout
9
+
10
+ | Folder | Contents |
11
+ | ---------------- | ------------------------------------------------------------------------------------------ |
12
+ | `modules/` | React components: the `<GfxCanvas>` wrapper (with `PlaceholderImage` and the `useContentMemo` hook beside it), the components built on it (`Hero`, `DotsBoard`, `VideoCarousel`), and the DOM-only `BlocksCarousel` (its gestures in `Carousel.hooks.ts`), `DotsBoard` anchoring (its pure math in `DotsBoard.helpers.ts`, contexts and measuring hooks in `DotsBoard.hooks.ts`, the string engine in `DotsBoard.strings.ts`, types in `DotsBoard.types.ts`) and `ScrollSteps`; component-specific pure logic lives in `*.helpers.ts` next to its component |
13
+ | `elements/` | Static illustration pieces with no WebGL: `<Shape>` (two-layer painted SVG shape with a grain or pixelate effect and rounded, straight or sketched edges; geometry in `Shapes.helpers.ts`, the state stepping in `Shapes.hooks.ts`), `<Marker>` (a disc or check mark on a halo, the pin `<DotsBoard.Item>` uses), `<PulsingMarker>` (the disc with glowing halos pulsing out of it, as Web Animations), `<Stack>` (children piled with small seeded rotations about one pivot; angles in `Stack.helpers.ts`) and `<TypedText>` (text retyped whenever it changes; the run in `Text.hooks.ts`) |
14
+ | `scenes/` | Scene modules (`SceneFactory` default exports) that the components `import()` lazily; this is where OGL composition lives |
15
+ | `libs/` | The OGL engine: runtime, pointer, pass chain, GLSL chunks, passes, textures, uniform helpers, dot grid |
16
+ | `libs/effects/` | Photo effects (`imageEffects`), effect regions, the effect quad, the ripple simulation, shared dot effect math (`dotEffects`), and an `index.ts` that re-exports the effects and regions for lazy `import()` |
17
+ | `utils/` | OGL-free helpers safe to import from route bundles: color parsing, easing curves, effect specs, dot grid specs and their CSS, reduced motion and springs, string curves, edge alignment keywords, the seeded PRNG |
18
+
19
+ ## Entry points
20
+
21
+ | Import | Contents |
22
+ | -------------------------------------------------- | ------------------------------------------------------------------------ |
23
+ | `@jsb188/gfx/modules/GfxCanvas` | `<GfxCanvas>` wrapper: lazy loading, placeholder, error fallback, transparent overlays; `<PlaceholderImage>` cover-fit placeholder photo |
24
+ | `@jsb188/gfx/modules/Hero` | Full-bleed photo hero with the cursor-following light field and hover/image effects |
25
+ | `@jsb188/gfx/modules/KineticHeader` | `<KineticHeader title slides>`: centered title with one `{word}` placeholder and a finite list of `{ text, images }` entries. The component `slideDuration` prop (default 5000ms) sets the fully visible display time for every slide, excluding image entrance and exit. Progress advances only during this display time, staying empty during entrance and full during exit. Optional `mouseOverSlideDuration` (a positive integer in milliseconds) changes the display speed on hover instead of pausing. It preserves the completed fraction of the slide and restores the normal speed on mouse leave; transition durations are unchanged. Without a valid value, hover still pauses. Navigation remains visible on hover, but the paused caption appears only when playback is actually paused. Keyboard focus still pauses. The first slide starts fully typed and still. On subsequent changes, the images and captions rise 32px and fade in together over `slideTransitionMs` (default 350ms; 0 disables entrance and exit), with gradual easing; the title and children stay stationary. Before each change, the outgoing images fade downward over 350ms in addition to the display duration; only after this exit finishes do the next text typing and image entrance begin. Images switch when their slide starts; display-time expiry starts exit even if typing is unfinished. Each image has `{ src, alt, altPosition?, altWidth?, altClassName?, offset?: { x, y }, width?, height? }`: offsets are pixels from the image area's center (negative x is left, negative y is up), and sizes are pixels. Supplying only width or only height preserves the natural aspect ratio; supplying both uses `img_cover` to crop to the box. With neither dimension, width defaults to 650. Captions default to the top at image width with an 8px gap. `altPosition` accepts `top`, `left`, `right`, or `bottom`; top/bottom use an 8px gap, and left/right use a 10px gap. `altWidth` sets caption width in pixels; `altClassName` adds classes to its container (for example, `a_r` for right alignment). Side captions align to the image top; top/bottom captions align to its left edge. Captions never shift or resize the image. Later images overlap earlier ones; the title stays above the image area. `imageAreaWidth` and `imageAreaHeight` set the maximum area width and fixed height (defaults: 1000 × 750 pixels). An optional `imageAreaAspectRatio` derives height only when `imageAreaHeight` is omitted. Images, captions, and offsets retain their exact pixel values at every container width; images may overflow the area. A thin line at the bottom of the image area tracks elapsed slide time. Without `mouseOverSlideDuration`, hovering or focusing the image area freezes only the fully visible display time and progress line; entrance and exit continue through hover and focus. Previous/next arrows appear at the progress bar edges with the paused caption while hovered or keyboard-focused. Navigation wraps around, runs exit before entrance, and resets display time; repeated input during transitions is ignored. Reduced motion switches manually without animations; fixed slides keep navigation disabled. A pointer remaining over the slide after entrance applies the hover speed, or pauses at the start of display time if no hover duration is supplied. Scrolling the image area offscreen or hiding the tab freezes all phases; returning resumes from that point. Native Web Animations interpolate the images and progress without a JavaScript frame loop. Optional `pausedLabelText` supplies a translated caption above the progress line only while paused. Loops back to the first entry after the last slide duration; a single entry stays visible without a progress line. Supports `typeMs`, `deleteMs`, `pauseMs`, `jitter`, `slideDuration`, `slideTransitionMs`, and styling props. Reduced motion keeps the current complete entry still (the first entry on initial load); changing the list restarts the sequence. Only the current slide mounts its images, so later slides are not preloaded. No WebGL. |
26
+ | `@jsb188/gfx/modules/Dots` | `<DotsBoard>`: one animated grid, hero image region, anchored `Stage` / `Item` / `Section` content, connecting strings and interactive `Sticky` layers |
27
+ | `@jsb188/gfx/modules/Gallery` | `<GalleryThumbs items>`: fixed halftone video thumbnails with enlarged native previews on pointer hover or keyboard focus. Items contain `{ videoUrl, title? }` with translated captions; optional `count` repeats them and `thumbnailWidth` sets their width (default 200). Each source loads only when its thumbnail enters view or becomes active. Paused thumbnails render on demand, and their opacity changes only while the gallery and tab are visible. Active videos pause when the gallery or tab is hidden. Preview bounds follow viewport changes; thumbnail geometry stays fixed. |
28
+ | `@jsb188/gfx/modules/Carousel` | `<VideoCarousel>`: full-width row of videos, the centered one plain, the rest through an effect (pixelated by default); `<BlocksCarousel>`: a row of any blocks dragged or scrolled sideways, snapping to the nearest block when the gesture ends (no WebGL) |
29
+ | `@jsb188/gfx/modules/ScrollSteps` | `<ScrollSteps>`: a sticky stage whose step advances as the page scrolls; `<ScrollStepFade>` fades content in on each step (no WebGL) |
30
+ | `@jsb188/gfx/elements/Text` | `<TypedText text caret typingClassName typeMs deleteMs pauseMs jitter>`: text retyped whenever it changes (cleared, or deleted a character at a time with `deleteMs`, then the new text typed at a human's uneven pace), a change mid-retype waiting for the running one to finish and only the latest text being typed then; `useTypedText` is the hook behind it (no WebGL) |
31
+ | `@jsb188/gfx/elements/Stack` | `<Stack spread alignX alignY originX originY seed items>`: its children piled in one spot (centered in the pile's box by default), each turned by a small seeded angle about one pivot point of that box, first at the bottom, with `items` setting any one's angle or pixel shift; sized by its biggest item |
32
+ | `@jsb188/gfx/elements/Shapes` | `<Shape state>`: a flat `baseColor` layer and a gradient `color` layer, each painted in as one brush stroke with a grain or pixelate `effect` as `state` goes `empty` → `base` → `active` (and out again the other way; a sweep always finishes before the next starts); `rounded` / `straight` / `sketch` edge; `shape` is a built-in name or a custom `{ d, viewBox }` icon silhouette, and `effect` `hatch` prints it like a woodcut; `reveal` starts it empty and paints it in on mount or on scrolling into view |
33
+ | `@jsb188/gfx/libs/types` | Scene contract types; safe to import without loading the engine |
34
+ | `@jsb188/gfx/libs/chain` | `PassChain`, `createPassProgram`, `disposeTexture`, `disposeRenderTarget` |
35
+ | `@jsb188/gfx/libs/uniforms` | `UniformValues` type plus `setVec2` / `setVec3`, which write vector uniforms in place |
36
+ | `@jsb188/gfx/libs/passes` | Reusable passes: spotlight, sine warp, Voronoi shatter, bokeh, composite |
37
+ | `@jsb188/gfx/libs/glsl` | GLSL ES 3.00 header, fullscreen vertex shader, shared chunks |
38
+ | `@jsb188/gfx/libs/texture` | `createImageTexture` — a texture usable before its image decodes; `createVideoTexture` — a <video> re-uploaded only on new frames; `createLinearTexture` / `createPixelTexture` — the shared texture setup |
39
+ | `@jsb188/gfx/libs/dotGrid` | `createDotGrid` — GPU-point dots a moving cursor throws, springing back home |
40
+ | `@jsb188/gfx/libs/effects` | `imageEffects` + `effectRegion` re-exported together, for a scene to `import()` lazily |
41
+ | `@jsb188/gfx/libs/effects/imageEffects` | Hover/photo effects spliced into an image pass, plus `createImageEffects` |
42
+ | `@jsb188/gfx/libs/effects/effectRegion` | `createEffectRegion` — per-pixel masks (split/circle/rect/path/image) that limit an effect group |
43
+ | `@jsb188/gfx/libs/effects/effectQuad` | `createEffectQuad` — draw a cover-fit image through effects into any rectangle of a transparent canvas |
44
+ | `@jsb188/gfx/libs/effects/dotEffects` | Shared GLSL evaluator and uniform helpers for click, pulse, and resting dot effects |
45
+ | `@jsb188/gfx/libs/effects/ripple` | `RippleSimulation` — cursor-driven wave equation on a ping-pong buffer |
46
+ | `@jsb188/gfx/libs/runtime` | `createGfxRuntime`; the wrapper imports this for you |
47
+ | `@jsb188/gfx/utils/color` | `hexToRgb`, `mixRgb`, `scaleRgb`, `cssColorToRgb` for color uniforms |
48
+ | `@jsb188/gfx/utils/easing` | `easeOutCubic`, `easeInOutCubic` for JavaScript-driven reveals and fades (no OGL) |
49
+ | `@jsb188/gfx/utils/motion` | `prefersReducedMotion`, and the damped spring integrator (`springBodyAt`, `stepSpring`, `snapSpring`) behind the board's strings (no OGL) |
50
+ | `@jsb188/gfx/utils/strings` | The curve of a string hung between two points: `getStringRestControl`, `getQuadraticPoint`, `buildStringPath` (no OGL) |
51
+ | `@jsb188/gfx/utils/align` | `AlignX` / `AlignY` edge keywords shared by the dot grid, `<Stack>` and `<DotsBoard.Item>` |
52
+ | `@jsb188/gfx/utils/imageEffectSpecs` | Effect names, option types, `normalizeImageEffectSpecs` (no OGL) |
53
+ | `@jsb188/gfx/utils/dotEffectSpecs` | `DOT_EFFECTS`, `DOT_SHAPES`, shared effect types/defaults, and `resolveDotEffectOptions` (no OGL) |
54
+ | `@jsb188/gfx/utils/dotGridSpecs` | Dot grid options, defaults, a matching SVG tile and the CSS mask style that draws the grid at rest (no OGL) |
55
+
56
+ Only `modules/*`, `libs/types`, and `utils/*` are safe to import from route bundles (plus
57
+ `import type` from anywhere). Everything else pulls in OGL and must stay behind the scene
58
+ module's dynamic import, which is how each component loads its `scenes/*` module.
59
+
60
+ ## Loading a scene
61
+
62
+ ```tsx
63
+ import { GfxCanvas } from '@jsb188/gfx/modules/GfxCanvas';
64
+ import type { MySceneParams } from '../scenes/MyScene.ts';
65
+
66
+ /*
67
+ * Load OGL and the scene only when the canvas mounts.
68
+ */
69
+ const loadMyScene = () => import('../scenes/MyScene.ts');
70
+
71
+ export const MyHero = () => {
72
+ const params = useMemo<MySceneParams>(() => ({ imageUrl, baseColor: '#ffaaa5' }), [imageUrl]);
73
+ return <GfxCanvas load={loadMyScene} params={params} style={{ aspectRatio: '16 / 9' }} />;
74
+ };
75
+ ```
76
+
77
+ - `load`: keep at module scope or memoize; a new identity recreates the scene.
78
+ - `params`: passed to the factory. A new identity later goes to the scene's `setParams`
79
+ without remounting; scenes that omit `setParams` ignore later changes.
80
+ - `placeholder` / `errorFallback`: static content shown until the scene reports ready (it stays
81
+ mounted through the canvas's fade-in, then unmounts so e.g. a decoded photo is released), and
82
+ again after an import, WebGL, or render failure. When the effect decorates a photo, pass that
83
+ photo as the placeholder (`<PlaceholderImage src={url} />`: cover-fit, same CORS mode as the
84
+ texture so it is fetched once) so a missing WebGL context degrades to the plain image.
85
+ - `label`: translated accessible text for meaningful artwork; omit for decoration.
86
+ - `style` / `className`: size the outer container. Block mode (the default) is `rel w_f ap_1`,
87
+ a full-width square; override `aspectRatio` or give an explicit height through `style`.
88
+ - `fill`: stretch over the nearest positioned ancestor (`abs_full`) instead, for a background or
89
+ an overlay; hero and carousel clip their containers, while a dots board clips only its background layers.
90
+ - Params built from inline arrays or objects (effect specs, option groups) should be memoized
91
+ by content with `useContentMemo` from `modules/GfxCanvas.hooks.ts`, so a caller re-creating
92
+ them each render does not call `setParams` each render.
93
+ - `lazy={false}`: start on mount instead of on viewport entry. Rendering still pauses while
94
+ offscreen or in a hidden tab either way.
95
+ - `maxPixelRatio`: drawing-buffer cap, default `1.5`.
96
+ - `fadeIn`: milliseconds the canvas fades in over the placeholder (default 600); `0` swaps
97
+ instantly, for a scene whose first frame reproduces the placeholder exactly.
98
+ - `transparent`: keep the canvas's alpha channel so the page shows through, for overlays such
99
+ as the dot grid. The canvas composites premultiplied: the scene clears to `(0, 0, 0, 0)`
100
+ itself and writes premultiplied color (`vec4(rgb * a, a)`).
101
+
102
+ ## Scene contract
103
+
104
+ A scene module's default export is a synchronous `SceneFactory<P>`:
105
+
106
+ ```ts
107
+ import { PassChain } from '@jsb188/gfx/libs/chain';
108
+ import { createSpotlightPass } from '@jsb188/gfx/libs/passes';
109
+ import type { SceneContext, Scene } from '@jsb188/gfx/libs/types';
110
+
111
+ export default function createScene({ gl, onDispose }: SceneContext, params: P): Scene<P> {
112
+ const chain = new PassChain(gl);
113
+ onDispose(() => chain.dispose());
114
+ const spotlight = createSpotlightPass(gl, { radius: 0.35, falloff: 1, skew: 0.5, angle: 0, shadeColor, clearColor });
115
+ onDispose(() => spotlight.remove());
116
+
117
+ return {
118
+ frameloop: 'always',
119
+ resize: ({ width, height }) => chain.setSize(width * 0.5, height * 0.5),
120
+ update: ({ pointer }) => {
121
+ const position = spotlight.uniforms.uPosition.value as number[];
122
+ position[0] = pointer.x;
123
+ position[1] = pointer.y;
124
+ },
125
+ render: () => {
126
+ chain.render([spotlight]);
127
+ chain.renderToScreen();
128
+ },
129
+ };
130
+ }
131
+ ```
132
+
133
+ - `resize` receives CSS size plus the effective `pixelRatio`; the runtime has already sized
134
+ the drawing buffer.
135
+ - `update` and `render` receive `elapsed` (active seconds, excluding pauses), `delta` (capped
136
+ at 0.1s), `reducedMotion`, and the eased `pointer` in canvas UV space (y up). The pointer also
137
+ carries `hover` (inside the canvas rect, children included — derived from the same position)
138
+ and an eased `hoverAmount` for hover-driven effects; `hoverSmoothing` sets its rate (default 6).
139
+ All canvases on a page share one `pointermove` listener; each converts the page position
140
+ into its own UVs once per frame (one layout read, and none while the pointer is still), so
141
+ extra canvases add no per-event work.
142
+ - `frameloop` defaults to `'demand'`: call `context.invalidate()` after changes. `'always'`
143
+ renders continuously while visible. Both modes keep rendering until the pointer easing
144
+ settles, so a demand scene still follows the mouse.
145
+ - `isReady` may return `false` while assets load; the wrapper keeps its placeholder up.
146
+ - `pointerSmoothing` is the per-second easing rate (default 6, about 10% per frame at 60fps).
147
+ - `followsPointer: false` declares that nothing in the scene reacts to the pointer: moves no
148
+ longer wake the loop and the pointer is not eased, so a demand scene renders only on resize
149
+ and param changes. It is read live, so a scene can flip it from `setParams`.
150
+ - Continuous scenes drop to `idleFrameRate` (default 30; 0 disables) once the pointer has been
151
+ still for `idleAfterSeconds` (default 2). Pointer movement, param changes, resizes, and
152
+ unfinished easing return the loop to full rate immediately, so interaction never feels throttled.
153
+ - The renderer asks for the default GPU (`powerPreference: 'default'`): decorative work should
154
+ not wake a discrete GPU.
155
+ - Reduced motion freezes `elapsed`, parks the pointer at the center, and stops continuous
156
+ frames; scenes need no special handling beyond reading those values.
157
+ - Register cleanup with `onDispose` as GPU resources are created. OGL has no dispose for
158
+ textures or render targets; use `disposeTexture` / `disposeRenderTarget`, or `PassChain.dispose`.
159
+ - Use `signal` to drop asynchronous results that arrive after disposal.
160
+ - Drive vector uniforms with `setVec2` / `setVec3` from `libs/uniforms`: they write into the
161
+ uniform's existing array, so a frame allocates nothing and OGL (which compares against its
162
+ last upload) skips values that did not change.
163
+
164
+ ## Pass chain and passes
165
+
166
+ `PassChain` owns one fullscreen triangle and two ping-pong render targets that may be much
167
+ smaller than the canvas. `chain.render(programs)` runs each program in order with `tInput`
168
+ bound to the previous output and `uResolution` set to the chain size; `chain.renderToScreen(
169
+ program)` draws at canvas resolution with `tInput` bound to the chain output. Programs come
170
+ from `createPassProgram(gl, fragmentShader(body, chunks), uniforms)`.
171
+
172
+ The passes in `libs/passes.ts` write an RGBA light field: rgb is a color and alpha is how strongly
173
+ it applies. `createImageLightCompositePass` presents a cover-fit image modulated by that
174
+ field; combine other passes freely for new effects.
175
+
176
+ ## Image effects
177
+
178
+ The effect code (~8 KB gzipped) is split out: a scene should `import('@jsb188/gfx/libs/effects')`
179
+ only when its params ask for effects, compiling the composite without effects first and again when
180
+ the chunk arrives (see `scenes/Hero.ts` for the pattern).
181
+
182
+ `createImageLightCompositePass(gl, { ...options, hoverEffects, regionEffects, region })` accepts
183
+ instances from `createImageEffects(gl, specs, prefix)`. Each effect is a GLSL snippet spliced
184
+ into the composite's own `main()`, so any number of them still cost one full-resolution pass,
185
+ and every effect scales by `amount` so it is an exact no-op at 0 — the shader even takes a
186
+ single-sample path when nothing is active. Two groups exist: `hoverEffects` take `amount` from
187
+ `uEffectAmount` (the eased hover value); `regionEffects` are always on and take it from
188
+ `uRegionEffectAmount × regionMask` (see below). Drive `uPointer`, `uEffectAmount`, and `uTime`
189
+ on the composite and call each instance's `update(frame, image)` / `resize` per frame, where
190
+ `image` is the photo the host is presenting (effects such as `bokeh` pre-process it); dispose
191
+ instances with the program (`disposeImageEffects`). Effects apply in list order, region group
192
+ first; at most one sampling effect (`chromatic`, `zoomBlur`, `bokeh`) is used, the hover group's
193
+ winning if both groups have one.
194
+
195
+ | Kind | Names |
196
+ | ---------- | -------------------------------------------------------------------------------------------------- |
197
+ | Distortion | `ripple` (simulation), `waves`, `heatHaze`, `liquid`, `lens`, `glass`, `fisheye`, `barrel`, `pincushion`, `parallax`, `swirl`, `kaleidoscope`, `shatter`, `pixelate` |
198
+ | Sampling | `chromatic`, `zoomBlur`, `bokeh` (focus follows the cursor; the photo is disc-blurred once at half resolution and cached) |
199
+ | Color | `grayscale`, `sepia`, `invert`, `duotone`, `posterize`, `hueRotate`, `colorReveal`, `edges`, `halftone`, `scanlines` |
200
+
201
+ Options and defaults are documented on `ImageEffectOptions`; a spec is `{ name, ...options }`
202
+ and `normalizeImageEffectSpecs` accepts bare names too. `ripple` owns a `RippleSimulation`
203
+ (~⅓-resolution half-float ping-pong when supported, RGBA8 otherwise) that steps only while
204
+ disturbed and flattens itself after a quiet period.
205
+
206
+ To add an effect, write its GLSL as a pure function chunk, add a factory to
207
+ `IMAGE_EFFECT_FACTORIES`, and add its option type to `ImageEffectOptions`. A stateless effect is
208
+ one `defineEffect(prefix, chunks, uniformEntries, { uv | sample | color })` call: the entries
209
+ declare prefixed uniforms and each template receives `u(name)` to reference them (see `waves`
210
+ or `pixelate`; `colorMixEffect` wraps the common "blend toward a transformed copy" case). An
211
+ effect with GPU state of its own (`ripple`, `bokeh`) builds on `defineUniforms` directly and
212
+ adds `update` / `resize` / `dispose`.
213
+
214
+ ## Effect quads and the video carousel
215
+
216
+ `imageEffectShaderParts({ hoverEffects, regionEffects, region })` (in `libs/passes.ts`) is the
217
+ effect-splicing half of `createImageLightCompositePass`, exported so other hosts can present a
218
+ cover-fit `tImage` through the same effect list: it returns the uniform declarations, the
219
+ `main()` statements that leave the effected color in `vec3 image`, the chunks, and the uniform
220
+ values. `createEffectQuad(gl, effects)` builds on it to draw such an image into any rectangle of a
221
+ transparent canvas (`draw({ image, imageSize, rect, canvas, amount, pointer, time, radius })`,
222
+ CSS-pixel rect, premultiplied output, anti-aliased rounded corners) with one draw call per
223
+ rectangle, so several images with the same effects share one program. Effects with per-host GPU
224
+ state (`ripple`, `bokeh`) are not supported in a quad; stateless ones (`pixelate`, the color
225
+ effects, the barrel family, ...) are.
226
+
227
+ `<VideoCarousel items textAreaWidth>` lays its videos out edge to edge across the full
228
+ width of its container and clips whatever falls outside (the page never scrolls sideways). Every
229
+ slide is its video at its own `width × height`, `gap` apart and top-aligned on a track as tall as
230
+ the tallest; the focused one sits centered and plain, and every other one shows through `effect`
231
+ (`'pixelate'` by default; any `ImageEffectSpec` list). Above the track, a fixed text area
232
+ `textAreaWidth` wide and `textAreaHeight` tall (default 120), independent of the videos' sizes,
233
+ shows the focused item's `iconName`, `title`, and `description`. Clicking a slide, or changing `focusedIndex` /
234
+ `onFocusedIndexChange`, moves focus: the slides glide over `transitionMs` while the effect eases
235
+ in on the slide that lost focus and out on the one that gained it. One transparent canvas covers
236
+ the carousel; each frame the scene reads every `<video>`'s `getBoundingClientRect()` and redraws
237
+ it there through the quad, so the CSS transitions carry the drawing along, and videos that are
238
+ clipped away entirely are skipped. The `<video>` elements (muted, looping, inline, autoplaying)
239
+ stay in the DOM underneath — they decode the frames and are what shows without WebGL. Each slide
240
+ is its own memoized `CarouselSlide`, so a carousel re-render (hover, autoplay) neither re-renders
241
+ untouched slides nor re-registers their videos. The endless-track arithmetic lives in
242
+ `modules/Carousel.helpers.ts`. Choose `textAreaWidth` responsively at the call site; it is
243
+ clamped to the container's width.
244
+
245
+ ## Blocks carousel
246
+
247
+ `<BlocksCarousel gap align index defaultIndex onIndexChange transitionMs lock contentOffset selectableText>` is a plain DOM row
248
+ of its children: each block keeps its own width, every one is stretched to the tallest, and
249
+ whatever falls past the container's edges is clipped. The visitor drags the track with any
250
+ pointer (mouse, pen, or a sideways finger; vertical pans still scroll the page) or scrolls it
251
+ sideways with a wheel or trackpad (vertical wheels pass through to the page). When the drag or
252
+ the scroll ends, the track glides over `transitionMs` (default 600) to the nearest snap position:
253
+ a block's left edge at the container's left edge (`align='start'`, the default), or its middle at
254
+ the container's middle (`'center'`). The track stops at its ends, so the last blocks share the
255
+ end position and nothing loops or moves on its own. A drag past an end gives with rubber-band
256
+ resistance and springs back; a flick always leaves the current block; a wheel notch too short
257
+ to reach the next block still advances one, so a mouse wheel is never stuck. A press that
258
+ moves less than a few pixels is a click on the block, so blocks can hold buttons and links; once
259
+ it becomes a drag, the click the browser fires at release is swallowed. With `selectableText`
260
+ (the default) a mouse or pen press on text selects it as anywhere else on the page, and the drag
261
+ starts from everything else (blank space, images, links, buttons); the cursor is an I-beam over
262
+ text and an open hand elsewhere. On touch a sideways swipe drags and a long press selects; form
263
+ fields are never dragged from, and a sideways wheel over a block's own scroller scrolls that
264
+ scroller. Keyboard focus landing
265
+ in a clipped block brings that block into view. Padding on the container shows the neighbouring
266
+ blocks under it. The track and the cursor are written to the DOM directly, never through React
267
+ state, so no gesture re-renders anything; the gestures are `useBlocksCarousel` in `modules/Carousel.hooks.ts`,
268
+ and the snap arithmetic (`getBlockSnapOffsets`, `getSettleIndex`, the rubber band, the wheel
269
+ units) is in `modules/Carousel.helpers.ts`.
270
+
271
+ ## Scroll steps
272
+
273
+ `<ScrollSteps count stepHeight stageHeight top>{(step) => …}</ScrollSteps>` is a scroll-driven
274
+ stage: a track `count × stepHeight` taller than its sticky stage, whose render prop re-renders
275
+ only when the step changes (`onProgress` gets the continuous 0..1 for parallax). The scroll
276
+ listener attaches only while the track is near the viewport. `<ScrollStepFade step>` fades its
277
+ content in on each change. `useScrollStep(ref, { count, stepHeight, stepHeights, top,
278
+ onProgress })` is the hook behind it, which `<DotsBoard.Sticky>` uses too. `useInView(ref, { once,
279
+ rootMargin, threshold })` says whether an element is in the viewport (latching after the first
280
+ sighting with `once`), which `<Shape reveal="view">` uses to paint itself in on scroll.
281
+
282
+ ## Effect regions
283
+
284
+ `createEffectRegion(gl, { signal, onLoad })` returns a mask whose uniforms merge into the
285
+ composite; `setSpec(spec)` selects the shape through uniforms only, so a region can change every
286
+ frame (scroll, state, the pointer) without recompiling. An `image` region decodes its mask
287
+ asynchronously: `onLoad` fires when it is in (pass `invalidate` for a demand scene) and loads
288
+ finishing after `signal` aborts are dropped. Coordinates are CSS-like fractions of the canvas (x left→right,
289
+ y top→bottom); radii, sizes, and `softness` are fractions of the canvas height so circles stay
290
+ round. Every position accepts `[x, y]` or `'pointer'`, and every shape takes `softness` and
291
+ `invert`.
292
+
293
+ | Shape | Fields |
294
+ | -------- | ---------------------------------------------------------------------- |
295
+ | `split` | `at`, `direction` (`left`/`right`/`up`/`down` or degrees clockwise from right) — everything on one side of a line through `at` |
296
+ | `circle` | `center`, `radius` |
297
+ | `rect` | `center`, `size: [w, h]` |
298
+ | `path` | `d` (SVG path data), `viewBox` (default 100×100), `position`, `size` (omit to cover the canvas); rasterized to a mask texture, feathered by `softness` |
299
+ | `image` | `url` (grayscale mask), `position`, `size` (omit to cover the canvas) |
300
+
301
+ ## Dots board
302
+
303
+ `<DotsBoard>` is the single public container for the homepage's background and anchored
304
+ content. `DotsBackground` and the separate CSS `hover` lens have been retired. Import
305
+ `DotsBoard`, `useDotsBoard`, `useDotsStage`, `useElementSize`, and `useViewportHeight` from
306
+ `@jsb188/gfx/modules/Dots`.
307
+
308
+ ```tsx
309
+ <DotsBoard
310
+ dots={{ shape: 'rounded_square', size: 2, spacing: 20, color: '#E0E0E0', alignY: 1 }}
311
+ image={{ src: '/hero.jpg', height: 1200, fade: 250 }}
312
+ footerImageUrl='/footer.jpg'
313
+ effects={{
314
+ kick: { radius: 225, strength: 0.2 },
315
+ thrown: { opacity: 0, scale: 15 },
316
+ click: { effect: 'ripple', radius: 300, width: 100, duration: 1500, scale: 3 },
317
+ pulse: { count: 75, interval: 6000, duration: 3000, scale: 3 },
318
+ }}
319
+ intro={{ initialSize: 2, peakSize: 4, delay: 250, duration: 1000 }}
320
+ fadeDotsBottom={{ start: 500, end: 400, color: 'rgba(0,0,0,.025)' }}
321
+ connections={connections}
322
+ strings={{ color: '#F0F0F0', width: 4, pull: 30 }}
323
+ >
324
+ <HomeHero />
325
+ <DotsBoard.Sticky top={40} lock={[400, 900]}>
326
+ <DotsBoard.Stage height={800}>
327
+ <DotsBoard.Item id='first' x='center' y={20}>Content</DotsBoard.Item>
328
+ </DotsBoard.Stage>
329
+ </DotsBoard.Sticky>
330
+ <DotsBoard.Stage height={400}>
331
+ <DotsBoard.Section x='center' y={20} width={600}>Content without dots behind it</DotsBoard.Section>
332
+ </DotsBoard.Stage>
333
+ <DotsBoard.Footer>
334
+ <MarketdayFooter disableBackground />
335
+ </DotsBoard.Footer>
336
+ </DotsBoard>
337
+ ```
338
+
339
+ - `footerImageUrl` paints a full background image inside `DotsBoard.Footer`, underneath the
340
+ interactive dots. The footer content sets its height through normal flow, including on the
341
+ server. Page CSS styles `[data-dots-footer-background]` for responsive image sizing and the
342
+ backing color. Keep `Footer` directly in the board's flow, outside sticky layers or wrappers
343
+ that create a stacking context. The root isolates its layers; content wrappers must not add
344
+ a stacking context between the footer artwork and the root. Disable the nested footer's own
345
+ background so the dots remain visible, and omit `fadeDotsBottom` to keep the normal dot colors to the bottom.
346
+ - `dots` defines one shared grid: shape, size, spacing, color, opacity and alignment. Use a
347
+ top pixel anchor such as `alignY: 1` to keep its rows stable as page height changes.
348
+ - `image: { src, height, fade }` cover-fits a photo to the board's top `height` CSS pixels.
349
+ Its final `fade` pixels blend into `dots.color`. This changes only the base color, never
350
+ interaction strength or dot opacity. Layers below the region do not load its texture.
351
+ - `effects: { hover, kick, thrown, click, pulse, rest }` configures the shared GPU effects described
352
+ below. Omitted effects are disabled, including cursor kicks. There is no second CSS hover
353
+ renderer underneath the animated dots. `hover: { color, radius, fade }` tints dots even under a
354
+ stationary pointer; `color` supports CSS variables, `radius` defaults to 175px, and `fade: false`
355
+ keeps the tint solid within that radius. Image-colored dots
356
+ blend into the active hover tint through the image fade; full-strength image pixels retain
357
+ their image colors. Pulse count is per layer.
358
+ - `intro: { delay, duration, initialSize, peakSize }` grows dots once on the board's clock.
359
+ Defaults are 0ms delay, 1000ms duration, zero initial size and the resting size as peak.
360
+ A late-loading or newly visible layer joins the current time instead of replaying the intro.
361
+ - `fadeDotsBottom: { start, end, color }` blends the final dot color (after image and hover
362
+ tints) over a band measured upward from the board's bottom in CSS pixels. For example,
363
+ `start: 500, end: 400` leaves dots unchanged above 500px, blends over the next 100px, and
364
+ holds `color` from 400px through the bottom. CSS colors, alpha and theme variables work;
365
+ use `transparent` to fade out. Equal stops produce a hard transition. Stops are clamped
366
+ to nonnegative values, with `end` at most `start`. Motion and scale effects continue;
367
+ sticky layers do not inherit this page-bottom color blend. The footer artwork is unaffected.
368
+ - Background blend modes use `fadeDotsBottom: { start: 900, end: 800, mode: 'soft-light', opacity: 0.4 }`.
369
+ Choose `'soft-light'` for gentle brightening, `'overlay'` for stronger contrast, or `'invert'`
370
+ for CSS difference inversion. These three blend white dots with the actual backdrop.
371
+ Use `'color-burn'` to darken the backdrop colors with neutral gray dots (50% RGB); white
372
+ would have no effect in this mode. All four modes choose their source internally; omit
373
+ `color`. `opacity` defaults to 1 and is clamped to 0..1. Omit `mode` (or use `'color'`) with
374
+ `color` to retain the color blend. These CSS modes share one additional canvas bounded to
375
+ the bottom band and lazy-loaded near it; normal colors fade out while blended dots fade in.
376
+ Both surfaces retain motion, scale, clicks and the shared animation clock. The board inherits
377
+ its parent's background color to provide an opaque blending backdrop; footer artwork stays
378
+ beneath the dots, and text/buttons stay above them.
379
+ - Add `fadeOut: { start: 500, end: 350 }` inside `fadeDotsBottom` to independently fade dots
380
+ to transparent from 500px to 350px above the board bottom, keeping the final 350px dot-free.
381
+ This works with every mode, including `color-burn`, and masks animated dots and the static
382
+ fallback equally. The image and footer content remain visible. Stops are clamped just like
383
+ the color blend range; omitting `fadeOut` keeps dots visible through the bottom.
384
+ - `Stage` reserves its `height` in normal flow and measures its position in its owning layer.
385
+ `useDotsStage()` exposes board coordinates and `ready` after measurement.
386
+ - `Item` snaps `x` / `y` (CSS pixels, percentages or `'center'`) to the nearest board dot,
387
+ then shifts by `dx` / `dy` whole dots. `anchorX` / `anchorY` and `offsetX` / `offsetY`
388
+ place its content relative to that dot. Its optional `id` connects it to strings; `marker`
389
+ defaults to a `Marker`, or accepts `null`. Unmeasured items stay hidden.
390
+ - `Section` snaps a rectangle to the grid and cuts it out of the layer's background, including
391
+ moving dots and the static fallback. `width` / `height` accept pixels or percentages;
392
+ omitted dimensions fit measured content plus `padding` (one spacing by default). `radius`
393
+ rounds the corners. `outline` accepts `{ color, width, dashed }`, or `false` to retain edge
394
+ dots. The outline is static; section cutouts must not overlap.
395
+ - `connections` lists item IDs per string, or `{ key, items, color, width, slack, maxSag, dashed }`.
396
+ `strings` supplies defaults plus `spring`, `fadeMs`, `tug`, and `pull`. Strings are still
397
+ SVG paths with spring motion and pointer hit paths; background rendering does not own them.
398
+ - `Sticky` pins a layer at `top` for `lock` CSS pixels (or an array of phase distances).
399
+ `onStep` and `onProgress` report scrolling; `pin={false}` keeps the section in normal flow.
400
+ The layer inherits the board's effects and grid, and carries dots, items and strings together.
401
+ Its opaque `bg` hides scrolling dots underneath. Keep a connection's items within one layer;
402
+ the homepage uses one sticky layer per board.
403
+
404
+ Internally, `Dots.tsx` composes the board and sticky layers. Anchoring components live in
405
+ `DotsBoardElements.tsx`; measurement and context in `DotsBoard.hooks.ts`; pure layout math in
406
+ `DotsBoard.helpers.ts`; string animation in `DotsBoard.strings.ts`. `DotsBoardCanvas.tsx`
407
+ provides the shared renderer and CSS fallback, using `useDotsBoardView` to move a canvas
408
+ window through the layer without React scroll updates. Only the background is clipped, so
409
+ sticky content retains the document's scroll context.
410
+
411
+ Each layer's framebuffer is at most the viewport height plus 512px of overscan, capped by
412
+ its own height. The logical grid's small spring texture persists across scrolls; scrolling
413
+ changes projection, not grid layout. Canvas dimensions never scale with the full page height.
414
+ The scene (`scenes/DotsBoard.ts`) shares wall-clock timing across layers and maps board clicks
415
+ into each layer, including nearby clicks outside its edges. Reduced motion disables the intro,
416
+ kicks, pulses and clicks. Before hydration or without WebGL, CSS draws the same image region,
417
+ base dots, fade and section cutouts. The fallback shows resting dots rather than animating.
418
+
419
+ ## Dot grid
420
+
421
+ `createDotGrid(gl, options)` draws evenly spaced dots as GPU points, laid out from
422
+ `gl_VertexID` and uniforms alone (no vertex buffer), centered on the canvas like a CSS tile
423
+ with `mask-position: center`. A moving cursor throws the dots near it aside and they spring
424
+ back home with a damped bounce; a still cursor does nothing. Each dot's offset and velocity
425
+ live in one texel of a half-float ping-pong texture (`cols × rows`) that a fullscreen pass
426
+ advances per frame, and the point shader reads its texel back. Without half-float render
427
+ targets physical kicks are disabled; visual click, pulse, and resting effects still work.
428
+
429
+ Ripple clicks can apply a radial impulse using `click.kickRadius` (default 80) and
430
+ `click.kickStrength` (default 0, disabled). These are independent of cursor kicks and work
431
+ with `kick: false`. Negative click strength pulls inward. The return uses `kick.bounceDuration`
432
+ and `kick.bounciness` when cursor kicks are configured, or their defaults otherwise. The
433
+ existing `thrown` styling applies to displaced dots. The visual ripple still uses `click.radius`.
434
+
435
+ Options come in groups (`dotGridSpecs` holds the types, `DOT_GRID_DEFAULTS`,
436
+ `resolveDotGridOptions`, `isDotGridInteractive`, `getDotGridCoverSize`, `getDotGridAnchor`,
437
+ `makeDotGridTileUrl` + `getDotGridMaskPosition`, which return one tile of the grid as an
438
+ SVG data URL and the `mask-position` that lays it on the same dots as the canvas, and
439
+ `getDotGridMaskStyle`, the CSS that draws the resting grid from them, with
440
+ `getDotGridLayerMaskStyle` for a layer that rests at an offset inside a measured area):
441
+
442
+ | Group | Fields | Meaning |
443
+ | -------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
444
+ | `dots` | `size` 2.25, `shape` `circle`, `spacing` 7, `color` `#ffffff`, `opacity` 1, `alignX` `center`, `alignY` `center` | The grid at rest (defaults match marketday's `.pattern_speckle` tile). `shape` is `circle`, `rounded_square`, `ring`, or `ring_rectangle` (`size` is the bounding size either way); thrown dots keep it. `alignX` (`left` / `center` / `right`) and `alignY` (`top` / `center` / `bottom`) anchor the grid: `center` puts a dot on the middle of the area; `left` / `top` hide the first dot just past that edge (its center one `size` out, so the first visible one is about a spacing in); `right` / `bottom` set the last dot flush against that edge; a number (or `{ left }` / `{ top }`) puts a dot's center that many px from the left / top edge, `{ right }` / `{ bottom }` that many from the right / bottom edge |
445
+ | `kick` | `radius` 80, `strength` 1, `bounceDuration` 1200, `bounciness` 0.5 | How a moving cursor throws dots within `radius` (a fast swipe throws the dots at its centre about `radius × strength` px; negative pulls them toward the path) and how they return (`bounceDuration` ms to settle, `bounciness` 0 = glide back, 1 = ring). `false` disables cursor kicks |
446
+ | `thrown` | `color`, `opacity`, `scale` | The look of a dot while thrown, blended by its swing amplitude (full at a quarter of `radius × strength`, the biggest throw a swipe gives) so it fades smoothly instead of flickering at each pass through home. Omit to keep the resting look |
447
+ | `pulse` | `effect` `swell`, `count` 20, `interval` 3000, `duration` 1500, `scale` 3, shared effect settings | A random handful of dots animate each cycle. Motion effects use a small local orbit around each selected dot; default radius is 3 × dot spacing. Starts after the reveal, with a stable effect choice per dot/cycle. Existing pulse configurations keep their simple swell. `true` enables defaults |
448
+ | `click` | `effect` `ripple`, `radius` 420, `width` 80, `duration` 1400, `scale` 4, shared effect settings | A click or tap runs the effect from that point. Up to eight clicks overlap; another replaces the oldest, and each dot follows the strongest active click. Works with `kick={false}`. Clicks during the reveal or reduced motion are ignored. `true` enables defaults; omitted or `false` disables it |
449
+ | `rest` | `effect` `ripple`, `interval` 6000, `duration` 1800, `scale` 2, `origin` `center`, shared effect settings | An ambient animation across the resting grid, independent of clicks and pulses. `origin: 'random'` chooses a point inside the area each cycle. Begins after the reveal; duration is capped at the interval. `true` enables defaults; omitted or `false` disables it |
450
+
451
+ Resolved options are themselves valid options, so a scene can pass them straight through.
452
+
453
+ ```tsx
454
+ <DotsBoard
455
+ dots={{ shape: 'rounded_square', size: 2, spacing: 20 }}
456
+ intro={{ initialSize: 1, peakSize: 10, duration: 800 }}
457
+ effects={{
458
+ click: { effect: 'random', shape: 'ring_rectangle', radius: 480, width: 90, duration: 1500, scale: 6 },
459
+ pulse: { effect: 'sparkle', count: 50, color: '#70C9D4', shape: 'ring', scale: 3 },
460
+ rest: { effect: 'vortex', interval: 8000, duration: 2500, strength: 0.15, scale: 1 },
461
+ }}
462
+ >
463
+ {children}
464
+ </DotsBoard>
465
+ ```
466
+
467
+ All three triggers use `DotEffectOptions`: `effect`, `shape`, `radius`, `width`, `duration`,
468
+ `strength`, `scale`, `opacity`, and `color`. Shapes and opacity default to the resting dots.
469
+ `strength` (0..1, default 0.35) controls movement; `width` is the half-width of a ripple/color
470
+ wave. `color` is an optional hex tint, including over images. Color wave and sparkle choose
471
+ a stable accent color when it is omitted. Set `scale: 1` for movement, tint, or shape changes
472
+ without swelling. Pulse and resting durations cannot exceed their intervals.
473
+
474
+ | Effect | Behavior |
475
+ | --- | --- |
476
+ | `swell` | Smoothly grow and return; the original pulse behavior |
477
+ | `ripple` | A wave grows dots as it expands outward |
478
+ | `vortex` | Swirl around the origin, then unwind |
479
+ | `magnet` | Pull toward the origin and release |
480
+ | `color_wave` | Spread a temporary tint in an expanding wave |
481
+ | `sparkle` | Stagger brief flashes and shape changes between dots |
482
+ | `random` | Choose one of the six effects per click, per selected pulse dot/cycle, or per resting cycle |
483
+
484
+ Random choices are held for the animation's lifetime, including across parameter-preserving
485
+ React rerenders. Pulse and resting choices are seeded in the shader; clicks choose once when
486
+ recorded. New effects belong in `libs/effects/dotEffects.ts` and their names/defaults in
487
+ `utils/dotEffectSpecs.ts`; triggers supply only origins, timing, and style. All effects use
488
+ the same point draw pass, no new textures or render passes. Click work is bounded to eight
489
+ events; pulsing/resting need continuous frames while visible. Reduced motion disables the
490
+ animations and returns every dot to its resting appearance. The static CSS fallback keeps
491
+ the resting pattern when WebGL is unavailable.
492
+
493
+ The click listener belongs to the background area, including its overlaid children, and
494
+ preserves their normal button/link actions and touch scrolling. Coordinates follow the canvas
495
+ after scrolling or CSS scaling. `ring` (a circular outline) and `ring_rectangle` (the outline of a rounded square) also work
496
+ as resting or pulse shapes, with matching SVG fallbacks. Their holes open during a reveal
497
+ so the intro starts filled; all shapes use `size` as their bounding diameter or side length.
498
+
499
+ Drive the grid from a scene: `resize(size)` from `resize`; `setOptions` from `setParams`;
500
+ `setOverlay(imageTexture | null)` to show an image through the dots instead of `dots.color`
501
+ (each fragment samples the cover-fit image at its own screen position, so a dot is a window
502
+ onto it and a bigger dot shows more); `setReveal(0..1, diameter?)` with an already eased amount (an optional CSS-pixel diameter supports growing dots from zero) and `setOverlayZoom(scale)` for the image; `setTime(seconds, reducedMotion)` every update, with `setPulseStart(seconds | null)` to begin (or hold) both ambient timelines. `isAnimating()` reports whether pulse or resting effects need continuous frames; `isPulsing()` reports pulses alone;
503
+ `clickAt(x, y, seconds)` on a click in canvas CSS pixels, and `stepClicks(seconds, reducedMotion)`
504
+ each frame to expire click effects (returns whether to `invalidate()` again);
505
+ `step(pointerPx, velocityPxPerSecond, active, dt, now)` from `update` with the raw pointer in
506
+ CSS pixels (y down), which returns whether the dots are still settling so the scene can
507
+ `invalidate()`; and `draw(clear)` from `render` (`draw(true)` clears to transparent first).
508
+ `isInteractive()` is false when there is no kick (or no half-float support), so a scene can
509
+ pass that on as `followsPointer: false` and pointer moves cost no frames at all.
510
+
511
+ The kick is a force proportional to cursor speed, so a slow drag only nudges dots while a
512
+ fast swipe scatters them (a per-dot random factor keeps the spread irregular). The spring is
513
+ derived from the bounce settings: `bounceDuration` is the ~2% settling time and `bounciness`
514
+ picks the damping ratio; the integrator substeps so it stays stable at any frame rate, and the
515
+ grid snaps to rest at 1.5 × `bounceDuration`, when the residual is under a quarter pixel.
516
+
517
+ ## Dependencies and checks
518
+
519
+ Marketday supplies `ogl` as a runtime dependency and its React installation; both are peers
520
+ here. Vite compiles the source exports in the consuming app; the package is listed in
521
+ marketday's `optimizeDeps.exclude` so edits hot-reload. Run `yarn workspace
522
+ @jsb188/gfx build` (or `tsc -p` in this folder) to typecheck.