@arraypress/effects-astro 0.0.0-stage → 0.1.1
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 +85 -0
- package/COMPONENTS.md +1264 -0
- package/LICENSE +139 -0
- package/README.md +197 -2
- package/package.json +60 -4
- package/src/components/AsciiRain.astro +36 -0
- package/src/components/BorderSweep.astro +39 -0
- package/src/components/Caustics.astro +39 -0
- package/src/components/ColorPanels.astro +62 -0
- package/src/components/Cursor.astro +97 -0
- package/src/components/DotGrid.astro +34 -0
- package/src/components/DotSurface.astro +35 -0
- package/src/components/EffectCanvas.astro +152 -0
- package/src/components/FitText.astro +35 -0
- package/src/components/FlutedGlass.astro +36 -0
- package/src/components/Glass.astro +69 -0
- package/src/components/GlassGlyph.astro +38 -0
- package/src/components/GlowField.astro +177 -0
- package/src/components/Grain.astro +98 -0
- package/src/components/HaloRing.astro +38 -0
- package/src/components/HighlightSweep.astro +74 -0
- package/src/components/ImageRipple.astro +56 -0
- package/src/components/Ink.astro +37 -0
- package/src/components/InkField.astro +45 -0
- package/src/components/IsoCity.astro +54 -0
- package/src/components/LightField.astro +40 -0
- package/src/components/LiquidMetal.astro +41 -0
- package/src/components/Magnetic.astro +52 -0
- package/src/components/Marquee.astro +216 -0
- package/src/components/MosaicReveal.astro +196 -0
- package/src/components/NebulaLogo.astro +38 -0
- package/src/components/NeonSwarm.astro +38 -0
- package/src/components/Ocean.astro +40 -0
- package/src/components/OutlineWordmark.astro +222 -0
- package/src/components/PaperBackground.astro +40 -0
- package/src/components/PaperShader.astro +55 -0
- package/src/components/Parallax.astro +49 -0
- package/src/components/ParticleLogo.astro +37 -0
- package/src/components/PixelGlitchText.astro +70 -0
- package/src/components/PointCloud.astro +37 -0
- package/src/components/ProductStack.astro +298 -0
- package/src/components/PulseMark.astro +189 -0
- package/src/components/RadiantGlass.astro +38 -0
- package/src/components/RainOnGlass.astro +71 -0
- package/src/components/Reveal.astro +115 -0
- package/src/components/ScrambleText.astro +52 -0
- package/src/components/ScrollReveal.astro +38 -0
- package/src/components/ShaderBackground.astro +55 -0
- package/src/components/SignalLines.astro +41 -0
- package/src/components/SilkRibbon.astro +37 -0
- package/src/components/SpotlightText.astro +131 -0
- package/src/components/Tilt.astro +79 -0
- package/src/components/Topography.astro +38 -0
- package/src/components/Typewriter.astro +66 -0
- package/src/components/VariableType.astro +59 -0
- package/src/components/VoxelLogo.astro +46 -0
- package/src/components/WaveBars.astro +41 -0
- package/src/components/WorldRoutes.astro +41 -0
- package/src/components/style.js +19 -0
- package/src/index.d.ts +143 -0
- package/src/index.js +105 -0
- package/src/runtime/ascii-rain.d.ts +53 -0
- package/src/runtime/ascii-rain.js +355 -0
- package/src/runtime/audio-meter.d.ts +65 -0
- package/src/runtime/audio-meter.js +282 -0
- package/src/runtime/audio.d.ts +26 -0
- package/src/runtime/audio.js +453 -0
- package/src/runtime/blur.d.ts +2 -0
- package/src/runtime/blur.js +56 -0
- package/src/runtime/canvas2d.d.ts +23 -0
- package/src/runtime/canvas2d.js +105 -0
- package/src/runtime/caustics.d.ts +40 -0
- package/src/runtime/caustics.js +286 -0
- package/src/runtime/color.d.ts +33 -0
- package/src/runtime/color.js +213 -0
- package/src/runtime/curl.d.ts +5 -0
- package/src/runtime/curl.js +81 -0
- package/src/runtime/cursor.d.ts +9 -0
- package/src/runtime/cursor.js +80 -0
- package/src/runtime/device.d.ts +14 -0
- package/src/runtime/device.js +73 -0
- package/src/runtime/dot-grid.d.ts +27 -0
- package/src/runtime/dot-grid.js +245 -0
- package/src/runtime/dot-surface.d.ts +46 -0
- package/src/runtime/dot-surface.js +429 -0
- package/src/runtime/feedback.d.ts +18 -0
- package/src/runtime/feedback.js +131 -0
- package/src/runtime/fit-text.d.ts +5 -0
- package/src/runtime/fit-text.js +60 -0
- package/src/runtime/fluid.d.ts +55 -0
- package/src/runtime/fluid.js +504 -0
- package/src/runtime/fluted-glass.d.ts +27 -0
- package/src/runtime/fluted-glass.js +157 -0
- package/src/runtime/gl.d.ts +19 -0
- package/src/runtime/gl.js +104 -0
- package/src/runtime/glass-glyph.d.ts +49 -0
- package/src/runtime/glass-glyph.js +355 -0
- package/src/runtime/glass-sheen.d.ts +2 -0
- package/src/runtime/glass-sheen.js +30 -0
- package/src/runtime/glsl.d.ts +17 -0
- package/src/runtime/glsl.js +78 -0
- package/src/runtime/glyphs.d.ts +22 -0
- package/src/runtime/glyphs.js +107 -0
- package/src/runtime/halo-ring.d.ts +47 -0
- package/src/runtime/halo-ring.js +334 -0
- package/src/runtime/height-field.d.ts +50 -0
- package/src/runtime/height-field.js +176 -0
- package/src/runtime/image-ripple.d.ts +25 -0
- package/src/runtime/image-ripple.js +353 -0
- package/src/runtime/image.d.ts +11 -0
- package/src/runtime/image.js +81 -0
- package/src/runtime/in-view.d.ts +6 -0
- package/src/runtime/in-view.js +36 -0
- package/src/runtime/ink-field/shaders.js +258 -0
- package/src/runtime/ink-field/sim.js +582 -0
- package/src/runtime/ink-field.d.ts +39 -0
- package/src/runtime/ink-field.js +311 -0
- package/src/runtime/ink.d.ts +31 -0
- package/src/runtime/ink.js +109 -0
- package/src/runtime/instancing.d.ts +12 -0
- package/src/runtime/instancing.js +37 -0
- package/src/runtime/iso-camera.d.ts +35 -0
- package/src/runtime/iso-camera.js +85 -0
- package/src/runtime/iso-city/figures.d.ts +30 -0
- package/src/runtime/iso-city/figures.js +136 -0
- package/src/runtime/iso-city/look.d.ts +34 -0
- package/src/runtime/iso-city/look.js +105 -0
- package/src/runtime/iso-city/plan.d.ts +59 -0
- package/src/runtime/iso-city/plan.js +463 -0
- package/src/runtime/iso-city/roads.d.ts +64 -0
- package/src/runtime/iso-city/roads.js +320 -0
- package/src/runtime/iso-city/scene.d.ts +27 -0
- package/src/runtime/iso-city/scene.js +432 -0
- package/src/runtime/iso-city/shaders.d.ts +6 -0
- package/src/runtime/iso-city/shaders.js +233 -0
- package/src/runtime/iso-city/shadows.d.ts +13 -0
- package/src/runtime/iso-city/shadows.js +148 -0
- package/src/runtime/iso-city/traffic.d.ts +80 -0
- package/src/runtime/iso-city/traffic.js +457 -0
- package/src/runtime/iso-city.d.ts +37 -0
- package/src/runtime/iso-city.js +458 -0
- package/src/runtime/lens-map.d.ts +11 -0
- package/src/runtime/lens-map.js +146 -0
- package/src/runtime/light-field.d.ts +29 -0
- package/src/runtime/light-field.js +292 -0
- package/src/runtime/liquid-glass.d.ts +48 -0
- package/src/runtime/liquid-glass.js +423 -0
- package/src/runtime/liquid-metal/beads.js +217 -0
- package/src/runtime/liquid-metal/field.js +88 -0
- package/src/runtime/liquid-metal/look.js +64 -0
- package/src/runtime/liquid-metal/shaders.js +255 -0
- package/src/runtime/liquid-metal/wave.js +53 -0
- package/src/runtime/liquid-metal.d.ts +46 -0
- package/src/runtime/liquid-metal.js +366 -0
- package/src/runtime/loop.d.ts +7 -0
- package/src/runtime/loop.js +112 -0
- package/src/runtime/magnetic.d.ts +9 -0
- package/src/runtime/magnetic.js +46 -0
- package/src/runtime/marquee.d.ts +2 -0
- package/src/runtime/marquee.js +27 -0
- package/src/runtime/mesh.d.ts +30 -0
- package/src/runtime/mesh.js +217 -0
- package/src/runtime/mosaic-reveal.d.ts +34 -0
- package/src/runtime/mosaic-reveal.js +504 -0
- package/src/runtime/motion.d.ts +2 -0
- package/src/runtime/motion.js +21 -0
- package/src/runtime/mount.d.ts +13 -0
- package/src/runtime/mount.js +120 -0
- package/src/runtime/nebula-logo.d.ts +31 -0
- package/src/runtime/nebula-logo.js +282 -0
- package/src/runtime/neon-swarm.d.ts +31 -0
- package/src/runtime/neon-swarm.js +258 -0
- package/src/runtime/ocean/presets.d.ts +54 -0
- package/src/runtime/ocean/presets.js +184 -0
- package/src/runtime/ocean/shader.d.ts +14 -0
- package/src/runtime/ocean/shader.js +389 -0
- package/src/runtime/ocean/view.d.ts +24 -0
- package/src/runtime/ocean/view.js +98 -0
- package/src/runtime/ocean/waves.d.ts +29 -0
- package/src/runtime/ocean/waves.js +119 -0
- package/src/runtime/ocean.d.ts +31 -0
- package/src/runtime/ocean.js +173 -0
- package/src/runtime/palettes.d.ts +37 -0
- package/src/runtime/palettes.js +75 -0
- package/src/runtime/paper-look.d.ts +42 -0
- package/src/runtime/paper-look.js +91 -0
- package/src/runtime/paper-looks.d.ts +17 -0
- package/src/runtime/paper-looks.js +21 -0
- package/src/runtime/paper.d.ts +37 -0
- package/src/runtime/paper.js +303 -0
- package/src/runtime/particle-logo.d.ts +31 -0
- package/src/runtime/particle-logo.js +196 -0
- package/src/runtime/ping-pong.d.ts +43 -0
- package/src/runtime/ping-pong.js +175 -0
- package/src/runtime/pixel-glitch.d.ts +17 -0
- package/src/runtime/pixel-glitch.js +287 -0
- package/src/runtime/point-cloud.d.ts +33 -0
- package/src/runtime/point-cloud.js +287 -0
- package/src/runtime/pointer.d.ts +27 -0
- package/src/runtime/pointer.js +128 -0
- package/src/runtime/points.d.ts +25 -0
- package/src/runtime/points.js +130 -0
- package/src/runtime/pools.d.ts +2 -0
- package/src/runtime/pools.js +25 -0
- package/src/runtime/product-stack.d.ts +24 -0
- package/src/runtime/product-stack.js +210 -0
- package/src/runtime/radiant-glass.d.ts +29 -0
- package/src/runtime/radiant-glass.js +282 -0
- package/src/runtime/rain-on-glass/backdrop.d.ts +22 -0
- package/src/runtime/rain-on-glass/backdrop.js +185 -0
- package/src/runtime/rain-on-glass/shader.d.ts +2 -0
- package/src/runtime/rain-on-glass/shader.js +168 -0
- package/src/runtime/rain-on-glass/wipe.d.ts +16 -0
- package/src/runtime/rain-on-glass/wipe.js +65 -0
- package/src/runtime/rain-on-glass.d.ts +27 -0
- package/src/runtime/rain-on-glass.js +210 -0
- package/src/runtime/ramp.d.ts +2 -0
- package/src/runtime/ramp.js +30 -0
- package/src/runtime/random.d.ts +2 -0
- package/src/runtime/random.js +22 -0
- package/src/runtime/scroll-reveal.d.ts +22 -0
- package/src/runtime/scroll-reveal.js +73 -0
- package/src/runtime/shader-background.d.ts +42 -0
- package/src/runtime/shader-background.js +261 -0
- package/src/runtime/shader-backgrounds/band-lens.js +72 -0
- package/src/runtime/shader-backgrounds/common.js +53 -0
- package/src/runtime/shader-backgrounds/grain-gradient.js +87 -0
- package/src/runtime/shader-backgrounds/grid.js +33 -0
- package/src/runtime/shader-backgrounds/mesh-gradient.js +74 -0
- package/src/runtime/shader-backgrounds/silk.js +57 -0
- package/src/runtime/shader-backgrounds/waves.js +31 -0
- package/src/runtime/shape.d.ts +42 -0
- package/src/runtime/shape.js +313 -0
- package/src/runtime/silk-ribbon.d.ts +23 -0
- package/src/runtime/silk-ribbon.js +206 -0
- package/src/runtime/slideshow.d.ts +27 -0
- package/src/runtime/slideshow.js +234 -0
- package/src/runtime/spotlight.d.ts +9 -0
- package/src/runtime/spotlight.js +97 -0
- package/src/runtime/stack-poses.d.ts +53 -0
- package/src/runtime/stack-poses.js +273 -0
- package/src/runtime/stage.d.ts +47 -0
- package/src/runtime/stage.js +187 -0
- package/src/runtime/swarm.d.ts +49 -0
- package/src/runtime/swarm.js +199 -0
- package/src/runtime/text-motion.d.ts +41 -0
- package/src/runtime/text-motion.js +165 -0
- package/src/runtime/text.d.ts +11 -0
- package/src/runtime/text.js +90 -0
- package/src/runtime/tilt.d.ts +19 -0
- package/src/runtime/tilt.js +116 -0
- package/src/runtime/topography.d.ts +71 -0
- package/src/runtime/topography.js +650 -0
- package/src/runtime/trackers.d.ts +21 -0
- package/src/runtime/trackers.js +76 -0
- package/src/runtime/variable-type.d.ts +43 -0
- package/src/runtime/variable-type.js +358 -0
- package/src/runtime/voxel-logo.d.ts +31 -0
- package/src/runtime/voxel-logo.js +237 -0
- package/src/runtime/waves.d.ts +70 -0
- package/src/runtime/waves.js +799 -0
- package/src/runtime/world-labels.d.ts +29 -0
- package/src/runtime/world-labels.js +59 -0
- package/src/runtime/world-land.d.ts +8 -0
- package/src/runtime/world-land.js +105 -0
- package/src/runtime/world-map.d.ts +69 -0
- package/src/runtime/world-map.js +308 -0
- package/src/runtime/world-plan.d.ts +101 -0
- package/src/runtime/world-plan.js +333 -0
- package/src/runtime/world-routes.d.ts +75 -0
- package/src/runtime/world-routes.js +673 -0
- package/src/styles/border-sweep.css +82 -0
- package/src/styles/glass.css +104 -0
- package/src/styles/motion.css +218 -0
- package/src/styles/reveal.css +51 -0
- package/src/vendor/paper/LICENSE +201 -0
- package/src/vendor/paper/NOTICE +5 -0
- package/src/vendor/paper/README.md +8 -0
- package/src/vendor/paper/get-shader-color-from-string.js +100 -0
- package/src/vendor/paper/get-shader-noise-texture.js +17 -0
- package/src/vendor/paper/presets.js +3678 -0
- package/src/vendor/paper/shader-sizing.js +37 -0
- package/src/vendor/paper/shader-utils.js +130 -0
- package/src/vendor/paper/shaders/color-panels.js +223 -0
- package/src/vendor/paper/shaders/dithering.js +270 -0
- package/src/vendor/paper/shaders/dot-grid.js +109 -0
- package/src/vendor/paper/shaders/dot-orbit.js +122 -0
- package/src/vendor/paper/shaders/fluted-glass.js +360 -0
- package/src/vendor/paper/shaders/gem-smoke.js +572 -0
- package/src/vendor/paper/shaders/god-rays.js +132 -0
- package/src/vendor/paper/shaders/grain-gradient.js +300 -0
- package/src/vendor/paper/shaders/halftone-cmyk.js +294 -0
- package/src/vendor/paper/shaders/halftone-dots.js +320 -0
- package/src/vendor/paper/shaders/heatmap.js +383 -0
- package/src/vendor/paper/shaders/image-dithering.js +198 -0
- package/src/vendor/paper/shaders/lens-distortion.js +275 -0
- package/src/vendor/paper/shaders/liquid-metal.js +632 -0
- package/src/vendor/paper/shaders/mesh-gradient.js +130 -0
- package/src/vendor/paper/shaders/metaballs.js +110 -0
- package/src/vendor/paper/shaders/neuro-noise.js +76 -0
- package/src/vendor/paper/shaders/paper-texture.js +526 -0
- package/src/vendor/paper/shaders/perlin-noise.js +166 -0
- package/src/vendor/paper/shaders/pulsing-border.js +238 -0
- package/src/vendor/paper/shaders/simplex-noise.js +91 -0
- package/src/vendor/paper/shaders/smoke-ring.js +132 -0
- package/src/vendor/paper/shaders/spiral.js +82 -0
- package/src/vendor/paper/shaders/static-mesh-gradient.js +130 -0
- package/src/vendor/paper/shaders/static-radial-gradient.js +187 -0
- package/src/vendor/paper/shaders/swirl.js +103 -0
- package/src/vendor/paper/shaders/voronoi.js +138 -0
- package/src/vendor/paper/shaders/warp.js +129 -0
- package/src/vendor/paper/shaders/water.js +121 -0
- package/src/vendor/paper/shaders/waves.js +65 -0
- package/src/vendor/paper/vertex-shader.js +159 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arraypress/effects-astro/paper-look
|
|
3
|
+
*
|
|
4
|
+
* A Paper look on the page: its plain props (src/runtime/paper-looks.js)
|
|
5
|
+
* turned into Paper's settings and run as a Paper shader
|
|
6
|
+
* (src/runtime/paper.js). A prop left out keeps its preset's setting, so
|
|
7
|
+
* with no props a look is its preset. Shared by every look's component
|
|
8
|
+
* through src/components/PaperBackground.astro.
|
|
9
|
+
*
|
|
10
|
+
* `quiet` dims the shader towards its `background` behind copy, with a
|
|
11
|
+
* mask on the canvas over the element's own background, since Paper's
|
|
12
|
+
* shaders are run unchanged.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { paperSettings, paperShader } from './paper.js';
|
|
16
|
+
import { pickColors } from './palettes.js';
|
|
17
|
+
import { PAPER_LOOKS } from './paper-looks.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {import('./paper-look.js').PaperLookConfig} PaperLookConfig
|
|
21
|
+
* @typedef {import('./paper.js').PaperConfig} PaperConfig
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** The props every look shares, and the Paper settings they set; a pair sets two from `[x, y]`. */
|
|
25
|
+
const SHARED = /** @type {Record<string, string | [string, string]>} */ ({ background: 'colorBack', zoom: 'scale', rotation: 'rotation', offset: ['offsetX', 'offsetY'] });
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A look's props as a Paper shader's config: its shader, its preset (the
|
|
29
|
+
* named one or the look's), and Paper's settings for the props given.
|
|
30
|
+
*
|
|
31
|
+
* @param {PaperLookConfig} config The look and its props.
|
|
32
|
+
* @returns {PaperConfig} The shader's config.
|
|
33
|
+
* @throws {Error} When there is no such look.
|
|
34
|
+
*/
|
|
35
|
+
export function paperLookSettings(config) {
|
|
36
|
+
const look = PAPER_LOOKS[config.look];
|
|
37
|
+
if (!look) throw new Error(`No Paper look "${config.look}"`);
|
|
38
|
+
/** @type {Record<string, unknown>} */
|
|
39
|
+
const params = {};
|
|
40
|
+
for (const [prop, setting] of Object.entries({ ...SHARED, ...look.props })) {
|
|
41
|
+
const value = /** @type {Record<string, unknown>} */ (config)[prop];
|
|
42
|
+
if (value === undefined) continue;
|
|
43
|
+
if (Array.isArray(setting)) setting.forEach((name, i) => (params[name] = /** @type {unknown[]} */ (value)[i]));
|
|
44
|
+
else params[setting] = value;
|
|
45
|
+
}
|
|
46
|
+
const colors = pickColors(config, []);
|
|
47
|
+
return {
|
|
48
|
+
shader: look.shader,
|
|
49
|
+
preset: config.preset ?? look.preset,
|
|
50
|
+
params,
|
|
51
|
+
...(colors.length ? { colors } : {}),
|
|
52
|
+
...(config.speed !== undefined ? { speed: config.speed } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The CSS mask that dims a canvas behind copy: `1 - depth` at the quiet
|
|
58
|
+
* area's centre, rising to full by its edge. Sized in the element's
|
|
59
|
+
* height (`cqh`), as the effects' own quiet areas are.
|
|
60
|
+
*
|
|
61
|
+
* @param {NonNullable<PaperLookConfig['quiet']>} quiet The quiet area.
|
|
62
|
+
* @returns {string} The mask.
|
|
63
|
+
*/
|
|
64
|
+
export function quietMask({ x = 0.5, y = 0.5, radius = 0.8, depth = 0.72 }) {
|
|
65
|
+
return `radial-gradient(circle calc(${radius} * 100cqh) at ${x * 100}% ${y * 100}%, rgb(0 0 0 / ${Number((1 - depth).toFixed(3))}) calc(${radius * 0.06} * 100cqh), #000)`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Starts a Paper look on an element: the shader in its canvas, the
|
|
70
|
+
* element's background the shader's (what shows through the quiet area),
|
|
71
|
+
* and its quiet area masked.
|
|
72
|
+
*
|
|
73
|
+
* @param {HTMLElement} el The element (its first canvas is drawn into).
|
|
74
|
+
* @param {PaperLookConfig} config The look and its props.
|
|
75
|
+
* @returns {() => void} Stops it.
|
|
76
|
+
*/
|
|
77
|
+
export function paperLook(el, config) {
|
|
78
|
+
const shader = paperLookSettings(config);
|
|
79
|
+
const canvas = el.querySelector('canvas');
|
|
80
|
+
const back = paperSettings(shader).colorBack;
|
|
81
|
+
if (typeof back === 'string') el.style.backgroundColor = back;
|
|
82
|
+
if (config.quiet && canvas) {
|
|
83
|
+
el.style.containerType = 'size';
|
|
84
|
+
canvas.style.maskImage = canvas.style.webkitMaskImage = quietMask(config.quiet);
|
|
85
|
+
}
|
|
86
|
+
const stop = paperShader(el, shader);
|
|
87
|
+
return () => {
|
|
88
|
+
stop();
|
|
89
|
+
if (canvas) canvas.style.maskImage = canvas.style.webkitMaskImage = '';
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PaperShaderName } from './paper.js';
|
|
2
|
+
|
|
3
|
+
/** A Paper look's name: its component's, in kebab case. */
|
|
4
|
+
export type PaperLookName = 'color-panels';
|
|
5
|
+
|
|
6
|
+
/** A Paper shader as a background of its own. */
|
|
7
|
+
export interface PaperLook {
|
|
8
|
+
/** Its shader. */
|
|
9
|
+
shader: PaperShaderName;
|
|
10
|
+
/** The preset its props start from. */
|
|
11
|
+
preset: string;
|
|
12
|
+
/** Which of Paper's settings each of its own props sets, by prop. */
|
|
13
|
+
props: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The Paper looks, by name. */
|
|
17
|
+
export const PAPER_LOOKS: Readonly<Record<PaperLookName, PaperLook>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arraypress/effects-astro/paper-looks
|
|
3
|
+
*
|
|
4
|
+
* The Paper looks: Paper shaders made backgrounds of their own (each a
|
|
5
|
+
* component, `<ColorPanels>`…), named for the look. Each is its shader,
|
|
6
|
+
* the preset its props start from, and which of Paper's settings each of
|
|
7
|
+
* its own props sets (`skewLeft` → `angle1`). The props every look shares
|
|
8
|
+
* (`background`, `zoom`, `rotation`, `offset`, `colors`, `palette`,
|
|
9
|
+
* `speed`, `quiet`) are mapped once, in src/runtime/paper-look.js.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** @typedef {import('./paper-looks.js').PaperLook} PaperLook */
|
|
13
|
+
|
|
14
|
+
/** @type {Readonly<Record<import('./paper-looks.js').PaperLookName, PaperLook>>} */
|
|
15
|
+
export const PAPER_LOOKS = {
|
|
16
|
+
'color-panels': {
|
|
17
|
+
shader: 'color-panels',
|
|
18
|
+
preset: 'Opening',
|
|
19
|
+
props: { density: 'density', skewLeft: 'angle1', skewRight: 'angle2', length: 'length', edges: 'edges', blur: 'blur', fadeInner: 'fadeIn', fadeOuter: 'fadeOut', blend: 'gradient' },
|
|
20
|
+
},
|
|
21
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** The thirty Paper shaders, by file name. */
|
|
2
|
+
export type PaperShaderName =
|
|
3
|
+
| 'color-panels' | 'dithering' | 'dot-grid' | 'dot-orbit' | 'fluted-glass' | 'gem-smoke' | 'god-rays'
|
|
4
|
+
| 'grain-gradient' | 'halftone-cmyk' | 'halftone-dots' | 'heatmap' | 'image-dithering' | 'lens-distortion'
|
|
5
|
+
| 'liquid-metal' | 'mesh-gradient' | 'metaballs' | 'neuro-noise' | 'paper-texture' | 'perlin-noise'
|
|
6
|
+
| 'pulsing-border' | 'simplex-noise' | 'smoke-ring' | 'spiral' | 'static-mesh-gradient'
|
|
7
|
+
| 'static-radial-gradient' | 'swirl' | 'voronoi' | 'warp' | 'water' | 'waves';
|
|
8
|
+
|
|
9
|
+
export interface PaperConfig {
|
|
10
|
+
/** The shader, by its file name. */
|
|
11
|
+
shader: PaperShaderName;
|
|
12
|
+
/** One of the shader's presets, by name (any case). Default its first. */
|
|
13
|
+
preset?: string;
|
|
14
|
+
/** Paper's settings for the shader (`distortion`, `colorBack`…), over the preset's. */
|
|
15
|
+
params?: Record<string, unknown>;
|
|
16
|
+
/** The shader's colours, over the preset's. */
|
|
17
|
+
colors?: string[];
|
|
18
|
+
/** A picture for the shaders that bend or trace one. */
|
|
19
|
+
image?: string;
|
|
20
|
+
/** Colours to make a picture from, when there is no `image`. */
|
|
21
|
+
gradient?: string[];
|
|
22
|
+
/** The made picture's angle, degrees. Default 135. */
|
|
23
|
+
gradientAngle?: number;
|
|
24
|
+
/** How fast it moves, over the preset's (0 is still). */
|
|
25
|
+
speed?: number;
|
|
26
|
+
/** Share of the pixel ratio drawn at. Default 1. */
|
|
27
|
+
scale?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A shader's settings: its preset with the config's settings over it. Throws for an unknown shader. */
|
|
31
|
+
export function paperSettings(config: PaperConfig): Record<string, any>;
|
|
32
|
+
|
|
33
|
+
/** Settings as uniforms: `u_` names, colours as RGBA, named options as numbers. */
|
|
34
|
+
export function paperUniforms(shader: string, settings: Record<string, any>): Record<string, number | boolean | number[] | number[][]>;
|
|
35
|
+
|
|
36
|
+
/** Starts a Paper shader in `el`'s canvas. Returns a function that stops it. */
|
|
37
|
+
export function paperShader(el: HTMLElement, config: PaperConfig): () => void;
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arraypress/effects-astro/paper
|
|
3
|
+
*
|
|
4
|
+
* The Paper Shaders catalogue on our stage: thirty shaders (mesh and grain
|
|
5
|
+
* gradients, god rays, liquid metal, water, warp, dithering, halftones,
|
|
6
|
+
* metaballs, voronoi and more), each with the presets Paper ships, run
|
|
7
|
+
* without React and without the npm package. The shader sources are
|
|
8
|
+
* vendored unchanged in src/vendor/paper (Apache-2.0; see its LICENSE and
|
|
9
|
+
* NOTICE); this is the host that feeds them.
|
|
10
|
+
*
|
|
11
|
+
* Settings are Paper's own names (`distortion`, `swirl`, `colorBack`…),
|
|
12
|
+
* each becoming its `u_` uniform: colours from CSS strings, `colors` as an
|
|
13
|
+
* array (and its count), named options (`shape: 'wave'`) as their numbers,
|
|
14
|
+
* and the sizing uniforms every shader needs (without them the shaders
|
|
15
|
+
* draw one flat colour). A `preset` is the starting point; settings
|
|
16
|
+
* override it. `image` feeds the shaders that bend or trace a picture
|
|
17
|
+
* (fluted glass, water, lens distortion, liquid metal, halftones…), and
|
|
18
|
+
* `gradient` makes one from colours when there is no picture.
|
|
19
|
+
*
|
|
20
|
+
* Each shader is its own module, loaded when used, so a page pays only for
|
|
21
|
+
* the shaders on it. Needs WebGL 2; without it the element's background
|
|
22
|
+
* shows. With prefers-reduced-motion, one still frame.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { createStage } from './stage.js';
|
|
26
|
+
import { watchColors } from './mount.js';
|
|
27
|
+
import { loadImage, imageTexture } from './image.js';
|
|
28
|
+
import { vertexShaderSource } from '../vendor/paper/vertex-shader.js';
|
|
29
|
+
import { getShaderColorFromString } from '../vendor/paper/get-shader-color-from-string.js';
|
|
30
|
+
import { getShaderNoiseTexture } from '../vendor/paper/get-shader-noise-texture.js';
|
|
31
|
+
import { PRESETS, ENUMS, RENAMES, FITS } from '../vendor/paper/presets.js';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {object} PaperConfig
|
|
35
|
+
* @property {string} shader The shader, by its file name: `mesh-gradient`, `god-rays`, `liquid-metal`…
|
|
36
|
+
* @property {string} [preset] One of the shader's presets, by name (`Beach`, `Ink`…; any case). Default its first.
|
|
37
|
+
* @property {Record<string, unknown>} [params] Paper's settings for the shader, over the preset's.
|
|
38
|
+
* @property {string[]} [colors] The shader's colours, over the preset's (where it takes a list).
|
|
39
|
+
* @property {string} [image] A picture for the shaders that bend or trace one.
|
|
40
|
+
* @property {string[]} [gradient] Colours to make a picture from, when there is no `image`.
|
|
41
|
+
* @property {number} [gradientAngle=135] The made picture's angle, degrees.
|
|
42
|
+
* @property {number} [speed] How fast it moves, over the preset's (0 is still).
|
|
43
|
+
* @property {number} [scale=1] Share of the pixel ratio drawn at.
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/** The shaders that sample their picture blurred (mip levels), as Paper's React components set up. */
|
|
47
|
+
const MIPMAPPED = new Set(['fluted-glass', 'gem-smoke', 'heatmap', 'liquid-metal', 'lens-distortion', 'paper-texture', 'water']);
|
|
48
|
+
|
|
49
|
+
/** The shaders whose picture preparation reads a dark shape: given a black silhouette, so a white or coloured logo works. */
|
|
50
|
+
const SILHOUETTE = new Set(['heatmap']);
|
|
51
|
+
|
|
52
|
+
/** Settings that are not uniforms: they steer the host. */
|
|
53
|
+
const HOST = new Set(['speed', 'frame']);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* A shader's module name as its export's prefix: `god-rays` → `godRays`.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} name The file name.
|
|
59
|
+
* @returns {string} camelCase.
|
|
60
|
+
*/
|
|
61
|
+
const camel = (name) => name.replace(/-(\w)/g, (_, c) => c.toUpperCase());
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The shader's settings: its preset (the named one or its first), with the
|
|
65
|
+
* config's colours and settings over it.
|
|
66
|
+
*
|
|
67
|
+
* @param {PaperConfig} config The config.
|
|
68
|
+
* @returns {Record<string, any>} Every setting.
|
|
69
|
+
* @throws {Error} When the shader is not in the catalogue.
|
|
70
|
+
*/
|
|
71
|
+
export function paperSettings(config) {
|
|
72
|
+
const presets = PRESETS[/** @type {keyof typeof PRESETS} */ (config.shader)];
|
|
73
|
+
if (!presets) throw new Error(`No Paper shader "${config.shader}"`);
|
|
74
|
+
const wanted = config.preset?.toLowerCase();
|
|
75
|
+
const preset = presets.find((p) => p.name.toLowerCase() === wanted) ?? presets[0];
|
|
76
|
+
return {
|
|
77
|
+
...preset.params,
|
|
78
|
+
...(config.colors ? { colors: config.colors } : {}),
|
|
79
|
+
...(config.speed !== undefined ? { speed: config.speed } : {}),
|
|
80
|
+
...config.params,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The settings as uniforms: `u_` names, colours as RGBA, named options as
|
|
86
|
+
* their numbers, `colors` with its count.
|
|
87
|
+
*
|
|
88
|
+
* @param {string} shader The shader.
|
|
89
|
+
* @param {Record<string, any>} settings Its settings.
|
|
90
|
+
* @returns {Record<string, number | boolean | number[] | number[][]>} Uniform values by name.
|
|
91
|
+
*/
|
|
92
|
+
export function paperUniforms(shader, settings) {
|
|
93
|
+
/** @type {Record<string, any>} */
|
|
94
|
+
const out = {};
|
|
95
|
+
const named = ENUMS[/** @type {keyof typeof ENUMS} */ (shader)] ?? {};
|
|
96
|
+
/** @type {Record<string, string>} */
|
|
97
|
+
const renamed = RENAMES[/** @type {keyof typeof RENAMES} */ (shader)] ?? {};
|
|
98
|
+
for (const [setting, value] of Object.entries(settings)) {
|
|
99
|
+
if (HOST.has(setting) || value === undefined || value === null) continue;
|
|
100
|
+
// Some settings feed a uniform of another name (`size` → `u_pxSize`).
|
|
101
|
+
const key = renamed[setting] ?? setting;
|
|
102
|
+
if (key === 'colors' && Array.isArray(value)) {
|
|
103
|
+
out.u_colors = value.map((c) => getShaderColorFromString(c));
|
|
104
|
+
out.u_colorsCount = value.length;
|
|
105
|
+
} else if (key === 'fit') {
|
|
106
|
+
out.u_fit = typeof value === 'string' ? FITS[/** @type {keyof typeof FITS} */ (value)] ?? 2 : value;
|
|
107
|
+
} else if (typeof value === 'string' && /** @type {Record<string, any>} */ (named)[setting]) {
|
|
108
|
+
out[`u_${key}`] = /** @type {Record<string, any>} */ (named)[setting][value] ?? 0;
|
|
109
|
+
} else if (typeof value === 'string') {
|
|
110
|
+
out[`u_${key}`] = getShaderColorFromString(value);
|
|
111
|
+
} else {
|
|
112
|
+
out[`u_${key}`] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A picture as a black silhouette: wherever it is opaque, black.
|
|
120
|
+
*
|
|
121
|
+
* @param {string} src The picture's URL.
|
|
122
|
+
* @returns {Promise<string>} A URL of the silhouette (PNG).
|
|
123
|
+
*/
|
|
124
|
+
async function silhouette(src) {
|
|
125
|
+
const img = await loadImage(src);
|
|
126
|
+
const canvas = document.createElement('canvas');
|
|
127
|
+
canvas.width = img.naturalWidth || 512;
|
|
128
|
+
canvas.height = img.naturalHeight || 512;
|
|
129
|
+
const ctx = /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));
|
|
130
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
131
|
+
ctx.globalCompositeOperation = 'source-in';
|
|
132
|
+
ctx.fillStyle = '#000';
|
|
133
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
134
|
+
return canvas.toDataURL();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Reads a Blob as a data: URL.
|
|
139
|
+
*
|
|
140
|
+
* @param {Blob} blob The blob (a prepared picture).
|
|
141
|
+
* @returns {Promise<string>} Its contents as a data: URL.
|
|
142
|
+
* @throws {DOMException} When the blob cannot be read.
|
|
143
|
+
*/
|
|
144
|
+
function dataUrl(blob) {
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
const reader = new FileReader();
|
|
147
|
+
reader.onload = () => resolve(String(reader.result));
|
|
148
|
+
reader.onerror = () => reject(reader.error);
|
|
149
|
+
reader.readAsDataURL(blob);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* A picture made from colours: a linear gradient, square.
|
|
155
|
+
*
|
|
156
|
+
* @param {string[]} colors The colours.
|
|
157
|
+
* @param {number} angle Degrees.
|
|
158
|
+
* @returns {Promise<HTMLImageElement>} The picture.
|
|
159
|
+
*/
|
|
160
|
+
function gradientImage(colors, angle) {
|
|
161
|
+
const size = 512;
|
|
162
|
+
const canvas = document.createElement('canvas');
|
|
163
|
+
canvas.width = canvas.height = size;
|
|
164
|
+
const ctx = /** @type {CanvasRenderingContext2D} */ (canvas.getContext('2d'));
|
|
165
|
+
const a = (angle * Math.PI) / 180;
|
|
166
|
+
const dx = Math.cos(a) * size;
|
|
167
|
+
const dy = Math.sin(a) * size;
|
|
168
|
+
const g = ctx.createLinearGradient((size - dx) / 2, (size - dy) / 2, (size + dx) / 2, (size + dy) / 2);
|
|
169
|
+
colors.forEach((c, i) => g.addColorStop(colors.length === 1 ? 0 : i / (colors.length - 1), c));
|
|
170
|
+
ctx.fillStyle = g;
|
|
171
|
+
ctx.fillRect(0, 0, size, size);
|
|
172
|
+
return loadImage(canvas.toDataURL());
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Starts a Paper shader on an element: a canvas inside it, filling it.
|
|
177
|
+
*
|
|
178
|
+
* @param {HTMLElement} el The element (its first canvas is drawn into).
|
|
179
|
+
* @param {PaperConfig} config The settings.
|
|
180
|
+
* @returns {() => void} Stops it.
|
|
181
|
+
*/
|
|
182
|
+
export function paperShader(el, config) {
|
|
183
|
+
let stopped = false;
|
|
184
|
+
let stop = () => {};
|
|
185
|
+
start(el, config)
|
|
186
|
+
.then((s) => {
|
|
187
|
+
if (stopped) s();
|
|
188
|
+
else stop = s;
|
|
189
|
+
})
|
|
190
|
+
.catch((error) => console.warn('[effects-astro]', error));
|
|
191
|
+
return () => {
|
|
192
|
+
stopped = true;
|
|
193
|
+
stop();
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Loads the shader and its pictures, then starts it.
|
|
199
|
+
*
|
|
200
|
+
* @param {HTMLElement} el The element.
|
|
201
|
+
* @param {PaperConfig} config The settings.
|
|
202
|
+
* @returns {Promise<() => void>} Stops it.
|
|
203
|
+
*/
|
|
204
|
+
async function start(el, config) {
|
|
205
|
+
/** @type {Record<string, any>} */
|
|
206
|
+
const module = await import(`../vendor/paper/shaders/${config.shader}.js`);
|
|
207
|
+
const fragment = module[`${camel(config.shader)}FragmentShader`];
|
|
208
|
+
if (!fragment) throw new Error(`No fragment shader in Paper's "${config.shader}"`);
|
|
209
|
+
let settings = paperSettings(config);
|
|
210
|
+
|
|
211
|
+
// The pictures: the shader's image (prepared, for the shaders that trace
|
|
212
|
+
// one), and the noise texture some of them sample.
|
|
213
|
+
/** @type {Record<string, HTMLImageElement>} */
|
|
214
|
+
const pictures = {};
|
|
215
|
+
if (fragment.includes('u_image')) {
|
|
216
|
+
let src = config.image;
|
|
217
|
+
const prepare = Object.keys(module).find((k) => k.startsWith('toProcessed'));
|
|
218
|
+
if (src && prepare) {
|
|
219
|
+
if (SILHOUETTE.has(config.shader)) src = await silhouette(src);
|
|
220
|
+
const result = await module[prepare](src);
|
|
221
|
+
// The helpers name their result differently: `pngBlob` (liquid metal, gem smoke) or `blob` (heatmap).
|
|
222
|
+
// Read as a data: URL, not a blob: one, so it loads under a CSP that allows data: images
|
|
223
|
+
// but not blob: (a common default), and there is no object URL left to revoke.
|
|
224
|
+
src = await dataUrl(result.pngBlob ?? result.blob);
|
|
225
|
+
}
|
|
226
|
+
if (src) pictures.u_image = await loadImage(src);
|
|
227
|
+
else if (config.gradient?.length) pictures.u_image = await gradientImage(config.gradient, config.gradientAngle ?? 135);
|
|
228
|
+
}
|
|
229
|
+
if (fragment.includes('u_noiseTexture')) {
|
|
230
|
+
const noise = getShaderNoiseTexture();
|
|
231
|
+
if (noise) pictures.u_noiseTexture = await noise.decode().then(() => noise);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const startTime = performance.now();
|
|
235
|
+
/** @type {Map<string, { type: number, size: number, location: WebGLUniformLocation }>} */
|
|
236
|
+
const active = new Map();
|
|
237
|
+
|
|
238
|
+
const { stage, stop } = createStage(el, {
|
|
239
|
+
fragment,
|
|
240
|
+
vertex: vertexShaderSource,
|
|
241
|
+
webgl1: false,
|
|
242
|
+
scale: config.scale ?? 1,
|
|
243
|
+
setup({ gl, program }) {
|
|
244
|
+
const count = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
|
|
245
|
+
for (let i = 0; i < count; i++) {
|
|
246
|
+
const info = /** @type {WebGLActiveInfo} */ (gl.getActiveUniform(program, i));
|
|
247
|
+
const name = info.name.replace(/\[0\]$/, '');
|
|
248
|
+
const location = gl.getUniformLocation(program, info.name);
|
|
249
|
+
if (location) active.set(name, { type: info.type, size: info.size, location });
|
|
250
|
+
}
|
|
251
|
+
// The pictures, each on its own unit, with its aspect ratio where the shader wants it.
|
|
252
|
+
let unit = 0;
|
|
253
|
+
for (const [name, img] of Object.entries(pictures)) {
|
|
254
|
+
const slot = active.get(name);
|
|
255
|
+
if (!slot) continue;
|
|
256
|
+
gl.activeTexture(gl.TEXTURE0 + unit);
|
|
257
|
+
imageTexture(gl, img, { mipmap: name === 'u_image' && MIPMAPPED.has(config.shader) });
|
|
258
|
+
gl.uniform1i(slot.location, unit);
|
|
259
|
+
const ratio = active.get(`${name}AspectRatio`);
|
|
260
|
+
if (ratio) gl.uniform1f(ratio.location, img.naturalWidth / img.naturalHeight);
|
|
261
|
+
unit++;
|
|
262
|
+
}
|
|
263
|
+
const isImage = active.get('u_isImage');
|
|
264
|
+
if (isImage) gl.uniform1i(isImage.location, pictures.u_image ? 1 : 0);
|
|
265
|
+
},
|
|
266
|
+
uniforms({ gl, canvas, ratio }, now) {
|
|
267
|
+
/**
|
|
268
|
+
* Sets one uniform by its declared type.
|
|
269
|
+
*
|
|
270
|
+
* @param {string} name The uniform.
|
|
271
|
+
* @param {any} value Its value.
|
|
272
|
+
*/
|
|
273
|
+
const set = (name, value) => {
|
|
274
|
+
const slot = active.get(name);
|
|
275
|
+
if (!slot || value === undefined) return;
|
|
276
|
+
const { type, location } = slot;
|
|
277
|
+
if (type === gl.FLOAT) gl.uniform1f(location, Number(value));
|
|
278
|
+
else if (type === gl.BOOL || type === gl.INT) gl.uniform1i(location, value ? Number(value) : 0);
|
|
279
|
+
else if (type === gl.FLOAT_VEC2) gl.uniform2fv(location, value);
|
|
280
|
+
else if (type === gl.FLOAT_VEC3) gl.uniform3fv(location, value.slice(0, 3));
|
|
281
|
+
else if (type === gl.FLOAT_VEC4) {
|
|
282
|
+
const flat = Array.isArray(value[0]) ? value.flat() : value;
|
|
283
|
+
if (flat.length) gl.uniform4fv(location, flat);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
const time = ((now - startTime) / 1000) * (settings.speed ?? 1) + (settings.frame ?? 0) / 1000;
|
|
287
|
+
set('u_time', time);
|
|
288
|
+
set('u_resolution', [canvas.width, canvas.height]);
|
|
289
|
+
set('u_pixelRatio', ratio);
|
|
290
|
+
for (const [name, value] of Object.entries(paperUniforms(config.shader, settings))) set(name, value);
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
if (!stage) return stop;
|
|
294
|
+
|
|
295
|
+
const unwatch = watchColors(el, (next) => {
|
|
296
|
+
settings = { ...settings, colors: next.colors };
|
|
297
|
+
if (stage.still) stage.redraw();
|
|
298
|
+
});
|
|
299
|
+
return () => {
|
|
300
|
+
stop();
|
|
301
|
+
unwatch();
|
|
302
|
+
};
|
|
303
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { PaletteName } from './palettes.js';
|
|
2
|
+
|
|
3
|
+
export interface ParticleLogoConfig {
|
|
4
|
+
/** A word (or a character, an emoji) to draw in particles. */
|
|
5
|
+
text?: string;
|
|
6
|
+
/** Its CSS font, without the size. Default: the page's, bold. */
|
|
7
|
+
font?: string;
|
|
8
|
+
/** An image (an SVG logo, a PNG) to draw in particles instead. */
|
|
9
|
+
src?: string;
|
|
10
|
+
/** Where the shape sits, each 0–1 from the top left. Default the middle. */
|
|
11
|
+
area?: { x: number; y: number; width: number; height: number };
|
|
12
|
+
/** The dots' two colours, then the two blooms'. Default white, ice blue, deep teal, midnight blue. */
|
|
13
|
+
colors?: string[];
|
|
14
|
+
/** A shared palette by name (`PALETTES`, any case), when there are no `colors`. */
|
|
15
|
+
palette?: PaletteName | (string & {});
|
|
16
|
+
/** The ground. Default `#030305`. */
|
|
17
|
+
background?: string;
|
|
18
|
+
/** How many particles (half on phones). Default 16000. */
|
|
19
|
+
count?: number;
|
|
20
|
+
/** A particle's size, CSS px. Default 2.2. */
|
|
21
|
+
size?: number;
|
|
22
|
+
/** How strongly they scatter round the pointer; 0 for not at all. Default 1. */
|
|
23
|
+
swarm?: number;
|
|
24
|
+
/** How far the mark tilts towards the pointer. Default 1. */
|
|
25
|
+
tilt?: number;
|
|
26
|
+
/** How far red and blue part, CSS px; 0 for none. Default 1.5. */
|
|
27
|
+
aberration?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Starts a particle logo in `el`'s canvas. Returns a function that stops it. */
|
|
31
|
+
export function particleLogo(el: HTMLElement, config: ParticleLogoConfig): () => void;
|