@jsb188/gfx 1.1.2 → 1.1.11
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.
- package/README.md +54 -248
- package/libs/dotGrid.ts +77 -480
- package/libs/effects/effectQuad.ts +2 -8
- package/libs/pointer.ts +0 -6
- package/libs/runtime.ts +4 -6
- package/libs/types.ts +1 -8
- package/main.ts +0 -2
- package/modules/Carousel.helpers.ts +0 -234
- package/modules/Carousel.tsx +29 -135
- package/modules/DotsArea.tsx +120 -0
- package/modules/GfxCanvas.tsx +2 -10
- package/modules/ScrollSteps.tsx +52 -7
- package/modules/VisionBoard.helpers.ts +561 -0
- package/modules/VisionBoard.tsx +358 -0
- package/modules/VisionBoard.types.ts +88 -0
- package/package.json +5 -15
- package/scenes/Carousel.ts +18 -99
- package/scenes/DotsArea.ts +208 -0
- package/tsconfig.json +1 -1
- package/utils/color.ts +2 -64
- package/utils/dotGridSpecs.ts +46 -304
- package/elements/Shapes.helpers.ts +0 -204
- package/elements/Shapes.hooks.ts +0 -171
- package/elements/Shapes.tsx +0 -505
- package/elements/Shapes.types.ts +0 -81
- package/elements/Stack.helpers.ts +0 -42
- package/elements/Stack.tsx +0 -143
- package/elements/Text.helpers.ts +0 -45
- package/elements/Text.hooks.ts +0 -197
- package/elements/Text.tsx +0 -98
- package/libs/dotGrid.helpers.ts +0 -53
- package/libs/effects/dotEffects.ts +0 -136
- package/modules/Carousel.hooks.ts +0 -520
- package/modules/Dots.tsx +0 -269
- package/modules/DotsBoard.helpers.ts +0 -388
- package/modules/DotsBoard.hooks.ts +0 -144
- package/modules/DotsBoard.strings.ts +0 -649
- package/modules/DotsBoard.types.ts +0 -240
- package/modules/DotsBoardCanvas.hooks.ts +0 -49
- package/modules/DotsBoardCanvas.tsx +0 -190
- package/modules/DotsBoardElements.tsx +0 -330
- package/modules/Gallery.helpers.ts +0 -32
- package/modules/Gallery.hooks.ts +0 -149
- package/modules/Gallery.tsx +0 -194
- package/modules/KineticHeader.helpers.ts +0 -44
- package/modules/KineticHeader.hooks.ts +0 -206
- package/modules/KineticHeader.tsx +0 -305
- package/modules/KineticHeader.types.ts +0 -56
- package/modules/ScrollSteps.hooks.ts +0 -138
- package/scenes/DotsBoard.helpers.ts +0 -12
- package/scenes/DotsBoard.ts +0 -245
- package/utils/align.ts +0 -18
- package/utils/dotEffectSpecs.ts +0 -79
- package/utils/motion.ts +0 -88
- package/utils/random.ts +0 -22
- package/utils/strings.ts +0 -116
package/README.md
CHANGED
|
@@ -9,12 +9,11 @@ modules built on them.
|
|
|
9
9
|
|
|
10
10
|
| Folder | Contents |
|
|
11
11
|
| ---------------- | ------------------------------------------------------------------------------------------ |
|
|
12
|
-
| `modules/` | React components: the `<GfxCanvas>` wrapper (with `PlaceholderImage` and the `useContentMemo` hook beside it), the components built on it (`Hero`, `
|
|
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`) |
|
|
12
|
+
| `modules/` | React components: the `<GfxCanvas>` wrapper (with `PlaceholderImage` and the `useContentMemo` hook beside it), the components built on it (`Hero`, `DotsArea`, `VideoCarousel`), and the DOM-only `VisionBoard` and `ScrollSteps`; component-specific pure logic lives in `*.helpers.ts` next to its component |
|
|
14
13
|
| `scenes/` | Scene modules (`SceneFactory` default exports) that the components `import()` lazily; this is where OGL composition lives |
|
|
15
14
|
| `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,
|
|
17
|
-
| `utils/` | OGL-free helpers safe to import from route bundles: color parsing, easing curves, effect specs, dot grid specs
|
|
15
|
+
| `libs/effects/` | Photo effects (`imageEffects`), effect regions, the effect quad, the ripple simulation, and an `index.ts` that re-exports the effects and regions for lazy `import()` |
|
|
16
|
+
| `utils/` | OGL-free helpers safe to import from route bundles: color parsing, easing curves, effect specs, dot grid specs |
|
|
18
17
|
|
|
19
18
|
## Entry points
|
|
20
19
|
|
|
@@ -22,14 +21,10 @@ modules built on them.
|
|
|
22
21
|
| -------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
23
22
|
| `@jsb188/gfx/modules/GfxCanvas` | `<GfxCanvas>` wrapper: lazy loading, placeholder, error fallback, transparent overlays; `<PlaceholderImage>` cover-fit placeholder photo |
|
|
24
23
|
| `@jsb188/gfx/modules/Hero` | Full-bleed photo hero with the cursor-following light field and hover/image effects |
|
|
25
|
-
| `@jsb188/gfx/modules/
|
|
26
|
-
| `@jsb188/gfx/modules/
|
|
27
|
-
| `@jsb188/gfx/modules/
|
|
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) |
|
|
24
|
+
| `@jsb188/gfx/modules/DotsArea` | Transparent dot pattern a moving cursor throws aside; the dots bounce back home |
|
|
25
|
+
| `@jsb188/gfx/modules/Carousel` | `<VideoCarousel>`: full-width row of videos, the centered one plain, the rest through an effect (pixelated by default) |
|
|
26
|
+
| `@jsb188/gfx/modules/VisionBoard` | `<VisionBoard>`: draggable photo/icon items joined by springy strings, driven through states by `overrides` and a tag filter (no WebGL) |
|
|
29
27
|
| `@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
28
|
| `@jsb188/gfx/libs/types` | Scene contract types; safe to import without loading the engine |
|
|
34
29
|
| `@jsb188/gfx/libs/chain` | `PassChain`, `createPassProgram`, `disposeTexture`, `disposeRenderTarget` |
|
|
35
30
|
| `@jsb188/gfx/libs/uniforms` | `UniformValues` type plus `setVec2` / `setVec3`, which write vector uniforms in place |
|
|
@@ -41,17 +36,12 @@ modules built on them.
|
|
|
41
36
|
| `@jsb188/gfx/libs/effects/imageEffects` | Hover/photo effects spliced into an image pass, plus `createImageEffects` |
|
|
42
37
|
| `@jsb188/gfx/libs/effects/effectRegion` | `createEffectRegion` — per-pixel masks (split/circle/rect/path/image) that limit an effect group |
|
|
43
38
|
| `@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
39
|
| `@jsb188/gfx/libs/effects/ripple` | `RippleSimulation` — cursor-driven wave equation on a ping-pong buffer |
|
|
46
40
|
| `@jsb188/gfx/libs/runtime` | `createGfxRuntime`; the wrapper imports this for you |
|
|
47
41
|
| `@jsb188/gfx/utils/color` | `hexToRgb`, `mixRgb`, `scaleRgb`, `cssColorToRgb` for color uniforms |
|
|
48
42
|
| `@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
43
|
| `@jsb188/gfx/utils/imageEffectSpecs` | Effect names, option types, `normalizeImageEffectSpecs` (no OGL) |
|
|
53
|
-
| `@jsb188/gfx/utils/
|
|
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) |
|
|
44
|
+
| `@jsb188/gfx/utils/dotGridSpecs` | Dot grid options, defaults, and a matching SVG tile for a CSS fallback (no OGL) |
|
|
55
45
|
|
|
56
46
|
Only `modules/*`, `libs/types`, and `utils/*` are safe to import from route bundles (plus
|
|
57
47
|
`import type` from anywhere). Everything else pulls in OGL and must stay behind the scene
|
|
@@ -86,7 +76,7 @@ export const MyHero = () => {
|
|
|
86
76
|
- `style` / `className`: size the outer container. Block mode (the default) is `rel w_f ap_1`,
|
|
87
77
|
a full-width square; override `aspectRatio` or give an explicit height through `style`.
|
|
88
78
|
- `fill`: stretch over the nearest positioned ancestor (`abs_full`) instead, for a background or
|
|
89
|
-
an overlay; hero and carousel
|
|
79
|
+
an overlay; the hero, dots area, and carousel use this inside their own `rel of` container.
|
|
90
80
|
- Params built from inline arrays or objects (effect specs, option groups) should be memoized
|
|
91
81
|
by content with `useContentMemo` from `modules/GfxCanvas.hooks.ts`, so a caller re-creating
|
|
92
82
|
them each render does not call `setParams` each render.
|
|
@@ -224,13 +214,13 @@ rectangle, so several images with the same effects share one program. Effects wi
|
|
|
224
214
|
state (`ripple`, `bokeh`) are not supported in a quad; stateless ones (`pixelate`, the color
|
|
225
215
|
effects, the barrel family, ...) are.
|
|
226
216
|
|
|
227
|
-
`<VideoCarousel items
|
|
228
|
-
width of its container and clips whatever falls outside (the page never scrolls sideways).
|
|
229
|
-
slide
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
`
|
|
233
|
-
|
|
217
|
+
`<VideoCarousel items focusedContentWidth>` lays its videos out edge to edge across the full
|
|
218
|
+
width of its container and clips whatever falls outside (the page never scrolls sideways). The
|
|
219
|
+
focused slide sits centered in a box `focusedContentWidth` wide holding its `iconName`, `title`,
|
|
220
|
+
and `description` in a text area `textAreaHeight` tall (default 120) above the plain video; every
|
|
221
|
+
other slide shows only its video at its own `width × height`, through `effect` (`'pixelate'` by
|
|
222
|
+
default; any `ImageEffectSpec` list), under an empty text area of the same height, so videos keep
|
|
223
|
+
their vertical position when focus moves. Clicking a slide, or changing `focusedIndex` /
|
|
234
224
|
`onFocusedIndexChange`, moves focus: the slides glide over `transitionMs` while the effect eases
|
|
235
225
|
in on the slide that lost focus and out on the one that gained it. One transparent canvas covers
|
|
236
226
|
the carousel; each frame the scene reads every `<video>`'s `getBoundingClientRect()` and redraws
|
|
@@ -239,45 +229,36 @@ clipped away entirely are skipped. The `<video>` elements (muted, looping, inlin
|
|
|
239
229
|
stay in the DOM underneath — they decode the frames and are what shows without WebGL. Each slide
|
|
240
230
|
is its own memoized `CarouselSlide`, so a carousel re-render (hover, autoplay) neither re-renders
|
|
241
231
|
untouched slides nor re-registers their videos. The endless-track arithmetic lives in
|
|
242
|
-
`modules/Carousel.helpers.ts`. Choose `
|
|
243
|
-
clamped to the container
|
|
244
|
-
|
|
245
|
-
##
|
|
246
|
-
|
|
247
|
-
`<
|
|
248
|
-
of
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
the
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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.
|
|
232
|
+
`modules/Carousel.helpers.ts`. Choose `focusedContentWidth` responsively at the call site; it is
|
|
233
|
+
not clamped to the container.
|
|
234
|
+
|
|
235
|
+
## Vision board
|
|
236
|
+
|
|
237
|
+
`<VisionBoard items connections width height>` is plain DOM: absolutely positioned items over one
|
|
238
|
+
SVG of strings, no canvas. `width` × `height` is the design space the item coordinates live in;
|
|
239
|
+
the board keeps that aspect ratio at any CSS width, so positions scale while node sizes and texts
|
|
240
|
+
stay in pixels. Each item needs only `x` / `y`; `image` or `icon` fills the node, and `title`,
|
|
241
|
+
`text`, and `tags` sit on the `textPlacement` side, always or on hover (`textVisibility`). Ids
|
|
242
|
+
default to the index. A connection is a chain of item ids: each stretch is a quadratic curve that
|
|
243
|
+
sags by `slack` (0 draws it straight), takes the color of the item it leaves, and may be `dashed`.
|
|
244
|
+
|
|
245
|
+
Items drag: free up to `dragLimit` board units from home, rubber-banding beyond it, and spring back
|
|
246
|
+
with a bounce on release (a fast release throws them). Strings have their own spring on the bend
|
|
247
|
+
(`physics.string`), so they lag and wobble behind moving items; `physics.item` tunes the item spring.
|
|
248
|
+
|
|
249
|
+
The board is driven by `overrides` (item id → any item fields): switching to another overrides
|
|
250
|
+
object springs items to their new places, fades hidden ones out, and transitions colors, so
|
|
251
|
+
buttons or a scroll position can step the board through states. `visibleTags` hides tagged items
|
|
252
|
+
carrying none of the tags; untagged items (a hub) always show. All motion runs in one
|
|
253
|
+
requestAnimationFrame loop outside React (`modules/VisionBoard.helpers.ts`) that stops when nothing
|
|
254
|
+
moves, writing transforms and path data straight to the DOM; the markup carries the rest state, so
|
|
255
|
+
server output shows the finished board, and reduced motion snaps instead of springing.
|
|
256
|
+
|
|
257
|
+
`<ScrollSteps count stepHeight stageHeight top>{(step) => …}</ScrollSteps>` is the scroll side: a
|
|
258
|
+
track `count × stepHeight` taller than its sticky stage, whose render prop re-renders only when
|
|
259
|
+
the step changes (`onProgress` gets the continuous 0..1 for parallax). The scroll listener attaches
|
|
260
|
+
only while the track is near the viewport. `<ScrollStepFade step>` fades its content in on each
|
|
261
|
+
change. See `HomeWorkflowStory` in marketday's `home-test.tsx` for the two together.
|
|
281
262
|
|
|
282
263
|
## Effect regions
|
|
283
264
|
|
|
@@ -298,124 +279,6 @@ round. Every position accepts `[x, y]` or `'pointer'`, and every shape takes `so
|
|
|
298
279
|
| `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
280
|
| `image` | `url` (grayscale mask), `position`, `size` (omit to cover the canvas) |
|
|
300
281
|
|
|
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
282
|
## Dot grid
|
|
420
283
|
|
|
421
284
|
`createDotGrid(gl, options)` draws evenly spaced dots as GPU points, laid out from
|
|
@@ -424,84 +287,27 @@ with `mask-position: center`. A moving cursor throws the dots near it aside and
|
|
|
424
287
|
back home with a damped bounce; a still cursor does nothing. Each dot's offset and velocity
|
|
425
288
|
live in one texel of a half-float ping-pong texture (`cols × rows`) that a fullscreen pass
|
|
426
289
|
advances per frame, and the point shader reads its texel back. Without half-float render
|
|
427
|
-
targets
|
|
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`.
|
|
290
|
+
targets the grid is static.
|
|
434
291
|
|
|
435
292
|
Options come in groups (`dotGridSpecs` holds the types, `DOT_GRID_DEFAULTS`,
|
|
436
|
-
`resolveDotGridOptions`, `isDotGridInteractive`, `getDotGridCoverSize`,
|
|
437
|
-
`makeDotGridTileUrl
|
|
438
|
-
|
|
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):
|
|
293
|
+
`resolveDotGridOptions`, `isDotGridInteractive`, `getDotGridCoverSize`, and
|
|
294
|
+
`makeDotGridTileUrl`, which returns one tile of the grid as an SVG data URL for a
|
|
295
|
+
`mask-image` placeholder that lines up with the canvas):
|
|
441
296
|
|
|
442
297
|
| Group | Fields | Meaning |
|
|
443
298
|
| -------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
444
|
-
| `dots` | `size` 2.25, `shape` `circle`, `spacing` 7, `color` `#ffffff`, `opacity` 1
|
|
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`
|
|
299
|
+
| `dots` | `size` 2.25, `shape` `circle`, `spacing` 7, `color` `#ffffff`, `opacity` 1 | The grid at rest (defaults match marketday's `.pattern_speckle` tile). `shape` is `circle` or `rounded_square` (`size` is the bounding size either way); thrown dots keep it |
|
|
300
|
+
| `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` for a static grid |
|
|
446
301
|
| `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`
|
|
448
|
-
| `
|
|
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 |
|
|
302
|
+
| `pulse` | `count` 20, `interval` 3000, `duration` 1500, `scale` 3, `opacity`, `shape` | Ambient twinkle: each cycle about `count` random dots swell to `scale`× (and to `opacity`, if given) and back over `duration` ms, each starting at a random moment in the cycle, and morphing into `shape` (default `dots.shape`) at the peak. Picked by hashing the cell with the cycle number, so it costs no per-dot state; needs continuous frames. Starts only once any reveal has finished. `true` for the defaults |
|
|
303
|
+
| `reveal` | `delay` 1000, `duration` 800, `zoomOnMount` 1, `zoomDuration` 1000 | Intro: dots start at the cover size (√2 × spacing + 1 for circles, less for rounded squares, so no pixel is uncovered), hold for `delay`, then shrink to `dots.size` over `duration`; kicks are ignored meanwhile. With an image, `zoomOnMount` (e.g. 1.25) eases it from that scale to the plain cover fit over `zoomDuration`, starting at mount and independent of `delay`: the shrink begins when the delay is up whether or not the zoom has finished (but never before the canvas has started rendering, since only it can draw dots). `true` for the defaults |
|
|
450
304
|
|
|
451
305
|
Resolved options are themselves valid options, so a scene can pass them straight through.
|
|
452
306
|
|
|
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
307
|
Drive the grid from a scene: `resize(size)` from `resize`; `setOptions` from `setParams`;
|
|
500
308
|
`setOverlay(imageTexture | null)` to show an image through the dots instead of `dots.color`
|
|
501
309
|
(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
|
|
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);
|
|
310
|
+
onto it and a bigger dot shows more); `setReveal(0..1)` with an already eased amount and `setOverlayZoom(scale)` for the image; `setTime(seconds)` each frame while `isPulsing()`, with `setPulseStart(seconds | null)` to begin (or hold) the pulsing on that clock;
|
|
505
311
|
`step(pointerPx, velocityPxPerSecond, active, dt, now)` from `update` with the raw pointer in
|
|
506
312
|
CSS pixels (y down), which returns whether the dots are still settling so the scene can
|
|
507
313
|
`invalidate()`; and `draw(clear)` from `render` (`draw(true)` clears to transparent first).
|