@arraypress/effects-astro 0.11.0 → 0.13.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 +2 -2
- package/COMPONENTS.md +175 -10
- package/package.json +1 -1
- package/src/components/DitherGradient.astro +41 -0
- package/src/components/FlutedGlow.astro +39 -0
- package/src/components/GlassDrop.astro +40 -0
- package/src/components/GlassStack.astro +41 -0
- package/src/components/PixelFountain.astro +20 -7
- package/src/components/PixelGlitchText.astro +4 -3
- package/src/components/PixelHorizon.astro +40 -0
- package/src/components/TruchetField.astro +40 -0
- package/src/index.d.ts +19 -1
- package/src/index.js +11 -1
- package/src/runtime/bayer.d.ts +5 -0
- package/src/runtime/bayer.js +48 -0
- package/src/runtime/dither-field.js +7 -33
- package/src/runtime/dither-gradient.d.ts +91 -0
- package/src/runtime/dither-gradient.js +410 -0
- package/src/runtime/fluted-glow.d.ts +79 -0
- package/src/runtime/fluted-glow.js +312 -0
- package/src/runtime/glass-drop-plan.d.ts +59 -0
- package/src/runtime/glass-drop-plan.js +133 -0
- package/src/runtime/glass-drop.d.ts +61 -0
- package/src/runtime/glass-drop.js +331 -0
- package/src/runtime/glass-optics.d.ts +5 -0
- package/src/runtime/glass-optics.js +49 -0
- package/src/runtime/glass-stack.d.ts +65 -0
- package/src/runtime/glass-stack.js +315 -0
- package/src/runtime/pixel-fountain.d.ts +29 -13
- package/src/runtime/pixel-fountain.js +183 -42
- package/src/runtime/pixel-glitch.d.ts +2 -0
- package/src/runtime/pixel-glitch.js +8 -2
- package/src/runtime/pixel-horizon.d.ts +60 -0
- package/src/runtime/pixel-horizon.js +274 -0
- package/src/runtime/slab-runs.d.ts +18 -0
- package/src/runtime/slab-runs.js +112 -0
- package/src/runtime/truchet-field.d.ts +60 -0
- package/src/runtime/truchet-field.js +272 -0
package/AGENTS.md
CHANGED
|
@@ -10,7 +10,7 @@ Pick by what is asked for:
|
|
|
10
10
|
|
|
11
11
|
| Asked for | Use |
|
|
12
12
|
|---|---|
|
|
13
|
-
| An animated, colourful background for a page or hero | `<LightField>` (liquid light), `<FlutedGlass>` (light, gallery-white or dark), `<AsciiRain>` (techy, dark), `<AsciiNoise>` (drifting blobs of monospace type; techy, terminal, studio), `<LightLeak>` (a soft drifting colour field), `<DitherField>` (dithered dots, ripples from a corner), `<CascadeGrid>` (a hex or dot spectrogram), `<FlowField>` (fine trails on a flow; Canvas), `<VoronoiMesh>` (thin nested cell lines), `<KineticGrid>` (a wire grid rain ripples), `<DotGrid>` (quiet, minimal), `<SignalLines>` / `<WaveBars>` (audio) |
|
|
13
|
+
| An animated, colourful background for a page or hero | `<LightField>` (liquid light), `<FlutedGlass>` (light, gallery-white or dark), `<AsciiRain>` (techy, dark), `<AsciiNoise>` (drifting blobs of monospace type; techy, terminal, studio), `<LightLeak>` (a soft drifting colour field), `<DitherField>` (dithered dots, ripples from a corner), `<CascadeGrid>` (a hex or dot spectrogram), `<FlowField>` (fine trails on a flow; Canvas), `<VoronoiMesh>` (thin nested cell lines), `<KineticGrid>` (a wire grid rain ripples), `<DitherGradient>` (a gradient in dithered or halftone dots: wave, band, swirl, pinwheel, steps), `<TruchetField>` (quarter-arc tiles turning a few at a time), `<PixelHorizon>` (a colour breaking into square blocks), `<FlutedGlow>` (a ring or orb of light through reeded glass), `<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
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) |
|
|
@@ -32,7 +32,7 @@ Pick by what is asked for:
|
|
|
32
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
33
|
| A space, astronomy, night-sky or sci-fi hero: a nebula with stars | `<Galaxy palette="…">` (Canvas 2D, no WebGL; `stars`, `glitter`, `speed`) |
|
|
34
34
|
| A light or texture over a background (a spotlight, film grain) | `<GlowField>`, `<Grain>` (`still` for either to hold) |
|
|
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` |
|
|
35
|
+
| The brand's logo as the hero's centrepiece | `<GlassGlyph>`, `<GlassDrop>` (a drop of liquid glass becomes a tile over the logo, or the logo itself, then melts; `loop`), `<GlassStack>` (the logo as stacked tinted glass discs on a lit card), `<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` |
|
|
36
36
|
| A footer wordmark | `<SpotlightText fit>`, `<PixelGlitchText fit>`, `<OutlineWordmark>` |
|
|
37
37
|
| Something retro or 8-bit on a footer: pixels firing out of it, sparks, "insert coin" | `<PixelFountain>` inside the footer (its top edge must not clip: `overflow-x: clip`, not `overflow: hidden`); `source="text"` sheds pixels from a wordmark; `color` or `colors` for the ramp |
|
|
38
38
|
| Sections that arrive on scroll, site-wide | `<ScrollReveal />` once in the layout, then reveal.css classes (`fade-in-up`…) on elements |
|
package/COMPONENTS.md
CHANGED
|
@@ -206,6 +206,23 @@ DitherField: a field of slow noise drawn in square dots, Bayer-dithered at its e
|
|
|
206
206
|
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
207
207
|
| `class` | `string` | Classes for the element. |
|
|
208
208
|
|
|
209
|
+
## `<DitherGradient>`
|
|
210
|
+
|
|
211
|
+
DitherGradient: a soft colour gradient drawn only in dots: a wavy horizon, a glowing band, a swirl, a pinwheel or stepped columns, square dots an ordered dither thins out or round halftone dots that shrink. See src/runtime/dither-gradient.js.
|
|
212
|
+
|
|
213
|
+
```astro
|
|
214
|
+
<section class="hero" style="position: relative; background: #0b0b0b">
|
|
215
|
+
<DitherGradient background="#081226" colors={['#5a0f4a', '#ff1f8f']} shape="wave" quiet={{ radius: 0.5, depth: 1 }} />
|
|
216
|
+
<h1>…</h1>
|
|
217
|
+
</section>
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
| Prop | Type | |
|
|
221
|
+
|---|---|---|
|
|
222
|
+
| `fixed` | `boolean` | Fill the viewport (position: fixed). Default false. |
|
|
223
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
224
|
+
| `class` | `string` | Classes for the element. |
|
|
225
|
+
|
|
209
226
|
## `<DotGrid>`
|
|
210
227
|
|
|
211
228
|
DotGrid: a sea of dots you can drop stones into. A slow current moves through a fixed grid of dots, a swell sits under the pointer, and a click sends a widening ripple across, lifting and pushing the dots. See src/runtime/dot-grid.js.
|
|
@@ -326,6 +343,23 @@ FlutedGlass: a pane of slanted fluted glass over soft blooms of colour, the main
|
|
|
326
343
|
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
327
344
|
| `class` | `string` | Classes for the element. |
|
|
328
345
|
|
|
346
|
+
## `<FlutedGlow>`
|
|
347
|
+
|
|
348
|
+
FlutedGlow: a soft ring, orb or rising light seen through upright reeded glass, breathing slowly, made to sit behind copy (no pointer). See src/runtime/fluted-glow.js.
|
|
349
|
+
|
|
350
|
+
```astro
|
|
351
|
+
<section class="hero" style="position: relative; background: #0b0b0b">
|
|
352
|
+
<FlutedGlow colors={['#7a1d00', '#ff7a00', '#ffd27a']} shape="ring" />
|
|
353
|
+
<h1>…</h1>
|
|
354
|
+
</section>
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
| Prop | Type | |
|
|
358
|
+
|---|---|---|
|
|
359
|
+
| `fixed` | `boolean` | Fill the viewport (position: fixed). Default false. |
|
|
360
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
361
|
+
| `class` | `string` | Classes for the element. |
|
|
362
|
+
|
|
329
363
|
## `<Galaxy>`
|
|
330
364
|
|
|
331
365
|
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.
|
|
@@ -375,6 +409,51 @@ Glass: a liquid glass panel, with a rim that catches the light and a sheen that
|
|
|
375
409
|
| `specular` | `number` | With `refract`, how bright the highlight along the rim is, 0–1. Default 0.7. |
|
|
376
410
|
| `class` | `string` | Classes for the element. |
|
|
377
411
|
|
|
412
|
+
## `<GlassDrop>`
|
|
413
|
+
|
|
414
|
+
GlassDrop: a logo arriving as liquid glass. A drop forms, lands with rings running out, and spreads into a glass tile with the logo rising under it (or into the logo's own shape, `form="mark"`); it holds, then melts away and leaves the logo flat on the ground. Once, or on a loop. See src/runtime/glass-drop.js.
|
|
415
|
+
|
|
416
|
+
```astro
|
|
417
|
+
<section class="hero" style="position: relative">
|
|
418
|
+
<GlassDrop src="/logo.svg" loop />
|
|
419
|
+
<h1>…</h1>
|
|
420
|
+
</section>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
| Prop | Type | |
|
|
424
|
+
|---|---|---|
|
|
425
|
+
| `src` | `string` | An image (an SVG logo) to make the glass of. |
|
|
426
|
+
| `text` | `string` | A character or word instead of an image. |
|
|
427
|
+
| `font` | `string` | Its CSS font, without the size. Default: the page's, bold. |
|
|
428
|
+
| `area` | `{ x: number; y: number; width: number; height: number }` | Where the glass sits, each 0–1 from the top left. Default all of the element. |
|
|
429
|
+
| `form` | `'tile' \| 'mark'` | What the drop becomes: `tile`, a glass tile with the logo under it, or `mark`, the logo's own shape in glass. Default `tile`. |
|
|
430
|
+
| `size` | `number` | The tile's edge, a share of the area's shorter side, 0.2–1. Default 0.7. |
|
|
431
|
+
| `markScale` | `number` | The logo's size under the glass, a share of the tile, 0.2–1. Default 0.62. |
|
|
432
|
+
| `restScale` | `number` | The logo's size once the glass has melted, times its size under the glass, 0.5–2. Default 1. |
|
|
433
|
+
| `radius` | `number` | The tile's corner radius, a share of its edge, 0–0.5. Default 0.24. |
|
|
434
|
+
| `background` | `string` | The ground. Default `#000000`. |
|
|
435
|
+
| `color` | `string` | The logo's colour. Default `#ffffff`. |
|
|
436
|
+
| `plate` | `string` | The tile's surface under the logo. Default `#0a1020`. |
|
|
437
|
+
| `light` | `string` | The studio light the glass mirrors. Default `#ffffff`. |
|
|
438
|
+
| `depth` | `number` | How hard the glass bends what is under it, 0–2. Default 1. |
|
|
439
|
+
| `dispersion` | `number` | How far the colours part at the rim, 0–2; 0 for none. Default 1. |
|
|
440
|
+
| `bevel` | `number` | How wide the rounded rim is, a share of the tile (or the logo), 0.02–0.3. Default 0.1. |
|
|
441
|
+
| `highlights` | `number` | The lip and the studio's reflections, 0–2. Default 1. |
|
|
442
|
+
| `caustics` | `number` | Light focused at the glass's edge and onto the ground, 0–2. Default 1. |
|
|
443
|
+
| `bloom` | `number` | A soft glow round the glass, 0–1. Default 0.5. |
|
|
444
|
+
| `ripples` | `number` | The rings the drop sends across the ground, 0–2; 0 for none. Default 1. |
|
|
445
|
+
| `tint` | `number` | With `form: 'mark'`: how strongly the glass takes the logo's colour, 0–1. Default 0.88. |
|
|
446
|
+
| `lightAngle` | `number` | Where the light comes from, degrees, 0–360 (0 right, 90 top). Default 125. |
|
|
447
|
+
| `speed` | `number` | How fast the sequence plays, 0.25–3. Default 1. |
|
|
448
|
+
| `delay` | `number` | Seconds to wait before it starts, 0–10. Default 0. |
|
|
449
|
+
| `hold` | `number` | Seconds the glass holds before it melts, 0–10. Default 2.4. |
|
|
450
|
+
| `loop` | `boolean` | Play it again after a rest; each round starts from the resting logo, which fades as the new drop forms. Default false. |
|
|
451
|
+
| `loopDelay` | `number` | With `loop`: seconds the logo rests before the next drop, 0–10. Default 1.6. |
|
|
452
|
+
| `rest` | `'flat' \| 'glass'` | How it ends: `flat`, the glass melted and the logo left on the ground, or `glass`, the glass held. Default `flat`. |
|
|
453
|
+
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
454
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
455
|
+
| `class` | `string` | Classes for the element. |
|
|
456
|
+
|
|
378
457
|
## `<GlassGlyph>`
|
|
379
458
|
|
|
380
459
|
GlassGlyph: a character or a logo as a thick slab of dark, smoked glass, lit from behind by beams of one coloured light. The light barely shows on the near-black ground; the glass catches it and glows with it through its body and bevels. The slab turns slowly on its own and leans away from the pointer; the light stays put. See src/runtime/glass-glyph.js.
|
|
@@ -412,6 +491,50 @@ GlassGlyph: a character or a logo as a thick slab of dark, smoked glass, lit fro
|
|
|
412
491
|
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
413
492
|
| `class` | `string` | Classes for the element. |
|
|
414
493
|
|
|
494
|
+
## `<GlassStack>`
|
|
495
|
+
|
|
496
|
+
GlassStack: a logo as a stack of tinted glass discs in front of a lit card, seen a little from below. The logo is cut into slices and every stretch of it in a slice becomes a disc; the tints run from the top slice to the bottom. The discs grow from the bottom up when it first shows, then the stack leans gently on its own and toward the pointer. See src/runtime/glass-stack.js.
|
|
497
|
+
|
|
498
|
+
```astro
|
|
499
|
+
<section class="hero" style="position: relative">
|
|
500
|
+
<GlassStack src="/logo.svg" background="#0b0b0b" colors={['#f4ffd0', '#c8ff00', '#0e8c7e']} />
|
|
501
|
+
<h1>…</h1>
|
|
502
|
+
</section>
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
| Prop | Type | |
|
|
506
|
+
|---|---|---|
|
|
507
|
+
| `src` | `string` | An image (an SVG logo) to make the stack of. |
|
|
508
|
+
| `text` | `string` | A character or word instead of an image. |
|
|
509
|
+
| `font` | `string` | Its CSS font, without the size. Default: the page's, bold. |
|
|
510
|
+
| `area` | `{ x: number; y: number; width: number; height: number }` | Where the stack sits, each 0–1 from the top left. Default all of the element. |
|
|
511
|
+
| `logoScale` | `number` | The logo's size, a share of the area's shorter side, 0.2–1. Default 0.73. |
|
|
512
|
+
| `colors` | `string[]` | The glass's tints from the top slice to the bottom, 2–6 colours. Default aqua to deep blue. |
|
|
513
|
+
| `background` | `string` | The ground. Default `#ffffff`. |
|
|
514
|
+
| `light` | `string` | The lit card behind the stack, and the studio the glass mirrors. Default `#ffffff`. |
|
|
515
|
+
| `slabs` | `number` | How many slices the logo is cut into, 4–64. Default 22. |
|
|
516
|
+
| `phase` | `number` | Where in its slice each disc samples the logo, 0 the top to 1 the bottom. Default 0.5. |
|
|
517
|
+
| `band` | `number` | How much of its slice each disc samples, 0 a line to 1 all of it; more keeps small parts. Default 0.35. |
|
|
518
|
+
| `depth` | `number` | How open each disc is from below (the camera's height), a share of the slice, 0.05–1.4. Default 0.55. |
|
|
519
|
+
| `thickness` | `number` | How much of each disc's front edge shows, a share of the slice, 0–1. Default 0.35. |
|
|
520
|
+
| `ior` | `number` | The glass's refractive index: how hard its rims bend the card, 1–2. Default 1.45. |
|
|
521
|
+
| `reflectivity` | `number` | How strongly the glass mirrors the studio, 0–1. Default 0.3. |
|
|
522
|
+
| `density` | `number` | How deeply the glass is tinted, 0–3. Default 0.9. |
|
|
523
|
+
| `opacity` | `number` | How much the discs hide the discs behind them, 0–1. Default 0.92. |
|
|
524
|
+
| `exposure` | `number` | The card's brightness, 0–2. Default 1.1. |
|
|
525
|
+
| `ambient` | `number` | How far the card's light spills onto the ground, 0–1. Default 0.05. |
|
|
526
|
+
| `cardSize` | `number` | The card's size, times the logo's box, 0 for none to 3. Default 1.15. |
|
|
527
|
+
| `lightAngle` | `number` | Where the light comes from, degrees, 0–360 (0 right, 90 top). Default 115. |
|
|
528
|
+
| `tilt` | `number` | How far the stack leans toward the pointer, 0–2; 0 for not at all. Default 1. |
|
|
529
|
+
| `sway` | `number` | How far it leans on its own, slowly, 0–2; 0 holds it still. Default 0.5. |
|
|
530
|
+
| `intro` | `boolean` | Grow the discs from the bottom up when it first shows. Default true. |
|
|
531
|
+
| `introDuration` | `number` | Seconds until the top disc has grown, 0.2–6. Default 1.6. |
|
|
532
|
+
| `delay` | `number` | Seconds before the intro starts, 0–10. Default 0. |
|
|
533
|
+
| `speed` | `number` | How fast the intro plays, 0.25–3. Default 1. |
|
|
534
|
+
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
535
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
536
|
+
| `class` | `string` | Classes for the element. |
|
|
537
|
+
|
|
415
538
|
## `<GlitchText>`
|
|
416
539
|
|
|
417
540
|
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.
|
|
@@ -1009,24 +1132,31 @@ PixelFountain: retro 8-bit sparks. Chunky square pixels fire up out of the host'
|
|
|
1009
1132
|
<PixelFountain cell={8} />
|
|
1010
1133
|
…
|
|
1011
1134
|
</footer>
|
|
1135
|
+
@example
|
|
1136
|
+
<div class="wordmark-wrap" style="position: relative; color: #0b0b0b">
|
|
1137
|
+
<PixelFountain source="pointer" cell={10} />
|
|
1138
|
+
<FitText as="div">Arcadia</FitText>
|
|
1139
|
+
</div>
|
|
1012
1140
|
```
|
|
1013
1141
|
|
|
1014
1142
|
| Prop | Type | |
|
|
1015
1143
|
|---|---|---|
|
|
1016
|
-
| `color` | `string` | The pixels' colour when they fire; the darker steps they fade through are made from it. Default `#c8ff00
|
|
1017
|
-
| `colors` | `string[]` | The steps a pixel fades through, first to last (overrides `color
|
|
1144
|
+
| `color` | `string` | The pixels' colour when they fire; the darker steps they fade through are made from it. With `source="pointer"`, the one ink every block is drawn in. Default `#c8ff00` (from the pointer, the text's colour, `currentColor`). |
|
|
1145
|
+
| `colors` | `string[]` | The steps a pixel fades through, first to last (overrides `color`; from the pointer, only the first is used). Default made from `color`. |
|
|
1018
1146
|
| `palette` | `string` | A shared palette by name, its colours as the steps, when there are no `colors`. Default none. |
|
|
1019
1147
|
| `cell` | `number` | A pixel's size, CSS px (a power-up's biggest blocks are two). Default 8. |
|
|
1020
|
-
| `rise` | `number` | How far above the edge the pixels can fly, CSS px. Default 240. |
|
|
1021
|
-
| `rate` | `number` | Pixels a second trickling up on their own, per 1,000 CSS px of edge; 0 for none. Default 14. |
|
|
1022
|
-
| `burst` | `number` | Pixels a click or tap fires. Default 40. |
|
|
1148
|
+
| `rise` | `number` | How far above the edge the pixels can fly, CSS px (from the pointer: how far above the host the canvas reaches). Default 240 (160 from the pointer). |
|
|
1149
|
+
| `rate` | `number` | Pixels a second trickling up on their own, per 1,000 CSS px of edge; 0 for none (always none from the pointer). Default 14. |
|
|
1150
|
+
| `burst` | `number` | Pixels a click or tap fires. Default 40 (24 from the pointer). |
|
|
1151
|
+
| `trail` | `number` | From the pointer: blocks fired for every 100 CSS px it moves, at most 12 a move. Default 10. |
|
|
1152
|
+
| `press` | `boolean` | Whether a mouse click fires a burst (a tap always does). Default true (false from the pointer). |
|
|
1023
1153
|
| `gravity` | `number` | How hard they are pulled back, 0–2. Default 1. |
|
|
1024
1154
|
| `spread` | `number` | How widely they fan out, 0–1. Default 0.5. |
|
|
1025
1155
|
| `drift` | `number` | How much a wind pushes them sideways, 0–1. Default 0.3. |
|
|
1026
|
-
| `life` | `number` | The longest a pixel lives, seconds. Default 1.4. |
|
|
1027
|
-
| `split` | `number` | The chance a pixel splits into smaller ones rather than shrinking, 0–1. Default 0.4. |
|
|
1028
|
-
| `flicker` | `number` | The chance a pixel flickers out on and off before it goes, 0–1. Default 0.35. |
|
|
1029
|
-
| `source` | `'edge' \| 'text'` | Fire from the host's top edge
|
|
1156
|
+
| `life` | `number` | The longest a pixel lives, seconds. Default 1.4 (0.9 from the pointer). |
|
|
1157
|
+
| `split` | `number` | The chance a pixel splits into smaller ones rather than shrinking, 0–1. Default 0.4 (0.2 from the pointer). |
|
|
1158
|
+
| `flicker` | `number` | The chance a pixel flickers out on and off before it goes, 0–1. Default 0.35 (0.5 from the pointer). |
|
|
1159
|
+
| `source` | `'edge' \| 'text' \| 'pointer'` | Fire from the host's top edge; from the filled pixels of its text; or only from the pointer, where it moves over the host (a block-dust trail in one ink, nothing on its own). Default `edge`. |
|
|
1030
1160
|
| `host` | `string` | A selector for the element the pixels fire from and the pointer is followed over: the nearest ancestor that matches, else the first on the page. Default the element's positioned parent. |
|
|
1031
1161
|
| `seed` | `number` | Seeds the randomness. Default 1. |
|
|
1032
1162
|
| `zIndex` | `number` | The canvas's `z-index`, over what is above the host. Default none (auto). |
|
|
@@ -1035,7 +1165,7 @@ PixelFountain: retro 8-bit sparks. Chunky square pixels fire up out of the host'
|
|
|
1035
1165
|
|
|
1036
1166
|
## `<PixelGlitchText>`
|
|
1037
1167
|
|
|
1038
|
-
PixelGlitchText: one line of text that breaks into pixels under the pointer and knits back together behind it. With `stroke`, a hollow outline at rest that the pixels fill in; `tear="row"` tears whole rows, and `ghost` lays a coloured copy behind the blocks. See src/runtime/pixel-glitch.js.
|
|
1168
|
+
PixelGlitchText: one line of text that breaks into pixels under the pointer and knits back together behind it. With `stroke`, a hollow outline at rest that the pixels fill in; `tear="row"` tears whole rows, and `ghost` lays a coloured copy behind the blocks; `glitch={false}` keeps only the drawing at rest (a still outlined wordmark). See src/runtime/pixel-glitch.js.
|
|
1039
1169
|
|
|
1040
1170
|
```astro
|
|
1041
1171
|
<footer>
|
|
@@ -1053,10 +1183,28 @@ PixelGlitchText: one line of text that breaks into pixels under the pointer and
|
|
|
1053
1183
|
| `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). |
|
|
1054
1184
|
| `tear` | `'cell' \| 'row'` | What slips: `cell`, each hot cell on its own; `row`, a whole row at once, now and then, by its hottest cell (up to half of `shift` either way). Default `cell`. |
|
|
1055
1185
|
| `ghost` | `string` | A colour for a copy of the blocks, nudged 3px right behind them (an accent under the break). Default none. |
|
|
1186
|
+
| `glitch` | `boolean` | Break into pixels under the pointer. False only draws the text at rest (with `stroke`, its merged outline), everywhere, with reduced motion and on touch screens too: the same look, the pointer left to something else. Default true. |
|
|
1056
1187
|
| `as` | `HTMLTag` | The element to render. Default `span`. |
|
|
1057
1188
|
| `fit` | `boolean` | Size the text to span its parent's width. Default false. |
|
|
1058
1189
|
| `class` | `string` | Classes for the element. |
|
|
1059
1190
|
|
|
1191
|
+
## `<PixelHorizon>`
|
|
1192
|
+
|
|
1193
|
+
PixelHorizon: a flat colour filling one side and breaking up into square blocks toward the other, blocks winking on and off along a slowly swaying frontier. See src/runtime/pixel-horizon.js.
|
|
1194
|
+
|
|
1195
|
+
```astro
|
|
1196
|
+
<section class="hero" style="position: relative; background: #0b0b0b">
|
|
1197
|
+
<PixelHorizon background="#0b0b0b" colors={['#1aff00']} side="bottom" quiet={{ radius: 0.42, depth: 1 }} />
|
|
1198
|
+
<h1>…</h1>
|
|
1199
|
+
</section>
|
|
1200
|
+
```
|
|
1201
|
+
|
|
1202
|
+
| Prop | Type | |
|
|
1203
|
+
|---|---|---|
|
|
1204
|
+
| `fixed` | `boolean` | Fill the viewport (position: fixed). Default false. |
|
|
1205
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
1206
|
+
| `class` | `string` | Classes for the element. |
|
|
1207
|
+
|
|
1060
1208
|
## `<PointCloud>`
|
|
1061
1209
|
|
|
1062
1210
|
PointCloud: a word drawn as a matrix of bright dots among rippling sheets of point cloud, the scene tilting towards the pointer. With `trackers`, boxes lock onto the word like a detector's debug view. See src/runtime/point-cloud.js.
|
|
@@ -1420,6 +1568,23 @@ Topography: a survey map that never sits still. The contour lines of a slowly dr
|
|
|
1420
1568
|
| `fixed` | `boolean` | Fill the viewport, behind the page (position: fixed, z-index -1). Default false. |
|
|
1421
1569
|
| `class` | `string` | Classes for the element. |
|
|
1422
1570
|
|
|
1571
|
+
## `<TruchetField>`
|
|
1572
|
+
|
|
1573
|
+
TruchetField: a field of Truchet tiles, quarter arcs that join into loops and S-bends, a few tiles turning at a time, bright patches drifting through. See src/runtime/truchet-field.js.
|
|
1574
|
+
|
|
1575
|
+
```astro
|
|
1576
|
+
<section class="hero" style="position: relative; background: #0b0b0b">
|
|
1577
|
+
<TruchetField background="#0b0b0b" colors={['#3a3a3a', '#f4f3ef']} quiet={{ radius: 0.5, depth: 0.9 }} />
|
|
1578
|
+
<h1>…</h1>
|
|
1579
|
+
</section>
|
|
1580
|
+
```
|
|
1581
|
+
|
|
1582
|
+
| Prop | Type | |
|
|
1583
|
+
|---|---|---|
|
|
1584
|
+
| `fixed` | `boolean` | Fill the viewport (position: fixed). Default false. |
|
|
1585
|
+
| `lazy` | `boolean \| string` | Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. |
|
|
1586
|
+
| `class` | `string` | Classes for the element. |
|
|
1587
|
+
|
|
1423
1588
|
## `<Typewriter>`
|
|
1424
1589
|
|
|
1425
1590
|
Typewriter: types phrases one after another behind a blinking caret, deleting each before the next. "Sell beats / sample packs / presets." Screen readers get the phrases as a list once, not a stream of letters; with reduced motion the first phrase simply shows. See src/runtime/text-motion.js.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arraypress/effects-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.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 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",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* DitherGradient: a soft colour gradient drawn only in dots: a wavy
|
|
4
|
+
* horizon, a glowing band, a swirl, a pinwheel or stepped columns, square
|
|
5
|
+
* dots an ordered dither thins out or round halftone dots that shrink. See
|
|
6
|
+
* src/runtime/dither-gradient.js.
|
|
7
|
+
*
|
|
8
|
+
* Fills its nearest positioned ancestor, or the viewport with `fixed`.
|
|
9
|
+
* Clear where there is nothing drawn, so it lays over any ground; with a
|
|
10
|
+
* `background`, the element shows a CSS still until the shader starts and
|
|
11
|
+
* without WebGL.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <section class="hero" style="position: relative; background: #0b0b0b">
|
|
15
|
+
* <DitherGradient background="#081226" colors={['#5a0f4a', '#ff1f8f']} shape="wave" quiet={{ radius: 0.5, depth: 1 }} />
|
|
16
|
+
* <h1>…</h1>
|
|
17
|
+
* </section>
|
|
18
|
+
*/
|
|
19
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
20
|
+
import { gradientStill, type DitherGradientConfig } from '../runtime/dither-gradient.js';
|
|
21
|
+
|
|
22
|
+
interface Props extends DitherGradientConfig {
|
|
23
|
+
/** Fill the viewport (position: fixed). Default false. */
|
|
24
|
+
fixed?: boolean;
|
|
25
|
+
/** Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
26
|
+
lazy?: boolean | string;
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { fixed = false, lazy = false, class: className, ...config } = Astro.props;
|
|
31
|
+
const still = config.background ? gradientStill(config) : undefined;
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<EffectCanvas name="dither-gradient" config={config} fixed={fixed} lazy={lazy} background={still} class={className} />
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import { mount } from '../runtime/mount.js';
|
|
38
|
+
import { ditherGradient } from '../runtime/dither-gradient.js';
|
|
39
|
+
|
|
40
|
+
mount('[data-effect-dither-gradient]', ditherGradient);
|
|
41
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* FlutedGlow: a soft ring, orb or rising light seen through upright reeded
|
|
4
|
+
* glass, breathing slowly, made to sit behind copy (no pointer). See
|
|
5
|
+
* src/runtime/fluted-glow.js.
|
|
6
|
+
*
|
|
7
|
+
* Fills its nearest positioned ancestor, or the viewport with `fixed`.
|
|
8
|
+
* Opaque: it paints its `background` (default near-black) everywhere; the
|
|
9
|
+
* element shows a CSS still of it until the shader starts and without WebGL.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <section class="hero" style="position: relative; background: #0b0b0b">
|
|
13
|
+
* <FlutedGlow colors={['#7a1d00', '#ff7a00', '#ffd27a']} shape="ring" />
|
|
14
|
+
* <h1>…</h1>
|
|
15
|
+
* </section>
|
|
16
|
+
*/
|
|
17
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
18
|
+
import { glowStill, type FlutedGlowConfig } from '../runtime/fluted-glow.js';
|
|
19
|
+
|
|
20
|
+
interface Props extends FlutedGlowConfig {
|
|
21
|
+
/** Fill the viewport (position: fixed). Default false. */
|
|
22
|
+
fixed?: boolean;
|
|
23
|
+
/** Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
24
|
+
lazy?: boolean | string;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { fixed = false, lazy = false, class: className, ...config } = Astro.props;
|
|
29
|
+
const still = glowStill(config);
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
<EffectCanvas name="fluted-glow" config={config} fixed={fixed} lazy={lazy} background={still} class={className} />
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import { mount } from '../runtime/mount.js';
|
|
36
|
+
import { flutedGlow } from '../runtime/fluted-glow.js';
|
|
37
|
+
|
|
38
|
+
mount('[data-effect-fluted-glow]', flutedGlow);
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* GlassDrop: a logo arriving as liquid glass. A drop forms, lands with
|
|
4
|
+
* rings running out, and spreads into a glass tile with the logo rising
|
|
5
|
+
* under it (or into the logo's own shape, `form="mark"`); it holds, then
|
|
6
|
+
* melts away and leaves the logo flat on the ground. Once, or on a loop.
|
|
7
|
+
* See src/runtime/glass-drop.js.
|
|
8
|
+
*
|
|
9
|
+
* Opaque: it is the whole background of what it fills (its nearest
|
|
10
|
+
* positioned ancestor, or the viewport with `fixed`). Without WebGL the
|
|
11
|
+
* `background` colour shows; with reduced motion, the final frame.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <section class="hero" style="position: relative">
|
|
15
|
+
* <GlassDrop src="/logo.svg" loop />
|
|
16
|
+
* <h1>…</h1>
|
|
17
|
+
* </section>
|
|
18
|
+
*/
|
|
19
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
20
|
+
import type { GlassDropConfig } from '../runtime/glass-drop.js';
|
|
21
|
+
|
|
22
|
+
interface Props extends GlassDropConfig {
|
|
23
|
+
/** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
|
|
24
|
+
fixed?: boolean;
|
|
25
|
+
/** Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
26
|
+
lazy?: boolean | string;
|
|
27
|
+
class?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const { fixed = false, lazy = false, class: className, ...config } = Astro.props;
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<EffectCanvas name="glass-drop" config={config} fixed={fixed} lazy={lazy} class={className} behind background={config.background ?? '#000000'} />
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
import { mount } from '../runtime/mount.js';
|
|
37
|
+
import { glassDrop } from '../runtime/glass-drop.js';
|
|
38
|
+
|
|
39
|
+
mount('[data-effect-glass-drop]', glassDrop);
|
|
40
|
+
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* GlassStack: a logo as a stack of tinted glass discs in front of a lit
|
|
4
|
+
* card, seen a little from below. The logo is cut into slices and every
|
|
5
|
+
* stretch of it in a slice becomes a disc; the tints run from the top slice
|
|
6
|
+
* to the bottom. The discs grow from the bottom up when it first shows,
|
|
7
|
+
* then the stack leans gently on its own and toward the pointer.
|
|
8
|
+
* See src/runtime/glass-stack.js.
|
|
9
|
+
*
|
|
10
|
+
* Opaque: it is the whole background of what it fills (its nearest
|
|
11
|
+
* positioned ancestor, or the viewport with `fixed`). Without WebGL the
|
|
12
|
+
* `background` colour shows; with reduced motion, every disc grown.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <section class="hero" style="position: relative">
|
|
16
|
+
* <GlassStack src="/logo.svg" background="#0b0b0b" colors={['#f4ffd0', '#c8ff00', '#0e8c7e']} />
|
|
17
|
+
* <h1>…</h1>
|
|
18
|
+
* </section>
|
|
19
|
+
*/
|
|
20
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
21
|
+
import type { GlassStackConfig } from '../runtime/glass-stack.js';
|
|
22
|
+
|
|
23
|
+
interface Props extends GlassStackConfig {
|
|
24
|
+
/** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
|
|
25
|
+
fixed?: boolean;
|
|
26
|
+
/** Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
27
|
+
lazy?: boolean | string;
|
|
28
|
+
class?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { fixed = false, lazy = false, class: className, ...config } = Astro.props;
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
<EffectCanvas name="glass-stack" config={config} fixed={fixed} lazy={lazy} class={className} behind background={config.background ?? '#ffffff'} />
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import { mount } from '../runtime/mount.js';
|
|
38
|
+
import { glassStack } from '../runtime/glass-stack.js';
|
|
39
|
+
|
|
40
|
+
mount('[data-effect-glass-stack]', glassStack);
|
|
41
|
+
</script>
|
|
@@ -9,19 +9,31 @@
|
|
|
9
9
|
* fires a stream, a click or tap a power-up. See
|
|
10
10
|
* src/runtime/pixel-fountain.js.
|
|
11
11
|
*
|
|
12
|
+
* With `source="pointer"`, blocks fire only where the pointer is, as it
|
|
13
|
+
* moves over the host: a block-dust trail off the cursor, in one solid ink
|
|
14
|
+
* (the text's colour, or `color`), that pops up, arcs and breaks down within
|
|
15
|
+
* about a second. Nothing on its own, nothing while the pointer rests; a
|
|
16
|
+
* tap fires a burst where it lands (a click too with `press`).
|
|
17
|
+
*
|
|
12
18
|
* Put it inside the host (its nearest positioned ancestor): the canvas sits
|
|
13
19
|
* above the host's top edge, `rise` px tall (over the host and above it
|
|
14
|
-
* with `source="text"`), so the host must not clip its top (no
|
|
20
|
+
* with `source="text"` or `"pointer"`), so the host must not clip its top (no
|
|
15
21
|
* `overflow: hidden`; `overflow-x: clip` is fine). Or put it in a
|
|
16
22
|
* zero-height positioned strip on the host's top edge and name the host
|
|
17
23
|
* with `host`. The canvas takes no pointer events; the host's are read.
|
|
18
|
-
* With reduced motion, a still scatter of pixels.
|
|
24
|
+
* With reduced motion, a still scatter of pixels (nothing from the pointer).
|
|
19
25
|
*
|
|
20
26
|
* @example
|
|
21
27
|
* <footer class="site-footer" style="position: relative">
|
|
22
28
|
* <PixelFountain cell={8} />
|
|
23
29
|
* …
|
|
24
30
|
* </footer>
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* <div class="wordmark-wrap" style="position: relative; color: #0b0b0b">
|
|
34
|
+
* <PixelFountain source="pointer" cell={10} />
|
|
35
|
+
* <FitText as="div">Arcadia</FitText>
|
|
36
|
+
* </div>
|
|
25
37
|
*/
|
|
26
38
|
import EffectCanvas from './EffectCanvas.astro';
|
|
27
39
|
import type { PixelFountainConfig } from '../runtime/pixel-fountain.js';
|
|
@@ -35,9 +47,10 @@ interface Props extends PixelFountainConfig {
|
|
|
35
47
|
}
|
|
36
48
|
|
|
37
49
|
const { zIndex, lazy = false, class: className, ...config } = Astro.props;
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
50
|
+
const pointer = config.source === 'pointer';
|
|
51
|
+
const rise = config.rise ?? (pointer ? 160 : 240);
|
|
52
|
+
const over = config.source === 'text' || pointer;
|
|
53
|
+
const classes = ['effect-pixel-fountain', over && 'is-over', className].filter(Boolean).join(' ');
|
|
41
54
|
---
|
|
42
55
|
|
|
43
56
|
<EffectCanvas
|
|
@@ -62,8 +75,8 @@ const classes = ['effect-pixel-fountain', text && 'is-text', className].filter(B
|
|
|
62
75
|
inset: auto 0 100% 0;
|
|
63
76
|
height: var(--fountain-rise);
|
|
64
77
|
}
|
|
65
|
-
/* From the text: over the host and the space above it. */
|
|
66
|
-
:global(.effect-canvas.effect-pixel-fountain.is-
|
|
78
|
+
/* From the text or the pointer: over the host and the space above it. */
|
|
79
|
+
:global(.effect-canvas.effect-pixel-fountain.is-over[data-effect-pixel-fountain]) {
|
|
67
80
|
inset: auto 0 0 0;
|
|
68
81
|
height: calc(100% + var(--fountain-rise));
|
|
69
82
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* PixelGlitchText: one line of text that breaks into pixels under the
|
|
4
4
|
* pointer and knits back together behind it. With `stroke`, a hollow
|
|
5
5
|
* outline at rest that the pixels fill in; `tear="row"` tears whole rows,
|
|
6
|
-
* and `ghost` lays a coloured copy behind the blocks
|
|
6
|
+
* and `ghost` lays a coloured copy behind the blocks; `glitch={false}`
|
|
7
|
+
* keeps only the drawing at rest (a still outlined wordmark). See
|
|
7
8
|
* src/runtime/pixel-glitch.js.
|
|
8
9
|
*
|
|
9
10
|
* With `fit`, the text is sized to span its parent's width (a footer
|
|
@@ -27,13 +28,13 @@ interface Props extends PixelGlitchConfig {
|
|
|
27
28
|
[attribute: string]: unknown;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
const { as: Tag = 'span', fit = false, cell, reach, decay, block, shift, stroke, tear, ghost, class: className, style: given, ...attributes } = Astro.props;
|
|
31
|
+
const { as: Tag = 'span', fit = false, cell, reach, decay, block, shift, stroke, tear, ghost, glitch, class: className, style: given, ...attributes } = Astro.props;
|
|
31
32
|
---
|
|
32
33
|
|
|
33
34
|
<Tag
|
|
34
35
|
class:list={['effect-pixel-glitch', { 'is-outline': (stroke ?? 0) > 0 }, className]}
|
|
35
36
|
data-effect-pixel-glitch
|
|
36
|
-
data-effect-config={JSON.stringify({ cell, reach, decay, block, shift, stroke, tear, ghost })}
|
|
37
|
+
data-effect-config={JSON.stringify({ cell, reach, decay, block, shift, stroke, tear, ghost, glitch })}
|
|
37
38
|
data-fit-text={fit ? '' : undefined}
|
|
38
39
|
style={withStyle(stroke ? `--glitch-stroke: ${stroke}px` : undefined, given)}
|
|
39
40
|
{...attributes}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* PixelHorizon: a flat colour filling one side and breaking up into square
|
|
4
|
+
* blocks toward the other, blocks winking on and off along a slowly
|
|
5
|
+
* swaying frontier. See src/runtime/pixel-horizon.js.
|
|
6
|
+
*
|
|
7
|
+
* Fills its nearest positioned ancestor, or the viewport with `fixed`.
|
|
8
|
+
* Clear where there is nothing drawn, so it lays over any ground; with a
|
|
9
|
+
* `background`, the element shows a CSS still until the shader starts and
|
|
10
|
+
* without WebGL.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <section class="hero" style="position: relative; background: #0b0b0b">
|
|
14
|
+
* <PixelHorizon background="#0b0b0b" colors={['#1aff00']} side="bottom" quiet={{ radius: 0.42, depth: 1 }} />
|
|
15
|
+
* <h1>…</h1>
|
|
16
|
+
* </section>
|
|
17
|
+
*/
|
|
18
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
19
|
+
import { horizonStill, type PixelHorizonConfig } from '../runtime/pixel-horizon.js';
|
|
20
|
+
|
|
21
|
+
interface Props extends PixelHorizonConfig {
|
|
22
|
+
/** Fill the viewport (position: fixed). Default false. */
|
|
23
|
+
fixed?: boolean;
|
|
24
|
+
/** Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
25
|
+
lazy?: boolean | string;
|
|
26
|
+
class?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { fixed = false, lazy = false, class: className, ...config } = Astro.props;
|
|
30
|
+
const still = config.background ? horizonStill(config) : undefined;
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<EffectCanvas name="pixel-horizon" config={config} fixed={fixed} lazy={lazy} background={still} pixelated class={className} />
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
import { mount } from '../runtime/mount.js';
|
|
37
|
+
import { pixelHorizon } from '../runtime/pixel-horizon.js';
|
|
38
|
+
|
|
39
|
+
mount('[data-effect-pixel-horizon]', pixelHorizon);
|
|
40
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* TruchetField: a field of Truchet tiles, quarter arcs that join into
|
|
4
|
+
* loops and S-bends, a few tiles turning at a time, bright patches
|
|
5
|
+
* drifting through. See src/runtime/truchet-field.js.
|
|
6
|
+
*
|
|
7
|
+
* Fills its nearest positioned ancestor, or the viewport with `fixed`.
|
|
8
|
+
* Clear where there is nothing drawn, so it lays over any ground; with a
|
|
9
|
+
* `background`, the element shows a CSS still until the shader starts and
|
|
10
|
+
* without WebGL.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <section class="hero" style="position: relative; background: #0b0b0b">
|
|
14
|
+
* <TruchetField background="#0b0b0b" colors={['#3a3a3a', '#f4f3ef']} quiet={{ radius: 0.5, depth: 0.9 }} />
|
|
15
|
+
* <h1>…</h1>
|
|
16
|
+
* </section>
|
|
17
|
+
*/
|
|
18
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
19
|
+
import { truchetStill, type TruchetFieldConfig } from '../runtime/truchet-field.js';
|
|
20
|
+
|
|
21
|
+
interface Props extends TruchetFieldConfig {
|
|
22
|
+
/** Fill the viewport (position: fixed). Default false. */
|
|
23
|
+
fixed?: boolean;
|
|
24
|
+
/** Run only while near the screen (true, or how near as a CSS length), giving its WebGL context back when away: for pages with many effects. Default false. */
|
|
25
|
+
lazy?: boolean | string;
|
|
26
|
+
class?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { fixed = false, lazy = false, class: className, ...config } = Astro.props;
|
|
30
|
+
const still = config.background ? truchetStill(config) : undefined;
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
<EffectCanvas name="truchet-field" config={config} fixed={fixed} lazy={lazy} background={still} class={className} />
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
import { mount } from '../runtime/mount.js';
|
|
37
|
+
import { truchetField } from '../runtime/truchet-field.js';
|
|
38
|
+
|
|
39
|
+
mount('[data-effect-truchet-field]', truchetField);
|
|
40
|
+
</script>
|