@arraypress/effects-astro 0.3.0 → 0.5.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.
package/AGENTS.md CHANGED
@@ -17,6 +17,7 @@ Pick by what is asked for:
17
17
  | Smoke or ink on a light page | `<Ink dark colors={[…]}>` (dark dye alone barely shows) |
18
18
  | Panels of colour fanning out of the dark, a bold launch or fintech hero with depth | `<ColorPanels>` (Opening by default; `preset="Glass"`, `"Default"` or `"Gradient"`; `palette` or `colors`, `quiet` behind copy) |
19
19
  | A gradient, noise, halftone or liquid-metal look by name | `<PaperShader shader="…" preset="…">`; the demo has a hero for every shader, its presets in the tag |
20
+ | A glossy, glassy or studio-lit background a palette recolours: liquid marble, frosted or ribbed glass, glossy tiles, chrome, glitter, holographic foil, a neon ribbon, pastel spheres or a blob, glass rings or strands, ink in water, topographic lines | `<Scene name="…" palette="…">` (`marble`, `frosted`, `ribs`, `tiles`, `blob`, `chrome`, `glitter`, `foil`, `ribbon`, `spiral`, `swirl`, `arches`, `spheres`, `spheres2`, `strands`, `rings`, `ink-water`, `topo`); `params` reshapes it (`PARAMS[name]` in `@arraypress/shaders` lists each scene's); lazy by default, so a wall of cards can each have one |
20
21
  | A themed hero background by name (mesh gradient, grainy gradient, silk, light bands, synthwave grid, neon waves), tinted from the site's accent | `<ShaderBackground effect="…">`; `static` when it sits behind body copy or is `fixed` |
21
22
  | A launch, waitlist or coming-soon hero: light around centred copy | `<HaloRing>` |
22
23
  | A dark, premium product or smart-home hero: frosted glass lit from within, copy beside it | `<RadiantGlass>` (`side="right"` mirrors it; `layout`, `shape`) |
@@ -29,12 +30,14 @@ Pick by what is asked for:
29
30
  | A map, outdoors, travel or trail hero: contour lines like a survey map | `<Topography>` (dark by default; `background="#f3ead6" colors={['#9a6b43']}` for a paper map; `labels` for elevation numbers, `quiet` behind copy) |
30
31
  | A taxi, ride-hailing, delivery, mobility or city-services hero: a tiny living city | `<IsoCity accent="…">` (`night` for lit windows and headlights, `side="right"` + `quiet` beside copy; a click on a street calls a taxi) |
31
32
  | A "we sell worldwide" or "we ship from here" section | `<WorldRoutes>` with the cities that matter to the shop; `home="…"` for a hub, `colors` + `gradient` for colour, `labels`, `region="europe"` (or `routes`) to crop |
33
+ | A space, astronomy, night-sky or sci-fi hero: a nebula with stars | `<Galaxy palette="…">` (Canvas 2D, no WebGL; `stars`, `glitter`, `speed`) |
32
34
  | A light or texture over a background (a spotlight, film grain) | `<GlowField>`, `<Grain>` (`still` for either to hold) |
33
35
  | The brand's logo as the hero's centrepiece | `<GlassGlyph>`, `<LiquidMetal>` (liquid chrome you can poke and splash; `tint="gold"`…), `<ParticleLogo>`, `<NeonSwarm>` (a flowing neon swarm), `<NebulaLogo>` (filled with nebula gas), `<VoxelLogo>`, `<PointCloud>`, all with `src="/logo.svg"` or `text` |
34
36
  | A footer wordmark | `<SpotlightText fit>`, `<PixelGlitchText fit>`, `<OutlineWordmark>` |
35
37
  | Sections that arrive on scroll, site-wide | `<ScrollReveal />` once in the layout, then reveal.css classes (`fade-in-up`…) on elements |
36
38
  | A type foundry or bold brand headline: big variable-font letters that swell under the pointer | `<VariableType as="h1" fit>` set in a variable font (`axes` for which axes swell) |
37
39
  | Text that arrives or moves | `<Reveal>`, `<ScrambleText>`, `<Typewriter>`, `<HighlightSweep>`, `<Marquee>` |
40
+ | A headline that glitches now and then (a label, a studio, a "make it yours" card) | `<GlitchText as="h2">` (CSS only; `blend="screen"` on a dark ground, `every`, `colors`) |
38
41
  | A small logo mark, a loading or "live" sign | `<PulseMark>`, `.fx-live` from `motion.css` |
39
42
  | A hero photo that reacts like water: ripples, a pond, "touch the photo" | `<ImageRipple src="…" alt="…">` (`strength`, `size`, `viscosity`, `fringe`, `fit="contain"`) |
40
43
  | A digital-goods or shop hero showing the products: their covers as the centrepiece, copy beside them | `<ProductStack items={[{ src, href, alt }, …]}>` (`layout="fan"`, `"stack"` or `"arc"`), or the covers as `<a><img></a>` children |
@@ -57,6 +60,7 @@ Things that trip people up:
57
60
  - **Clicks:** effects that react to clicks ignore links, buttons and form fields. Add `data-effect-ignore` to anything else whose clicks are its own.
58
61
  - **`<SpotlightText fill="dodge">`** blends with what is behind it: no stacking context may sit between them (no `z-index` on a positioned ancestor, no `opacity`, `transform`, `filter` or `isolation`). Use `fill="solid"` where that cannot be arranged.
59
62
  - **Styling a component's element** from the page needs `:global(.its-class)`, since the element belongs to the component.
63
+ - **`<Scene>` takes a palette by name** (`palette="Barbie"`); `@arraypress/shaders` itself takes the palette object (`PALETTES.Barbie`), never the name. Its `lazy` is the scene's own (a context held near the screen, given back four seconds after leaving on a fresh canvas), not `mount()`'s.
60
64
  - **`<PaperShader>` needs WebGL 2** and shows `background` without it. Its picture shaders take `image` (same origin, or served with CORS).
61
65
  - **Colour presets:** any effect that takes `colors` takes `palette="…"` (`PALETTES`: Lumetri, Forest, Cadmium, Peacock, Vermillion, Barbie, Uranium, Azure, Ruby, Ultramarine, Saffron, Crimson, Ember, Lagoon, Citrus, Glacier, Rosewater, Mono). Reach for a palette before inventing colours, and avoid violet unless the brand is violet.
62
66
  - **Changing colours at runtime:** `setColors(el, colors, glint?)` from `@arraypress/effects-astro`.
@@ -64,7 +68,7 @@ Things that trip people up:
64
68
 
65
69
  ## Working on this package
66
70
 
67
- Plain ES modules in `src/` with hand-written `.d.ts` files beside them: components in `src/components/`, the runtime in `src/runtime/` (one concern a file), stylesheets in `src/styles/`. No build step and no dependencies. `demo/` is an Astro site (not published): one gallery page of every effect as a working hero, a file of heroes per group in `demo/src/heroes/` (listed in `demo/src/tour/groups.ts`), shown one at a time and filtered by type (`src/scripts/viewer.js`; only the hero on show has its effect stamped in). Each hero's Customise panel is generated from the components' prop docs by `npm run docs`, so every prop needs a doc comment with its default and, for numbers, a range written "0–1".
71
+ Plain ES modules in `src/` with hand-written `.d.ts` files beside them: components in `src/components/`, the runtime in `src/runtime/` (one concern a file), stylesheets in `src/styles/`. No build step, and one dependency: `@arraypress/shaders` (the owner's own scene shaders, for `<Scene>`). `demo/` is an Astro site (not published): one gallery page of every effect as a working hero, a file of heroes per group in `demo/src/heroes/` (listed in `demo/src/tour/groups.ts`), shown one at a time and filtered by type (`src/scripts/viewer.js`; only the hero on show has its effect stamped in). Each hero's Customise panel is generated from the components' prop docs by `npm run docs`, so every prop needs a doc comment with its default and, for numbers, a range written "0–1".
68
72
 
69
73
  | | |
70
74
  |---|---|
@@ -83,7 +87,7 @@ The shaders and canvases cannot run under Node. After changing an effect, check
83
87
  - **No repetition.** Anything two effects need goes in its own runtime module and is imported.
84
88
  - **JSDoc on every function**, nested ones included: a short description, `@param` for each parameter, `@returns`, `@throws` where it applies. Every prop has a doc comment with its default (COMPONENTS.md is built from them). Keep the `.d.ts` files in step. Plain, concise voice: what a thing does and why.
85
89
  - **Colour in Oklab** (`mixOklab`, `paletteAt`, `GLSL_PALETTE`), never mixed in RGB.
86
- - **No telemetry, no network, no dependencies.** Effects ship inside sites for other people's visitors.
90
+ - **No telemetry, no network, no third-party dependencies.** Effects ship inside sites for other people's visitors. The one dependency is `@arraypress/shaders`, the owner's own; a scene's shader belongs there, and `<Scene>` only wraps it.
87
91
  - **`src/vendor/paper/` is Paper's code, unchanged but for dropped source-map comments** (Apache-2.0). Update it by re-vendoring a release and regenerating `presets.js`; never edit it by hand.
88
92
  - **Credit what is adapted**, in the module's header, the README's Credits and LICENSE, and only from MIT-compatible sources. shaders.com's open-source components (MIT) may be adapted; its presets and sections are licensed content and may not be copied, even modified.
89
93
  - **Every change goes in CHANGELOG.md** (Keep a Changelog, SemVer). Commit and push only with the owner's go-ahead; the owner publishes to npm.
package/COMPONENTS.md CHANGED
@@ -58,6 +58,8 @@ BorderSweep: a light travelling round an element's outline, on hover and focus o
58
58
  | `speed` | `number` | Seconds a lap takes. Default 2.6. |
59
59
  | `width` | `number` | The ring's width, px. Default 1. |
60
60
  | `always` | `boolean` | Run all the time, not only on hover. Default false. |
61
+ | `lights` | `1 \| 2` | How many lights go round, 1–2: two chase each other half a lap apart. Default 1. |
62
+ | `inset` | `boolean` | Draw the ring inside the edge and over the content, for elements that clip (`overflow: hidden`) and fill themselves with a picture or a canvas. Default false. |
61
63
  | `class` | `string` | Classes for the element. |
62
64
 
63
65
  ## `<Caustics>`
@@ -222,6 +224,30 @@ FlutedGlass: a pane of slanted fluted glass over soft blooms of colour, the main
222
224
  | `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
223
225
  | `class` | `string` | Classes for the element. |
224
226
 
227
+ ## `<Galaxy>`
228
+
229
+ Galaxy: deep space in your colours. Soft nebula clouds with dark dust lanes, fine glitter shimmering over them and stars twinkling each on its own beat, the brightest with a cross of light, all drifting slowly. See src/runtime/galaxy.js.
230
+
231
+ ```astro
232
+ <section class="hero" style="position: relative">
233
+ <Galaxy palette="Peacock" />
234
+ <h1>Made for <em>night owls.</em></h1>
235
+ </section>
236
+ ```
237
+
238
+ | Prop | Type | |
239
+ |---|---|---|
240
+ | `colors` | `string[]` | The nebula's colours, deep to bright (two to five read best), blended in Oklab from near-black up to a pale highlight. Default indigo, cornflower, violet and cyan. |
241
+ | `palette` | `PaletteName \| (string & {})` | A shared palette by name (`PALETTES`, any case), when there are no `colors`. |
242
+ | `speed` | `number` | How fast it drifts and twinkles, 0–4; 0 holds it still. Default 1. |
243
+ | `stars` | `number` | How many stars, as a share of the usual, 0–3; 0 for none. Default 1. |
244
+ | `glitter` | `number` | How bright the fine glitter is, as a share of the usual, 0–2; 0 for none. Default 1. |
245
+ | `seed` | `number` | Which sky, 1–999: the same seed draws the same nebula and stars. Default 7. |
246
+ | `lazy` | `boolean \| string` | Run only while near the screen (true, or a CSS length; default `200px`), handled by `mount`. Default false. |
247
+ | `background` | `string` | What shows before it draws. Default `#05040d`. |
248
+ | `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
249
+ | `class` | `string` | Classes for the element. |
250
+
225
251
  ## `<Glass>`
226
252
 
227
253
  Glass: a liquid glass panel, with a rim that catches the light and a sheen that follows the pointer. A wrapper for `class="glass"` from glass.css that also starts the sheen; for elements you render yourself, import `@arraypress/effects-astro/glass.css` and add the class, then call `glassSheen()` once.
@@ -281,6 +307,25 @@ GlassGlyph: a character or a logo as a thick slab of dark, smoked glass, lit fro
281
307
  | `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
282
308
  | `class` | `string` | Classes for the element. |
283
309
 
310
+ ## `<GlitchText>`
311
+
312
+ GlitchText: a headline that glitches now and then. Every few seconds two coloured copies of it (pink and blue by default) flash over it for a few frames, sliced into bands and shifted sideways, and the text nudges with them; the rest of the time it sits still. Livelier under the pointer (on the text, or a link or button round it). Each one on the page glitches on its own beat. CSS only, from glitch-text.css; with reduced motion it is the plain text. Not the canvas `<PixelGlitchText>`, which breaks into pixels under the pointer.
313
+
314
+ ```astro
315
+ <GlitchText as="h2" blend="screen">Seen one you like? <em>Make it yours.</em></GlitchText>
316
+ ```
317
+
318
+ | Prop | Type | |
319
+ |---|---|---|
320
+ | `as` | `HTMLTag` | The element to render. Default `span`. |
321
+ | `every` | `number` | Seconds from one glitch to the next, 2–12 (the burst is a fixed share of it, so it lengthens too). Default 5. |
322
+ | `hoverEvery` | `number` | Seconds from one glitch to the next under the pointer, 0.5–5. Default 1.6. |
323
+ | `delay` | `number` | Where in its cycle it starts, seconds (negative is part way in); give several the same to glitch together. Default a random offset, so each has its own beat. |
324
+ | `colors` | `string[]` | The two copies' colours. Default `['#ff3ea5', '#2e4bff']` (pink and blue). |
325
+ | `palette` | `PaletteName \| (string & {})` | A shared palette by name (`PALETTES`, any case), its first two colours, when there are no `colors`. |
326
+ | `blend` | `'multiply' \| 'screen' \| 'normal' \| 'difference' \| 'plus-lighter'` | How the copies blend with the text and what is behind: `multiply` on a light ground, `screen` on a dark one. Default `multiply`. |
327
+ | `class` | `string` | Classes for the element. |
328
+
284
329
  ## `<GlowField>`
285
330
 
286
331
  GlowField: a light laid over a section's background, or over a shader: a hard light source above an organic wash, so a headline has something to sit in. Pure CSS gradients that move only by transform and opacity, so it costs next to nothing and cannot fail to start.
@@ -816,7 +861,7 @@ PixelGlitchText: one line of text that breaks into pixels under the pointer and
816
861
  | `decay` | `number` | Heat kept each frame (0.9 is gone in about half a second). Default 0.9. |
817
862
  | `block` | `number` | The pixel block size at full heat, CSS px. Default 22. |
818
863
  | `shift` | `number` | How far the hottest rows slip sideways, CSS px. Default 16. |
819
- | `stroke` | `number` | With a width (CSS px), the text at rest is an outline that the pixels fill. Default 0 (solid). |
864
+ | `stroke` | `number` | With a width (CSS px), the text at rest is an outline that the pixels fill: one outline round the word, so overlapping letters merge. Default 0 (solid). |
820
865
  | `as` | `HTMLTag` | The element to render. Default `span`. |
821
866
  | `fit` | `boolean` | Size the text to span its parent's width. Default false. |
822
867
  | `class` | `string` | Classes for the element. |
@@ -968,6 +1013,40 @@ Reveal: content that rises, slides, zooms or un-blurs into place as it scrolls i
968
1013
  | `distance` | `number` | How far it travels, px. Default 24. |
969
1014
  | `class` | `string` | Classes for the element. |
970
1015
 
1016
+ ## `<Scene>`
1017
+
1018
+ Scene: one of the scenes from `@arraypress/shaders` as a background: liquid marble, frosted glass, ribbed light, glossy tiles, a pastel blob, chrome liquid, a glitter galaxy, holographic foil, a neon ribbon, spiral trails, a glass swirl, arches, pastel spheres, glass strands, glass rings, ink in water and topographic lines. Any palette recolours it, and its own settings (`params`) reshape it. See src/runtime/scene.js.
1019
+
1020
+ ```astro
1021
+ <Scene name="marble" palette="Barbie" params={{ scale: 1.2 }} />
1022
+ <Scene name="ink-water" colors={['#0d1461', '#990f61', '#050514']} speed={0.6} />
1023
+ <Scene name="foil" fixed opacity={0.5} />
1024
+ ```
1025
+
1026
+ | Prop | Type | |
1027
+ |---|---|---|
1028
+ | `name` (required) | `SceneName` | The scene: marble, frosted, ribs, tiles, blob, chrome, glitter, foil, ribbon, spiral, swirl, arches, spheres, spheres2, strands, rings, ink-water or topo. Required. |
1029
+ | `palette` | `PaletteName` | A named palette (PALETTES): its three colours and its glint. Default the scene's own colours. |
1030
+ | `colors` | `string[]` | One to three colours (hex), over the palette's. Default the palette's, or the scene's own. |
1031
+ | `glint` | `string` | The highlight colour (hex), over the palette's. Default the palette's, or the scene's own. |
1032
+ | `params` | `Record<string, number>` | The scene's own settings by key (`PARAMS[name]` in `@arraypress/shaders`; marble takes `scale`, `sharpness`, `warp` and `relief`). Default the scene's. |
1033
+ | `speed` | `number` | How fast it moves, 0–3 (0 still). Default 1. |
1034
+ | `hue` | `number` | Hue turned round the colour wheel, -180–180 degrees. Default 0. |
1035
+ | `sat` | `number` | Saturation, 0–2 (0 grey). Default 1. |
1036
+ | `exposure` | `number` | Brightness, 0.3–2. Default 1. |
1037
+ | `tint` | `string` | A colour to lean toward (hex), keeping the light and dark, by `tintAmount`. Default `#d4ff3a`. |
1038
+ | `tintAmount` | `number` | How far toward `tint`, 0–1. Default 0. |
1039
+ | `zoom` | `number` | Zoom, 0.5–2.5. Default 1. |
1040
+ | `angle` | `number` | Rotation, -180–180 degrees. Default 0. |
1041
+ | `grain` | `number` | Film grain, 0–3. Default 1. |
1042
+ | `fps` | `number` | Frames a second, 1–60. Default 30. |
1043
+ | `scale` | `number` | Share of CSS pixels drawn at, 0.1–1 (lowered while frames come late). Default the scene's own, 0.45–0.85. |
1044
+ | `lazy` | `boolean \| string` | Hold a WebGL context only while near the screen (true, or how near as a CSS length), giving it back four seconds after leaving; false holds one from the start. Default true. |
1045
+ | `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
1046
+ | `background` | `string` | What shows before it draws, and without WebGL 2 (a CSS background). Default the scene's colours as soft blooms over its ground. |
1047
+ | `opacity` | `number` | Its opacity, 0–1, for backdrops under copy. Default 1. |
1048
+ | `class` | `string` | Classes for the element. |
1049
+
971
1050
  ## `<ScrambleText>`
972
1051
 
973
1052
  ScrambleText: text that resolves out of random characters, left to right, when it scrolls into view, and again on hover if asked. For a label, a stat, a short headline. Screen readers and search get the real text; the scramble is drawn over it. See src/runtime/text-motion.js.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @arraypress/effects-astro
2
2
 
3
- Effects for Astro sites, as components: shader backgrounds, a real fluid, logos made of glass, particles or cubes, text that glitches, scrambles or types itself, glass panels and marquees: what makes a page look alive. Small UI pieces (countdowns, sliders, drop zones, tooltips) live in [`@arraypress/ui-astro`](https://github.com/LumiThemes/ui-astro); counters and drag-to-scroll in [`@arraypress/behaviors-astro`](https://github.com/arraypress/behaviors-astro). Plain WebGL, Canvas and CSS with no dependencies, and with the fallbacks a theme needs built in.
3
+ Effects for Astro sites, as components: shader backgrounds, a real fluid, logos made of glass, particles or cubes, text that glitches, scrambles or types itself, glass panels and marquees: what makes a page look alive. Small UI pieces (countdowns, sliders, drop zones, tooltips) live in [`@arraypress/ui-astro`](https://github.com/LumiThemes/ui-astro); counters and drag-to-scroll in [`@arraypress/behaviors-astro`](https://github.com/arraypress/behaviors-astro). Plain WebGL, Canvas and CSS with no third-party dependencies (`<Scene>`'s shaders come from the owner's own [`@arraypress/shaders`](https://github.com/arraypress/shaders)), and with the fallbacks a theme needs built in.
4
4
 
5
5
  ```astro
6
6
  ---
@@ -54,6 +54,8 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
54
54
  | `<Ocean>` | Photoreal open sea to the horizon: wind-driven waves, a glittering sun path, light through thin crests, whitecaps, high cloud and haze; `time` dawn, noon, sunset or a moonlit night; the camera drifts with the pointer | WebGL |
55
55
  | `<IsoCity>` | A tiny isometric low-poly city with traffic keeping its lanes and the brand's taxis; click a street and the nearest one drives round to pick you up; `night` lights the windows and headlights | WebGL |
56
56
  | `<ColorPanels>` | Translucent panels of colour swinging open out of the dark and sweeping past like turning pages: Paper's color-panels shader with plain props (`density`, `skewLeft`, `length`, `edges`, `blur`, `blend`…), its Opening preset by default (`preset` for the others) | WebGL 2 |
57
+ | `<Galaxy>` | Deep space in a palette's colours: soft nebula clouds with dust lanes, shimmering glitter and twinkling stars, drifting slowly | Canvas |
58
+ | `<Scene>` | One of twenty studio-lit scenes from [`@arraypress/shaders`](https://github.com/arraypress/shaders) by `name`: liquid marble, frosted or ribbed glass, glossy tiles, chrome, glitter, holographic foil, a neon ribbon, pastel spheres, glass rings, ink in water, oil bubbles, a melting hologram, topographic lines and more; any `palette` recolours it, `params` reshapes it, lazy by default | WebGL 2 |
57
59
  | `<WorldRoutes>` | A dotted world map with comets of light arcing between cities: a home hub, per-route colours and Oklab gradients, labels, regions, great-circle arcs, hover | Canvas |
58
60
  | `<GlowField>` | A light to lay over a background: a bloom, a swaying stage spotlight, a horizon or a wash, breathing gently | CSS |
59
61
  | `<Grain>` | Flickering film grain, to dither smooth gradients and make a picture read as film | CSS |
@@ -87,6 +89,7 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
87
89
  | `<Reveal>` | Content, or each word, rising into place on scroll | CSS + JS |
88
90
  | `<ScrollReveal>` | Once in a layout: anything with a reveal.css class (`fade-in-up`, `zoom-in`, `flip-left`…) arrives on scroll | CSS + JS |
89
91
  | `<HighlightSweep>` | A marker underline sweeping in under a word | CSS |
92
+ | `<GlitchText>` | A headline that glitches every few seconds, each on its own beat: two coloured copies sliced and shifted for a few frames; livelier under the pointer | CSS |
90
93
  | `<Marquee>` | An endless strip of names or logos, with a pause button | CSS + JS |
91
94
  | `<VariableType>` | A variable-font headline whose letters swell heavier and wider under the pointer in a springy wave, and drift gently on their own | JS |
92
95
 
@@ -99,7 +102,7 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
99
102
  | `<MosaicReveal>` | A slideshow whose pictures change through a GPU transition: tiles flipping in a diagonal wave, a pixel-sort melt, pixelation or a glowing dissolve | WebGL |
100
103
  | `<RadiantGlass>` | A cluster of frosted glass tiles on a dark ground, glowing from inside with soft drifting light that shifts with the pointer; a two-tone rim and a halo on each | WebGL |
101
104
  | `<Glass>` | A liquid glass panel with a lit rim and a pointer sheen; `refract` bends the live page behind it like a thick lens, with colour at the rim (Chromium; elsewhere it stays frosted) | CSS + JS |
102
- | `<BorderSweep>` | A light travelling round an outline | CSS |
105
+ | `<BorderSweep>` | A light travelling round an outline (or two chasing each other); `inset` for cards that clip | CSS |
103
106
  | `<Tilt>` | A card that leans towards the pointer, with a glare | CSS + JS |
104
107
  | `<Parallax>` | Layers that drift with the pointer by depth | CSS + JS |
105
108
  | `<Magnetic>` | A button the pointer pulls on | CSS + JS |
@@ -111,7 +114,8 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
111
114
  | Import | Classes |
112
115
  |---|---|
113
116
  | `@arraypress/effects-astro/glass.css` | `.glass` (call `glassSheen()` once for the sheen) |
114
- | `@arraypress/effects-astro/border-sweep.css` | `.sweep-ring`, `--always`, `--fast` |
117
+ | `@arraypress/effects-astro/border-sweep.css` | `.sweep-ring`, `--always`, `--fast`, `--two`, `--inset` |
118
+ | `@arraypress/effects-astro/glitch-text.css` | `.glitch-text` with its copies `.glitch-text-a` and `.glitch-text-b` (markup in the file) |
115
119
  | `@arraypress/effects-astro/motion.css` | `.fx-pulse-ring`, `.fx-heartbeat`, `.fx-bump` (replay with `bump(el)`), `.fx-shimmer`, `.fx-pulse`, `.fx-wiggle`, `.fx-shake`, `.fx-settle`, `.fx-live` (a status dot) |
116
120
  | `@arraypress/effects-astro/reveal.css` | `.fade-in`, `.fade-in-up/down/left/right`, `.slide-in-*`, `.zoom-in`, `.zoom-out`, `.flip-up/down/left/right`, `.blur-in` (with `<ScrollReveal />`) |
117
121
 
@@ -139,7 +143,7 @@ Every effect that takes `colors` also takes `palette`, one of eighteen named set
139
143
 
140
144
  ## Changing colours
141
145
 
142
- The WebGL effects (`<LightField>`, `<InkField>`, `<Ink>`, `<AsciiRain>`, `<FlutedGlass>`, `<GlassGlyph>`, `<LiquidMetal>`, `<ParticleLogo>`, `<NeonSwarm>`, `<NebulaLogo>`, `<PointCloud>`, `<VoxelLogo>`, `<SignalLines>`, `<WaveBars>`, `<DotSurface>`, `<HaloRing>`, `<SilkRibbon>`, `<RadiantGlass>`, `<Topography>`, `<Caustics>`, `<RainOnGlass>`, `<MosaicReveal>`, `<Ocean>`, `<IsoCity>`) read a `data-colors` attribute; `setColors` writes it. A light or an ink field eases to the new palette in about a second; ink, rain and the rest take it from their next frame. Set before an effect starts, it is its colours from the first frame.
146
+ The WebGL effects (`<LightField>`, `<InkField>`, `<Ink>`, `<AsciiRain>`, `<FlutedGlass>`, `<GlassGlyph>`, `<LiquidMetal>`, `<ParticleLogo>`, `<NeonSwarm>`, `<NebulaLogo>`, `<PointCloud>`, `<VoxelLogo>`, `<SignalLines>`, `<WaveBars>`, `<DotSurface>`, `<HaloRing>`, `<SilkRibbon>`, `<RadiantGlass>`, `<Topography>`, `<Caustics>`, `<RainOnGlass>`, `<MosaicReveal>`, `<Ocean>`, `<IsoCity>`, `<Scene>`) and `<Galaxy>` read a `data-colors` attribute; `setColors` writes it. A light or an ink field eases to the new palette in about a second; ink, rain and the rest take it from their next frame. Set before an effect starts, it is its colours from the first frame.
143
147
 
144
148
  ```js
145
149
  import { setColors } from '@arraypress/effects-astro';
@@ -154,6 +158,7 @@ The package's main entry is the runtime the components are built on, for use wit
154
158
  | Export | |
155
159
  |---|---|
156
160
  | `paperShader(el, config)`, `paperSettings`, `paperUniforms` | Paper's shaders, and the settings and uniforms for a shader and preset |
161
+ | `scene(el, config)`, `sceneSettings` | `<Scene>`: an `@arraypress/shaders` scene on an element's canvas, and its props as that package's options |
157
162
  | `paperLook(el, config)`, `paperLookSettings`, `PAPER_LOOKS` | The Paper looks (`<ColorPanels>`…): a look's plain props as a Paper shader's settings, and the looks by name |
158
163
  | `createStage(el, options)` | A full-canvas WebGL effect: context, program, sizing, the loop, reduced motion, clean-up |
159
164
  | `createCanvas2D(el, options)`, `grainPattern`, `grainOnto` | The same for Canvas 2D effects, and grain laid onto strokes only |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arraypress/effects-astro",
3
- "version": "0.3.0",
4
- "description": "GPU effects for Astro sites, as components: liquid light with a real fluid under it, ink in water, and outline text a spotlight fills. Plain WebGL, no dependencies, with the fallbacks a theme needs (reduced motion, no WebGL, touch screens, off-screen pausing).",
3
+ "version": "0.5.0",
4
+ "description": "GPU effects for Astro sites, as components: liquid light with a real fluid under it, ink in water, and outline text a spotlight fills. Plain WebGL, no third-party dependencies, with the fallbacks a theme needs (reduced motion, no WebGL, touch screens, off-screen pausing).",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
7
7
  "types": "src/index.d.ts",
@@ -43,6 +43,9 @@
43
43
  "engines": {
44
44
  "node": ">=20"
45
45
  },
46
+ "dependencies": {
47
+ "@arraypress/shaders": "^0.1.0"
48
+ },
46
49
  "peerDependencies": {
47
50
  "astro": "^6 || ^7"
48
51
  },
@@ -6,7 +6,9 @@
6
6
  * `@arraypress/effects-astro/border-sweep.css` and add the class.
7
7
  *
8
8
  * Suits outlined things: cards, ghost buttons, a featured pricing tier. A
9
- * filled button has no outline for the light to travel.
9
+ * filled button has no outline for the light to travel. `lights={2}` sends
10
+ * two round, chasing each other; `inset` keeps the ring over the content of
11
+ * a card that clips and fills itself.
10
12
  *
11
13
  * @example
12
14
  * <BorderSweep as="a" href="/pricing" class="card" color="#a5b4fc" always>…</BorderSweep>
@@ -26,14 +28,18 @@ interface Props {
26
28
  width?: number;
27
29
  /** Run all the time, not only on hover. Default false. */
28
30
  always?: boolean;
31
+ /** How many lights go round, 1–2: two chase each other half a lap apart. Default 1. */
32
+ lights?: 1 | 2;
33
+ /** Draw the ring inside the edge and over the content, for elements that clip (`overflow: hidden`) and fill themselves with a picture or a canvas. Default false. */
34
+ inset?: boolean;
29
35
  class?: string;
30
36
  [attribute: string]: unknown;
31
37
  }
32
38
 
33
- const { as: Tag = 'div', color, speed, width, always = false, class: className, style: given, ...attributes } = Astro.props;
39
+ const { as: Tag = 'div', color, speed, width, always = false, lights = 1, inset = false, class: className, style: given, ...attributes } = Astro.props;
34
40
  const style = [color && `--sweep-color: ${color}`, speed !== undefined && `--sweep-speed: ${speed}s`, width !== undefined && `--sweep-width: ${width}px`]
35
41
  .filter(Boolean)
36
42
  .join('; ');
37
43
  ---
38
44
 
39
- <Tag class:list={['sweep-ring', { 'sweep-ring--always': always }, className]} style={withStyle(style, given)} {...attributes}><slot /></Tag>
45
+ <Tag class:list={['sweep-ring', { 'sweep-ring--always': always, 'sweep-ring--two': lights === 2, 'sweep-ring--inset': inset }, className]} style={withStyle(style, given)} {...attributes}><slot /></Tag>
@@ -0,0 +1,40 @@
1
+ ---
2
+ /**
3
+ * Galaxy: deep space in your colours. Soft nebula clouds with dark dust
4
+ * lanes, fine glitter shimmering over them and stars twinkling each on
5
+ * its own beat, the brightest with a cross of light, all drifting slowly.
6
+ * See src/runtime/galaxy.js.
7
+ *
8
+ * Opaque: it is the whole background of what it fills (its nearest
9
+ * positioned ancestor, or the viewport with `fixed`). Canvas 2D, so it
10
+ * needs no WebGL; one still frame with reduced motion. `setColors`
11
+ * recolours it live.
12
+ *
13
+ * @example
14
+ * <section class="hero" style="position: relative">
15
+ * <Galaxy palette="Peacock" />
16
+ * <h1>Made for <em>night owls.</em></h1>
17
+ * </section>
18
+ */
19
+ import EffectCanvas from './EffectCanvas.astro';
20
+ import type { GalaxyConfig } from '../runtime/galaxy.js';
21
+
22
+ interface Props extends GalaxyConfig {
23
+ /** What shows before it draws. Default `#05040d`. */
24
+ background?: string;
25
+ /** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
26
+ fixed?: boolean;
27
+ class?: string;
28
+ }
29
+
30
+ const { background = '#05040d', fixed = false, class: className, ...config } = Astro.props;
31
+ ---
32
+
33
+ <EffectCanvas name="galaxy" config={config} fixed={fixed} class={className} behind background={background} />
34
+
35
+ <script>
36
+ import { mount } from '../runtime/mount.js';
37
+ import { galaxy } from '../runtime/galaxy.js';
38
+
39
+ mount('[data-effect-galaxy]', galaxy);
40
+ </script>
@@ -0,0 +1,69 @@
1
+ ---
2
+ /**
3
+ * GlitchText: a headline that glitches now and then. Every few seconds two
4
+ * coloured copies of it (pink and blue by default) flash over it for a few
5
+ * frames, sliced into bands and shifted sideways, and the text nudges with
6
+ * them; the rest of the time it sits still. Livelier under the pointer (on
7
+ * the text, or a link or button round it). Each one on the page glitches
8
+ * on its own beat. CSS only, from glitch-text.css; with reduced motion it
9
+ * is the plain text. Not the canvas `<PixelGlitchText>`, which breaks
10
+ * into pixels under the pointer.
11
+ *
12
+ * The slot is rendered three times: once as the real text, twice as the
13
+ * copies (hidden from assistive technology and from focus), so keep it to
14
+ * text and inline formatting. For elements you render yourself, import
15
+ * `@arraypress/effects-astro/glitch-text.css` and follow its markup.
16
+ *
17
+ * @example
18
+ * <GlitchText as="h2" blend="screen">Seen one you like? <em>Make it yours.</em></GlitchText>
19
+ */
20
+ import type { HTMLTag } from 'astro/types';
21
+ import type { PaletteName } from '../runtime/palettes.js';
22
+ import { pickColors } from '../runtime/palettes.js';
23
+ import '../styles/glitch-text.css';
24
+ import { withStyle } from './style.js';
25
+
26
+ interface Props {
27
+ /** The element to render. Default `span`. */
28
+ as?: HTMLTag;
29
+ /** Seconds from one glitch to the next, 2–12 (the burst is a fixed share of it, so it lengthens too). Default 5. */
30
+ every?: number;
31
+ /** Seconds from one glitch to the next under the pointer, 0.5–5. Default 1.6. */
32
+ hoverEvery?: number;
33
+ /** Where in its cycle it starts, seconds (negative is part way in); give several the same to glitch together. Default a random offset, so each has its own beat. */
34
+ delay?: number;
35
+ /** The two copies' colours. Default `['#ff3ea5', '#2e4bff']` (pink and blue). */
36
+ colors?: string[];
37
+ /** A shared palette by name (`PALETTES`, any case), its first two colours, when there are no `colors`. */
38
+ palette?: PaletteName | (string & {});
39
+ /** How the copies blend with the text and what is behind: `multiply` on a light ground, `screen` on a dark one. Default `multiply`. */
40
+ blend?: 'multiply' | 'screen' | 'normal' | 'difference' | 'plus-lighter';
41
+ class?: string;
42
+ [attribute: string]: unknown;
43
+ }
44
+
45
+ const { as: Tag = 'span', every, hoverEvery, delay, colors, palette, blend, class: className, style: given, ...attributes } = Astro.props;
46
+ const [a, b] = colors?.length || palette ? pickColors({ colors, palette }, ['#ff3ea5', '#2e4bff'], (p) => [p.colors[0], p.colors[1]]) : [];
47
+ const cycle = every ?? 5;
48
+ // Rendered once, at build time: each instance gets its own beat in the static page.
49
+ const offset = delay ?? -Number((Math.random() * cycle).toFixed(2));
50
+ const style = [
51
+ every !== undefined && `--glitch-every: ${every}s`,
52
+ hoverEvery !== undefined && `--glitch-hover: ${hoverEvery}s`,
53
+ `--glitch-delay: ${offset}s`,
54
+ a && `--glitch-a: ${a}`,
55
+ (b ?? a) && `--glitch-b: ${b ?? a}`,
56
+ blend && `--glitch-blend: ${blend}`,
57
+ ]
58
+ .filter(Boolean)
59
+ .join('; ');
60
+ const html = await Astro.slots.render('default');
61
+ ---
62
+
63
+ <Tag class:list={['glitch-text', className]} style={withStyle(style, given)} {...attributes}
64
+ ><span><Fragment set:html={html} /></span><span class="glitch-text-a" aria-hidden="true" inert><Fragment set:html={html} /></span><span
65
+ class="glitch-text-b"
66
+ aria-hidden="true"
67
+ inert><Fragment set:html={html} /></span
68
+ ></Tag
69
+ >
@@ -58,10 +58,10 @@ const { as: Tag = 'span', fit = false, cell, reach, decay, block, shift, stroke,
58
58
  -webkit-text-fill-color: transparent;
59
59
  -webkit-text-stroke: var(--glitch-stroke) currentColor;
60
60
  }
61
- /* Once the canvas draws the text, the element's own is only for layout. */
61
+ /* Once the canvas draws the text (and its outline, merged), the element's own is only for layout. */
62
62
  .effect-pixel-glitch:global(.is-ready) {
63
63
  -webkit-text-fill-color: transparent;
64
- -webkit-text-stroke: 0;
64
+ -webkit-text-stroke: 0 transparent;
65
65
  }
66
66
  .effect-pixel-glitch :global(.effect-pixel-glitch-canvas) {
67
67
  position: absolute;
@@ -0,0 +1,89 @@
1
+ ---
2
+ /**
3
+ * Scene: one of the scenes from `@arraypress/shaders` as a
4
+ * background: liquid marble, frosted glass, ribbed light, glossy tiles, a
5
+ * pastel blob, chrome liquid, a glitter galaxy, holographic foil, a neon
6
+ * ribbon, spiral trails, a glass swirl, arches, pastel spheres, glass
7
+ * strands, glass rings, ink in water and topographic lines. Any palette
8
+ * recolours it, and its own settings (`params`) reshape it. See
9
+ * src/runtime/scene.js.
10
+ *
11
+ * Fills its nearest positioned ancestor, or the viewport with `fixed`.
12
+ * Lazy by default: it holds a WebGL context only while near the screen
13
+ * and gives it back four seconds after it leaves, so a page can carry
14
+ * many. It draws at 30 frames a second, at a share of the screen's
15
+ * resolution that drops on slow devices, pauses off screen, and draws one
16
+ * still frame with reduced motion. Without WebGL 2, its colours show as
17
+ * soft blooms over its ground. `setColors` recolours it live.
18
+ *
19
+ * @example
20
+ * <Scene name="marble" palette="Barbie" params={{ scale: 1.2 }} />
21
+ * <Scene name="ink-water" colors={['#0d1461', '#990f61', '#050514']} speed={0.6} />
22
+ * <Scene name="foil" fixed opacity={0.5} />
23
+ */
24
+ import EffectCanvas from './EffectCanvas.astro';
25
+ import { SCENES, fallback, validateOptions } from '@arraypress/shaders';
26
+ import { sceneSettings } from '../runtime/scene.js';
27
+ import type { SceneName } from '../runtime/scene.js';
28
+ import type { PaletteName } from '../runtime/palettes.js';
29
+
30
+ interface Props {
31
+ /** The scene: marble, frosted, ribs, tiles, blob, chrome, glitter, foil, ribbon, spiral, swirl, arches, spheres, spheres2, strands, rings, ink-water or topo. Required. */
32
+ name: SceneName;
33
+ /** A named palette (PALETTES): its three colours and its glint. Default the scene's own colours. */
34
+ palette?: PaletteName;
35
+ /** One to three colours (hex), over the palette's. Default the palette's, or the scene's own. */
36
+ colors?: string[];
37
+ /** The highlight colour (hex), over the palette's. Default the palette's, or the scene's own. */
38
+ glint?: string;
39
+ /** The scene's own settings by key (`PARAMS[name]` in `@arraypress/shaders`; marble takes `scale`, `sharpness`, `warp` and `relief`). Default the scene's. */
40
+ params?: Record<string, number>;
41
+ /** How fast it moves, 0–3 (0 still). Default 1. */
42
+ speed?: number;
43
+ /** Hue turned round the colour wheel, -180–180 degrees. Default 0. */
44
+ hue?: number;
45
+ /** Saturation, 0–2 (0 grey). Default 1. */
46
+ sat?: number;
47
+ /** Brightness, 0.3–2. Default 1. */
48
+ exposure?: number;
49
+ /** A colour to lean toward (hex), keeping the light and dark, by `tintAmount`. Default `#d4ff3a`. */
50
+ tint?: string;
51
+ /** How far toward `tint`, 0–1. Default 0. */
52
+ tintAmount?: number;
53
+ /** Zoom, 0.5–2.5. Default 1. */
54
+ zoom?: number;
55
+ /** Rotation, -180–180 degrees. Default 0. */
56
+ angle?: number;
57
+ /** Film grain, 0–3. Default 1. */
58
+ grain?: number;
59
+ /** Frames a second, 1–60. Default 30. */
60
+ fps?: number;
61
+ /** Share of CSS pixels drawn at, 0.1–1 (lowered while frames come late). Default the scene's own, 0.45–0.85. */
62
+ scale?: number;
63
+ /** Hold a WebGL context only while near the screen (true, or how near as a CSS length), giving it back four seconds after leaving; false holds one from the start. Default true. */
64
+ lazy?: boolean | string;
65
+ /** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
66
+ fixed?: boolean;
67
+ /** What shows before it draws, and without WebGL 2 (a CSS background). Default the scene's colours as soft blooms over its ground. */
68
+ background?: string;
69
+ /** Its opacity, 0–1, for backdrops under copy. Default 1. */
70
+ opacity?: number;
71
+ class?: string;
72
+ }
73
+
74
+ const { fixed = false, background, opacity = 1, lazy = true, class: className, ...config } = Astro.props;
75
+ if (!Object.hasOwn(SCENES, config.name)) throw new Error(`<Scene>: no scene "${config.name}" (there are ${Object.keys(SCENES).join(', ')})`);
76
+ // `lazy` reaches the scene as `near`: under its own name, mount() would start and stop the scene itself, without the scene's own grace period and fresh canvas.
77
+ Object.assign(config, { near: lazy });
78
+ const { options } = sceneSettings(config);
79
+ validateOptions(config.name, options); // a bad param or colour fails the build, not the page
80
+ ---
81
+
82
+ <EffectCanvas name="scene" config={config} fixed={fixed} behind background={background ?? fallback(config.name, options)} opacity={opacity} class={className} />
83
+
84
+ <script>
85
+ import { mount } from '../runtime/mount.js';
86
+ import { scene } from '../runtime/scene.js';
87
+
88
+ mount('[data-effect-scene]', scene);
89
+ </script>
package/src/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { pointCloud } from './runtime/point-cloud.js';
16
16
  export type { PointCloudConfig } from './runtime/point-cloud.js';
17
17
  export { voxelLogo } from './runtime/voxel-logo.js';
18
18
  export type { VoxelLogoConfig } from './runtime/voxel-logo.js';
19
- export { pixelGlitch } from './runtime/pixel-glitch.js';
19
+ export { pixelGlitch, outlineAlpha } from './runtime/pixel-glitch.js';
20
20
  export type { PixelGlitchConfig } from './runtime/pixel-glitch.js';
21
21
  export { fit, fitText } from './runtime/fit-text.js';
22
22
  export { textNodes, textRange, splitLetters, joinLetters } from './runtime/text.js';
@@ -68,6 +68,8 @@ export { radiantGlass } from './runtime/radiant-glass.js';
68
68
  export type { RadiantGlassConfig } from './runtime/radiant-glass.js';
69
69
  export { topography } from './runtime/topography.js';
70
70
  export type { TopographyConfig } from './runtime/topography.js';
71
+ export { galaxy, galaxyRamp, nebulaField } from './runtime/galaxy.js';
72
+ export type { GalaxyConfig } from './runtime/galaxy.js';
71
73
  export { caustics, causticTones } from './runtime/caustics.js';
72
74
  export type { CausticsConfig, CausticTones } from './runtime/caustics.js';
73
75
  export { rainOnGlass } from './runtime/rain-on-glass.js';
@@ -99,6 +101,8 @@ export type { LiveGradientOptions } from './runtime/live-gradient.js';
99
101
  export type { PaperConfig, PaperShaderName } from './runtime/paper.js';
100
102
  export { paperLook, paperLookSettings } from './runtime/paper-look.js';
101
103
  export type { PaperLookConfig, PaperLookOptions } from './runtime/paper-look.js';
104
+ export { scene, sceneSettings } from './runtime/scene.js';
105
+ export type { SceneConfig, SceneName } from './runtime/scene.js';
102
106
  export { PAPER_LOOKS } from './runtime/paper-looks.js';
103
107
  export type { PaperLook, PaperLookName } from './runtime/paper-looks.js';
104
108
  export { createStage } from './runtime/stage.js';
@@ -140,7 +144,7 @@ export { mount, readConfig, watchColors } from './runtime/mount.js';
140
144
  /**
141
145
  * Changes the colours of a WebGL effect (`<LightField>`, `<Ink>`, `<AsciiRain>`,
142
146
  * `<FlutedGlass>`, `<GlassGlyph>`, `<LiquidMetal>`, `<ParticleLogo>`, `<PointCloud>`,
143
- * `<VoxelLogo>`, `<HaloRing>`, `<SilkRibbon>`, `<RadiantGlass>`, `<Topography>`, `<Caustics>`, `<RainOnGlass>`, `<MosaicReveal>`, `<Ocean>`, `<IsoCity>`),
147
+ * `<VoxelLogo>`, `<HaloRing>`, `<SilkRibbon>`, `<RadiantGlass>`, `<Topography>`, `<Caustics>`, `<RainOnGlass>`, `<MosaicReveal>`, `<Ocean>`, `<IsoCity>`, `<Scene>`),
144
148
  * in the order its `colors` takes. A light eases to them; the others take them next frame.
145
149
  */
146
150
  export function setColors(el: Element | null, colors: string[], glint?: string): void;
package/src/index.js CHANGED
@@ -20,7 +20,7 @@ export { flutedGlass } from './runtime/fluted-glass.js';
20
20
  export { particleLogo } from './runtime/particle-logo.js';
21
21
  export { pointCloud } from './runtime/point-cloud.js';
22
22
  export { voxelLogo } from './runtime/voxel-logo.js';
23
- export { pixelGlitch } from './runtime/pixel-glitch.js';
23
+ export { pixelGlitch, outlineAlpha } from './runtime/pixel-glitch.js';
24
24
  export { fit, fitText } from './runtime/fit-text.js';
25
25
  export { textNodes, textRange, splitLetters, joinLetters } from './runtime/text.js';
26
26
  export { variableType, DEFAULT_AXES } from './runtime/variable-type.js';
@@ -51,6 +51,7 @@ export { haloRing } from './runtime/halo-ring.js';
51
51
  export { silkRibbon } from './runtime/silk-ribbon.js';
52
52
  export { radiantGlass } from './runtime/radiant-glass.js';
53
53
  export { topography } from './runtime/topography.js';
54
+ export { galaxy, galaxyRamp, nebulaField } from './runtime/galaxy.js';
54
55
  export { caustics, causticTones } from './runtime/caustics.js';
55
56
  export { rainOnGlass } from './runtime/rain-on-glass.js';
56
57
  export { ocean } from './runtime/ocean.js';
@@ -68,6 +69,7 @@ export { paperShader, paperSettings, paperUniforms } from './runtime/paper.js';
68
69
  export { whenNear, lazyMargin } from './runtime/near.js';
69
70
  export { liveGradient } from './runtime/live-gradient.js';
70
71
  export { paperLook, paperLookSettings } from './runtime/paper-look.js';
72
+ export { scene, sceneSettings } from './runtime/scene.js';
71
73
  export { PAPER_LOOKS } from './runtime/paper-looks.js';
72
74
  export { createStage } from './runtime/stage.js';
73
75
  export { createMesh, STRIDE } from './runtime/mesh.js';
@@ -94,7 +96,7 @@ export { mount, readConfig, watchColors } from './runtime/mount.js';
94
96
  /**
95
97
  * Changes the colours of a WebGL effect (`<LightField>`, `<Ink>`,
96
98
  * `<AsciiRain>`, `<FlutedGlass>`, `<GlassGlyph>`, `<LiquidMetal>`,
97
- * `<ParticleLogo>`, `<PointCloud>`, `<VoxelLogo>`, `<HaloRing>`, `<SilkRibbon>`, `<RadiantGlass>`, `<Topography>`, `<Caustics>`, `<RainOnGlass>`, `<MosaicReveal>`, `<Ocean>`, `<IsoCity>`): a light
99
+ * `<ParticleLogo>`, `<PointCloud>`, `<VoxelLogo>`, `<HaloRing>`, `<SilkRibbon>`, `<RadiantGlass>`, `<Topography>`, `<Caustics>`, `<RainOnGlass>`, `<MosaicReveal>`, `<Ocean>`, `<IsoCity>`, `<Scene>`): a light
98
100
  * eases to them in about a second, the others take them from their next frame.
99
101
  *
100
102
  * @param {Element | null} el The effect's element (`[data-effect-light-field]` and so on).
@@ -0,0 +1,37 @@
1
+ import type { PaletteName } from './palettes.js';
2
+
3
+ export interface GalaxyConfig {
4
+ /** The nebula's colours, deep to bright (two to five read best), blended in Oklab from near-black up to a pale highlight. Default indigo, cornflower, violet and cyan. */
5
+ colors?: string[];
6
+ /** A shared palette by name (`PALETTES`, any case), when there are no `colors`. */
7
+ palette?: PaletteName | (string & {});
8
+ /** How fast it drifts and twinkles, 0–4; 0 holds it still. Default 1. */
9
+ speed?: number;
10
+ /** How many stars, as a share of the usual, 0–3; 0 for none. Default 1. */
11
+ stars?: number;
12
+ /** How bright the fine glitter is, as a share of the usual, 0–2; 0 for none. Default 1. */
13
+ glitter?: number;
14
+ /** Which sky, 1–999: the same seed draws the same nebula and stars. Default 7. */
15
+ seed?: number;
16
+ /** Run only while near the screen (true, or a CSS length; default `200px`), handled by `mount`. Default false. */
17
+ lazy?: boolean | string;
18
+ }
19
+
20
+ /** The colours without `colors` or `palette`: indigo, cornflower, violet and cyan. */
21
+ export const COLORS: string[];
22
+
23
+ /** The worked-out nebula's size, px (drawn scaled up to cover). */
24
+ export const NEBULA_WIDTH: number;
25
+ export const NEBULA_HEIGHT: number;
26
+
27
+ /** The nebula as places on the colour ramp, 0–1, one a pixel row by row: layered noise clouds cut by ridged dust lanes. Tileable; the same seed gives the same field. */
28
+ export function nebulaField(width: number, height: number, seed?: number): Float32Array;
29
+
30
+ /** The ramp the nebula is painted along (the first colour darkened to near-black, the colours, a pale top), blended in Oklab: `steps` (default 256) RGB triples. Throws a TypeError for a colour that is not hex. */
31
+ export function galaxyRamp(colors: string[], steps?: number): Uint8ClampedArray;
32
+
33
+ /** Paints a nebula field along a ramp: opaque RGBA, a pixel per value. */
34
+ export function nebulaPixels(field: Float32Array, ramp: Uint8ClampedArray): Uint8ClampedArray;
35
+
36
+ /** Starts the galaxy on an element (its first canvas is drawn into). Returns a function that stops it. */
37
+ export function galaxy(el: HTMLElement, config: GalaxyConfig): () => void;