@arraypress/effects-astro 0.2.0 → 0.4.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 +6 -0
- package/COMPONENTS.md +71 -1
- package/README.md +6 -3
- package/package.json +1 -1
- package/src/components/BorderSweep.astro +9 -3
- package/src/components/EffectCanvas.astro +20 -2
- package/src/components/Galaxy.astro +40 -0
- package/src/components/GlitchText.astro +69 -0
- package/src/components/LiveGradient.astro +62 -0
- package/src/components/PixelGlitchText.astro +2 -2
- package/src/index.d.ts +6 -1
- package/src/index.js +4 -1
- package/src/runtime/galaxy.d.ts +37 -0
- package/src/runtime/galaxy.js +311 -0
- package/src/runtime/ink.d.ts +4 -0
- package/src/runtime/ink.js +17 -3
- package/src/runtime/live-gradient.d.ts +15 -0
- package/src/runtime/live-gradient.js +40 -0
- package/src/runtime/mount.js +13 -1
- package/src/runtime/near.d.ts +9 -0
- package/src/runtime/near.js +94 -0
- package/src/runtime/paper.d.ts +2 -0
- package/src/runtime/pixel-glitch.d.ts +8 -1
- package/src/runtime/pixel-glitch.js +71 -12
- package/src/runtime/shader-background.d.ts +2 -0
- package/src/styles/border-sweep.css +28 -1
- package/src/styles/glitch-text.css +169 -0
package/AGENTS.md
CHANGED
|
@@ -13,6 +13,8 @@ Pick by what is asked for:
|
|
|
13
13
|
| An animated, colourful background for a page or hero | `<LightField>` (liquid light), `<FlutedGlass>` (light, gallery-white or dark), `<AsciiRain>` (techy, dark), `<DotGrid>` (quiet, minimal), `<SignalLines>` / `<WaveBars>` (audio) |
|
|
14
14
|
| Ink in water, a lit fluid background, or a hero whose colours a palette switcher changes | `<InkField palette="…">` (Lumetri, Forest, Cadmium, Peacock, Vermillion, Barbie, Uranium, Azure, Ruby, Ultramarine, Saffron, Crimson); `setColors(el, INK_PALETTES[name].colors, INK_PALETTES[name].glint)` recolours it live |
|
|
15
15
|
| Something to play with: ink, smoke, liquid, "interactive" | `<Ink>` over a section, or `<LightField>` (it has the fluid under it), or `<DotGrid>` (click ripples) |
|
|
16
|
+
| A soft gradient that drifts (a card, a hero, a section) — "grainy gradient", "mesh", "aurora" | `<LiveGradient colors={[…]}>` (lazy by default; `liveGradient(colors)` for HTML made in a script) |
|
|
17
|
+
| Smoke or ink on a light page | `<Ink dark colors={[…]}>` (dark dye alone barely shows) |
|
|
16
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) |
|
|
17
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 |
|
|
18
20
|
| 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` |
|
|
@@ -27,12 +29,14 @@ Pick by what is asked for:
|
|
|
27
29
|
| 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) |
|
|
28
30
|
| 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) |
|
|
29
31
|
| 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 |
|
|
32
|
+
| A space, astronomy, night-sky or sci-fi hero: a nebula with stars | `<Galaxy palette="…">` (Canvas 2D, no WebGL; `stars`, `glitter`, `speed`) |
|
|
30
33
|
| A light or texture over a background (a spotlight, film grain) | `<GlowField>`, `<Grain>` (`still` for either to hold) |
|
|
31
34
|
| 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` |
|
|
32
35
|
| A footer wordmark | `<SpotlightText fit>`, `<PixelGlitchText fit>`, `<OutlineWordmark>` |
|
|
33
36
|
| Sections that arrive on scroll, site-wide | `<ScrollReveal />` once in the layout, then reveal.css classes (`fade-in-up`…) on elements |
|
|
34
37
|
| 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) |
|
|
35
38
|
| Text that arrives or moves | `<Reveal>`, `<ScrambleText>`, `<Typewriter>`, `<HighlightSweep>`, `<Marquee>` |
|
|
39
|
+
| 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`) |
|
|
36
40
|
| A small logo mark, a loading or "live" sign | `<PulseMark>`, `.fx-live` from `motion.css` |
|
|
37
41
|
| A hero photo that reacts like water: ripples, a pond, "touch the photo" | `<ImageRipple src="…" alt="…">` (`strength`, `size`, `viscosity`, `fringe`, `fit="contain"`) |
|
|
38
42
|
| 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 |
|
|
@@ -44,6 +48,8 @@ Pick by what is asked for:
|
|
|
44
48
|
|
|
45
49
|
Things that trip people up:
|
|
46
50
|
|
|
51
|
+
- **Many effects on one page** (a wall of cards, a long list): mark them `lazy` (or use `whenNear`). A browser keeps about sixteen WebGL contexts and silently drops the oldest past that.
|
|
52
|
+
|
|
47
53
|
- **`fixed` backgrounds need a transparent `body`.** They sit at `z-index: -1` behind the page: `body { background: transparent }` and paint the page colour on `html`.
|
|
48
54
|
- **Non-fixed effects fill their nearest positioned ancestor.** Give the section `position: relative`, and put the effect before the content.
|
|
49
55
|
- **Headlines over a busy background:** pass `quiet` (`<LightField>`, `<AsciiRain>`) so it dims behind them.
|
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.
|
|
@@ -415,6 +460,8 @@ Ink: ink in water over whatever is behind it. The pointer stirs it and trails in
|
|
|
415
460
|
| `momentum` | `number` | How fast the motion dies away, per second (lower flows on longer). Default 0.25. |
|
|
416
461
|
| `opacity` | `number` | The ink's strongest cover, 0–1. Default 1. |
|
|
417
462
|
| `idle` | `number` | Seconds between drops of ink on their own, so it moves before anyone touches it; 0 for none. They wait while it's off screen or the tab is hidden. Default 0. |
|
|
463
|
+
| `dark` | `boolean` | Ink for a light ground: the colours given are laid dark on light (dark dye alone would barely show). Default false. |
|
|
464
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or a CSS length; default `200px`), handled by `mount`. Default false. |
|
|
418
465
|
| `ignore` | `string` | Clicks on these are theirs, not the ink's. Default: links, buttons, form fields and `[data-effect-ignore]`. |
|
|
419
466
|
| `fixed` | `boolean` | Fill the viewport (position: fixed). Default false. |
|
|
420
467
|
| `class` | `string` | Classes for the element. |
|
|
@@ -528,6 +575,27 @@ LiquidMetal: a logo or a word made of liquid chrome. At rest it is a polished sl
|
|
|
528
575
|
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
529
576
|
| `class` | `string` | Classes for the element. |
|
|
530
577
|
|
|
578
|
+
## `<LiveGradient>`
|
|
579
|
+
|
|
580
|
+
LiveGradient: a gradient that's alive — Paper's mesh gradient in your colours, morphing slowly, with film grain over it. Subtle by default (a sixth of Paper's speed, a gentle swirl), so it sits behind a card, a hero or a section without pulling the eye. The same colours show as a still CSS gradient first (and without WebGL); the live one fades in over it. Lazy by default: it runs only while near the screen, so a page can have many. Fills its nearest positioned ancestor. See src/runtime/live-gradient.js.
|
|
581
|
+
|
|
582
|
+
```astro
|
|
583
|
+
<article class="card" style="position: relative">
|
|
584
|
+
<LiveGradient colors={['#ff5c8a', '#ffb347', '#7b3ff2', '#1a0b2e']} />
|
|
585
|
+
<h3>…</h3>
|
|
586
|
+
</article>
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
| Prop | Type | |
|
|
590
|
+
|---|---|---|
|
|
591
|
+
| `colors` (required) | `string[]` | Two to four colours (hex); the last is the ground the others bloom on. Required. |
|
|
592
|
+
| `speed` | `number` | How fast it morphs (1 is Paper's own speed). Default 0.16. |
|
|
593
|
+
| `distortion` | `number` | How far the colours bend into each other, 0–1. Default 0.7. |
|
|
594
|
+
| `swirl` | `number` | How much they turn, 0–1. Default 0.3. |
|
|
595
|
+
| `grain` | `number` | Film grain over it, 0–1 (0 for none). Default 0.35. |
|
|
596
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or a CSS length). Default true. |
|
|
597
|
+
| `class` | `string` | Classes for the element. |
|
|
598
|
+
|
|
531
599
|
## `<Magnetic>`
|
|
532
600
|
|
|
533
601
|
Magnetic: an element the pointer pulls on. As the pointer comes near it leans towards it, its contents a little further, and springs back when the pointer goes: a call to action that feels like a soft object. See src/runtime/magnetic.js. Still on touch screens and with reduced motion.
|
|
@@ -724,6 +792,7 @@ PaperShader: any of the thirty Paper Shaders (mesh and grain gradients, god rays
|
|
|
724
792
|
| `gradientAngle` | `number` | The made picture's angle, degrees. Default 135. |
|
|
725
793
|
| `speed` | `number` | How fast it moves, over the preset's (0 is still). |
|
|
726
794
|
| `scale` | `number` | Share of the pixel ratio drawn at. Default 1. |
|
|
795
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or a CSS length; default `200px`), handled by `mount`. Default false. |
|
|
727
796
|
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
728
797
|
| `background` | `string` | The colour shown before it draws, and without WebGL 2. Default transparent. |
|
|
729
798
|
| `opacity` | `number` | Its opacity, 0–1, for backdrops under copy. Default 1. |
|
|
@@ -792,7 +861,7 @@ PixelGlitchText: one line of text that breaks into pixels under the pointer and
|
|
|
792
861
|
| `decay` | `number` | Heat kept each frame (0.9 is gone in about half a second). Default 0.9. |
|
|
793
862
|
| `block` | `number` | The pixel block size at full heat, CSS px. Default 22. |
|
|
794
863
|
| `shift` | `number` | How far the hottest rows slip sideways, CSS px. Default 16. |
|
|
795
|
-
| `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). |
|
|
796
865
|
| `as` | `HTMLTag` | The element to render. Default `span`. |
|
|
797
866
|
| `fit` | `boolean` | Size the text to span its parent's width. Default false. |
|
|
798
867
|
| `class` | `string` | Classes for the element. |
|
|
@@ -1001,6 +1070,7 @@ ShaderBackground: six animated shader backgrounds for a hero or section, tinted
|
|
|
1001
1070
|
| `static` | `boolean` | One frame, never the loop: for a shader background that is wallpaper. Default false. |
|
|
1002
1071
|
| `frame` | `number` | With `static`, the moment drawn, in seconds. Default 12. |
|
|
1003
1072
|
| `interactive` | `boolean` | Lean towards the pointer, on devices that hover. Default false. |
|
|
1073
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or a CSS length; default `200px`), handled by `mount`. Default false. |
|
|
1004
1074
|
| `opacity` | `number` | Its opacity, 0–1, to fade it against the section without changing the shader. Default 1. |
|
|
1005
1075
|
| `blend` | `string` | CSS `mix-blend-mode` with what is behind it (`screen`, `lighten`, `plus-lighter`…), for layering over imagery. Default normal. |
|
|
1006
1076
|
| `fade` | `'none' \| 'bottom' \| 'top' \| 'both'` | Fade it out towards an edge, so it melts into the page: 'bottom', 'top', 'both' (top and bottom) or 'none'. Default 'bottom'. |
|
package/README.md
CHANGED
|
@@ -54,6 +54,7 @@ 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 |
|
|
57
58
|
| `<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
59
|
| `<GlowField>` | A light to lay over a background: a bloom, a swaying stage spotlight, a horizon or a wash, breathing gently | CSS |
|
|
59
60
|
| `<Grain>` | Flickering film grain, to dither smooth gradients and make a picture read as film | CSS |
|
|
@@ -87,6 +88,7 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
|
|
|
87
88
|
| `<Reveal>` | Content, or each word, rising into place on scroll | CSS + JS |
|
|
88
89
|
| `<ScrollReveal>` | Once in a layout: anything with a reveal.css class (`fade-in-up`, `zoom-in`, `flip-left`…) arrives on scroll | CSS + JS |
|
|
89
90
|
| `<HighlightSweep>` | A marker underline sweeping in under a word | CSS |
|
|
91
|
+
| `<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
92
|
| `<Marquee>` | An endless strip of names or logos, with a pause button | CSS + JS |
|
|
91
93
|
| `<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
94
|
|
|
@@ -99,7 +101,7 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
|
|
|
99
101
|
| `<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
102
|
| `<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
103
|
| `<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 |
|
|
104
|
+
| `<BorderSweep>` | A light travelling round an outline (or two chasing each other); `inset` for cards that clip | CSS |
|
|
103
105
|
| `<Tilt>` | A card that leans towards the pointer, with a glare | CSS + JS |
|
|
104
106
|
| `<Parallax>` | Layers that drift with the pointer by depth | CSS + JS |
|
|
105
107
|
| `<Magnetic>` | A button the pointer pulls on | CSS + JS |
|
|
@@ -111,7 +113,8 @@ Astro 6 or 7. The runtime underneath (`@arraypress/effects-astro`) works without
|
|
|
111
113
|
| Import | Classes |
|
|
112
114
|
|---|---|
|
|
113
115
|
| `@arraypress/effects-astro/glass.css` | `.glass` (call `glassSheen()` once for the sheen) |
|
|
114
|
-
| `@arraypress/effects-astro/border-sweep.css` | `.sweep-ring`, `--always`, `--fast` |
|
|
116
|
+
| `@arraypress/effects-astro/border-sweep.css` | `.sweep-ring`, `--always`, `--fast`, `--two`, `--inset` |
|
|
117
|
+
| `@arraypress/effects-astro/glitch-text.css` | `.glitch-text` with its copies `.glitch-text-a` and `.glitch-text-b` (markup in the file) |
|
|
115
118
|
| `@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
119
|
| `@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
120
|
|
|
@@ -139,7 +142,7 @@ Every effect that takes `colors` also takes `palette`, one of eighteen named set
|
|
|
139
142
|
|
|
140
143
|
## Changing colours
|
|
141
144
|
|
|
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.
|
|
145
|
+
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>`) 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
146
|
|
|
144
147
|
```js
|
|
145
148
|
import { setColors } from '@arraypress/effects-astro';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arraypress/effects-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
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).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -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>
|
|
@@ -32,10 +32,14 @@ interface Props {
|
|
|
32
32
|
opacity?: number;
|
|
33
33
|
/** CSS `mix-blend-mode` with what is behind it (`screen`, `plus-lighter`…). Default normal. */
|
|
34
34
|
blend?: string;
|
|
35
|
+
/** Run only while near the screen (true, or how near as a CSS length; default `200px`), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
36
|
+
lazy?: boolean | string;
|
|
37
|
+
/** Fade the canvas in once it starts, over the `background`. Default false. */
|
|
38
|
+
fadeIn?: boolean;
|
|
35
39
|
class?: string;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
const { name, config, fixed = false, behind = false, background, pixelated = false, fade = false, opacity, blend, class: className } = Astro.props;
|
|
42
|
+
const { name, config, fixed = false, behind = false, background, pixelated = false, fade = false, opacity, blend, lazy = false, fadeIn = false, class: className } = Astro.props;
|
|
39
43
|
const style = [
|
|
40
44
|
background && `background: ${background}`,
|
|
41
45
|
opacity !== undefined && opacity < 1 && `opacity: ${opacity}`,
|
|
@@ -46,7 +50,8 @@ const style = [
|
|
|
46
50
|
---
|
|
47
51
|
|
|
48
52
|
<div
|
|
49
|
-
class:list={['effect-canvas', { 'is-fixed': fixed, 'is-behind': fixed && behind, 'is-pixelated': pixelated, 'is-faded': fade === true }, typeof fade === 'string' && `is-faded-${fade}`, className]}
|
|
53
|
+
class:list={['effect-canvas', { 'is-fixed': fixed, 'is-behind': fixed && behind, 'is-pixelated': pixelated, 'is-faded': fade === true, 'is-fade-in': fadeIn }, typeof fade === 'string' && `is-faded-${fade}`, className]}
|
|
54
|
+
data-effect-lazy={lazy === false ? undefined : lazy === true ? '' : lazy}
|
|
50
55
|
data-effect-config={JSON.stringify(config)}
|
|
51
56
|
style={style || undefined}
|
|
52
57
|
aria-hidden="true"
|
|
@@ -73,6 +78,19 @@ const style = [
|
|
|
73
78
|
width: 100%;
|
|
74
79
|
height: 100%;
|
|
75
80
|
}
|
|
81
|
+
/* fadeIn: the canvas comes in over the background once the effect starts (mount sets data-effect-live) */
|
|
82
|
+
.effect-canvas.is-fade-in canvas {
|
|
83
|
+
opacity: 0;
|
|
84
|
+
transition: opacity 1.2s ease;
|
|
85
|
+
}
|
|
86
|
+
.effect-canvas.is-fade-in[data-effect-live] canvas {
|
|
87
|
+
opacity: 1;
|
|
88
|
+
}
|
|
89
|
+
@media (prefers-reduced-motion: reduce) {
|
|
90
|
+
.effect-canvas.is-fade-in canvas {
|
|
91
|
+
transition: none;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
76
94
|
.effect-canvas.is-faded {
|
|
77
95
|
-webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
|
|
78
96
|
mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
|
|
@@ -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
|
+
>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* LiveGradient: a gradient that's alive — Paper's mesh gradient in your
|
|
4
|
+
* colours, morphing slowly, with film grain over it. Subtle by default (a
|
|
5
|
+
* sixth of Paper's speed, a gentle swirl), so it sits behind a card, a hero
|
|
6
|
+
* or a section without pulling the eye. The same colours show as a still
|
|
7
|
+
* CSS gradient first (and without WebGL); the live one fades in over it.
|
|
8
|
+
* Lazy by default: it runs only while near the screen, so a page can have
|
|
9
|
+
* many. Fills its nearest positioned ancestor. See src/runtime/live-gradient.js.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <article class="card" style="position: relative">
|
|
13
|
+
* <LiveGradient colors={['#ff5c8a', '#ffb347', '#7b3ff2', '#1a0b2e']} />
|
|
14
|
+
* <h3>…</h3>
|
|
15
|
+
* </article>
|
|
16
|
+
*/
|
|
17
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
18
|
+
import Grain from './Grain.astro';
|
|
19
|
+
import { liveGradient } from '../runtime/live-gradient.js';
|
|
20
|
+
|
|
21
|
+
interface Props {
|
|
22
|
+
/** Two to four colours (hex); the last is the ground the others bloom on. Required. */
|
|
23
|
+
colors: string[];
|
|
24
|
+
/** How fast it morphs (1 is Paper's own speed). Default 0.16. */
|
|
25
|
+
speed?: number;
|
|
26
|
+
/** How far the colours bend into each other, 0–1. Default 0.7. */
|
|
27
|
+
distortion?: number;
|
|
28
|
+
/** How much they turn, 0–1. Default 0.3. */
|
|
29
|
+
swirl?: number;
|
|
30
|
+
/** Film grain over it, 0–1 (0 for none). Default 0.35. */
|
|
31
|
+
grain?: number;
|
|
32
|
+
/** Run only while near the screen (true, or a CSS length). Default true. */
|
|
33
|
+
lazy?: boolean | string;
|
|
34
|
+
class?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const { colors, speed, distortion, swirl, grain = 0.35, lazy = true, class: className } = Astro.props;
|
|
38
|
+
const { config, fallback } = liveGradient(colors, { speed, distortion, swirl });
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
<div class:list={['effect-live-gradient', className]} aria-hidden="true">
|
|
42
|
+
<EffectCanvas name="paper" config={config} background={fallback} lazy={lazy} fadeIn />
|
|
43
|
+
{grain > 0 && <Grain opacity={grain} still />}
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
import { mount } from '../runtime/mount.js';
|
|
48
|
+
import { paperShader } from '../runtime/paper.js';
|
|
49
|
+
|
|
50
|
+
mount('[data-effect-paper]', paperShader);
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<style>
|
|
54
|
+
.effect-live-gradient {
|
|
55
|
+
position: absolute;
|
|
56
|
+
inset: 0;
|
|
57
|
+
z-index: 0;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
border-radius: inherit;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
}
|
|
62
|
+
</style>
|
|
@@ -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;
|
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';
|
|
@@ -93,6 +95,9 @@ export type { Canvas2D } from './runtime/canvas2d.js';
|
|
|
93
95
|
export { loadImage, imageTexture, coverScale, GLSL_COVER } from './runtime/image.js';
|
|
94
96
|
export { boxBlur } from './runtime/blur.js';
|
|
95
97
|
export { paperShader, paperSettings, paperUniforms } from './runtime/paper.js';
|
|
98
|
+
export { whenNear, lazyMargin } from './runtime/near.js';
|
|
99
|
+
export { liveGradient } from './runtime/live-gradient.js';
|
|
100
|
+
export type { LiveGradientOptions } from './runtime/live-gradient.js';
|
|
96
101
|
export type { PaperConfig, PaperShaderName } from './runtime/paper.js';
|
|
97
102
|
export { paperLook, paperLookSettings } from './runtime/paper-look.js';
|
|
98
103
|
export type { PaperLookConfig, PaperLookOptions } from './runtime/paper-look.js';
|
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';
|
|
@@ -65,6 +66,8 @@ export { createCanvas2D, grainPattern, grainOnto } from './runtime/canvas2d.js';
|
|
|
65
66
|
export { loadImage, imageTexture, coverScale, GLSL_COVER } from './runtime/image.js';
|
|
66
67
|
export { boxBlur } from './runtime/blur.js';
|
|
67
68
|
export { paperShader, paperSettings, paperUniforms } from './runtime/paper.js';
|
|
69
|
+
export { whenNear, lazyMargin } from './runtime/near.js';
|
|
70
|
+
export { liveGradient } from './runtime/live-gradient.js';
|
|
68
71
|
export { paperLook, paperLookSettings } from './runtime/paper-look.js';
|
|
69
72
|
export { PAPER_LOOKS } from './runtime/paper-looks.js';
|
|
70
73
|
export { createStage } from './runtime/stage.js';
|
|
@@ -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;
|