安装
npm install agent-aura
import { aura } from 'agent-aura'
aura.glow('#hero')
aura.border('#card')
aura.fire('#card')
aura.burning('#agent')
aura.shape('#avatar')
aura.water('#stream')
aura.cultivation('#dao')
aura.demonic('#mo')
aura.thunder('#jie')
aura.void('#hole')
aura.glitch('#crash')
CDN:https://unpkg.com/agent-aura/build/agent-aura.min.js,全局
AgentAura。包是 ESM,没有 CJS。glow / border /
fire / burning / thunder / shape /
water / cultivation / demonic / void /
glitch 需要 WebGL2。
aura
aura.glow(target, options?: GlowOptions): Glow aura.border(target, options?: AttachOptions<MotionBorderOptions>): MotionBorder aura.fire(target, options?: AttachOptions<FireBorderOptions>): FireBorder aura.burning(target, options?: AttachOptions<BurningFireOptions>): BurningFire aura.shape(target, options?: AttachOptions<ShapeAuraOptions>): ShapeAura aura.water(target, options?: AttachOptions<WaterAuraOptions>): WaterAura aura.cultivation(target, options?: AttachOptions<CultivationAuraOptions>): CultivationAura aura.demonic(target, options?: AttachOptions<DemonicAuraOptions>): DemonicAura aura.thunder(target, options?: AttachOptions<ThunderAuraOptions>): ThunderAura aura.void(target, options?: AttachOptions<VoidAuraOptions>): VoidAura aura.glitch(target, options?: AttachOptions<GlitchAuraOptions>): GlitchAura
target 是选择器或 HTMLElement。等价于对应 class 的
attach()。找不到节点抛 agent-aura: target not found。
生命周期
| 方法 | 行为 |
|---|---|
start() |
attach() 已调用,一般不用再调
|
pause() |
停 rAF,canvas 留着 |
dispose() |
释放 WebGL / Observer / canvas,幂等。之后再 start/pause 会抛错 |
const fx = aura.fire('#card')
fx.pause()
fx.start()
fx.dispose()
挂载
| API | 挂到哪 | 定位 |
|---|---|---|
glow |
target 内部 | absolute; inset: 0 |
border |
container → 非 body parent → document.body
|
容器内 absolute,否则 fixed,外扩 glowPadding
|
fire / burning |
container 或 document.body
|
铺满容器或视口,粒子沿 target 边框 |
thunder |
container 或 document.body
|
铺满容器或视口,雷电沿 target 轮廓 |
void |
container 或 document.body
|
铺满容器或视口,黑洞光带沿 target 轮廓 |
glitch |
container 或 document.body
|
铺满容器或视口,故障光带沿 target 轮廓 |
shape / water / cultivation / demonic |
container 或 document.body
|
铺满容器或视口,灵气沿 target 轮廓 |
aura.border('#card', { container: '#stage' })
aura.fire('#card', { container: '#stage' })
aura.shape('#card', { container: '#stage' })
aura.void('#hole', { container: '#stage' })
aura.glitch('#crash', { container: '#stage' })
border / fire / burning / thunder /
shape / water / cultivation / demonic /
void / glitch 在 overflow / transform /
滚动容器里必须传 container。
aura.glow
流光遮罩。canvas 插在 target 里面。暗底用 mode: 'dark'。
aura.glow('#hero', {
mode: 'dark',
borderRadius: 16,
borderWidth: 6,
glowWidth: 140,
})
| 字段 | 默认 | 说明 |
|---|---|---|
mode |
'light' |
'dark' | 'light',没有两全样式 |
colors |
蓝 / 紫 / 橙 / 黄 | 必须 4 个 rgb(r, g, b) |
borderWidth |
8 |
实线边宽 |
glowWidth |
200 |
光晕宽 |
borderRadius |
8 |
圆角 |
ratio |
DPR | 可 < 1 降分辨率 |
额外方法:resize、autoResize、fadeIn() /
fadeOut()(300ms Promise)。内部约 32fps。没有 container。
aura.border
神经光场绕圆角边框流动。
aura.border('#neural-card', {
container: '#neural-preview',
glowPadding: 64,
glowWidth: 90,
borderWidth: 2,
borderRadius: 22,
speed: 1.2,
})
| 字段 | 默认 | 说明 |
|---|---|---|
glowPadding |
110 |
canvas 相对 target 外扩 |
borderWidth |
2.2 |
光带宽度 |
glowWidth |
115 |
外溢宽度 |
borderRadius |
28 |
跟卡片圆角对齐 |
speed |
1 |
时间倍率 |
zIndex |
10 |
canvas 层级 |
setTarget / setContainer 可热切换跟随节点。
aura.fire
火焰沿边框烧。内部强制无烟、无热浪。
aura.fire('#fire-card', {
container: '#fire-preview',
particleCount: 800,
})
| 字段 | 默认 | 说明 |
|---|---|---|
particleCount |
1300 |
越大越密、越吃 GPU |
padding |
1 |
边框采样内缩 |
zIndex |
10 |
|
onFrame |
— | (time: number) => void,秒 |
aura.burning
大火 + 烟雾 + 背景热浪。
aura.burning('#burn-card', {
container: '#burn-preview',
particleCount: 1800,
smokeCount: 300,
glow: true,
})
| 字段 | 默认 | 说明 |
|---|---|---|
particleCount |
2200 |
火焰粒子 |
smokeCount |
520 |
0 关烟 |
glow |
true |
背景热浪 |
padding |
2 |
边框采样内缩 |
笔记本建议把粒子降到 600–1000,烟 150–300。离屏 pause()。
aura.shape
形状感知 AI 光环。WebGL2 沿轮廓的有宽度 ribbon + 外层柔光 + 能量尘,自动跟随目标的
border-radius 和 clip-path。
const fx = aura.shape('#agent', {
container: '#stage',
offset: 5,
auraWidth: 33,
outerGlowWidth: 86,
dustCount: 75,
pathSamples: 500,
speed: 1,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
5 |
光带中心相对元素外扩的像素距离 |
auraWidth |
33 |
主光带半宽(像素) |
outerGlowWidth |
86 |
外层柔光半宽(像素) |
dustCount |
75 |
能量尘粒子数量 |
pathSamples |
500 |
轮廓采样点数 |
speed |
1 |
整体时间倍率 |
cornerSegments |
24 |
圆角采样分段数 |
aura.water
形状感知液态水流。SVG 扰动滤镜 + 高光折射 + 水珠,自动跟随
border-radius 和 clip-path。
const fx = aura.water('#agent', {
container: '#stage',
offset: 7,
fieldCount: 180,
detailCount: 110,
pathSamples: 420,
speed: 1,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
7 |
水流光圈相对元素外扩的像素距离 |
fieldCount |
180 |
外围水雾粒子数量 |
detailCount |
110 |
沿轮廓的水珠粒子数量 |
pathSamples |
420 |
轮廓采样点数 |
speed |
1 |
整体时间倍率 |
cornerSegments |
20 |
圆角采样分段数 |
aura.cultivation
形状感知金色修仙灵气。WebGL2 沿轮廓流转的金光脉 + 仙雾粒子 + 灵子,自动跟随
border-radius 和 clip-path。
const fx = aura.cultivation('#agent', {
container: '#stage',
offset: 7,
fieldCount: 180,
detailCount: 110,
pathSamples: 420,
speed: 1,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
7 |
灵气光圈相对元素外扩的像素距离 |
fieldCount |
180 |
外围仙雾粒子数量(fieldCount) |
detailCount |
110 |
沿轮廓奔走的灵子数量(detailCount) |
pathSamples |
420 |
轮廓采样点数 |
speed |
1 |
整体时间倍率 |
cornerSegments |
20 |
圆角采样分段数 |
aura.demonic
形状感知紫黑魔气。SVG 魔雾扰动 + 旋转魔气流 + 黑金高光 + 魔焰粒子 + 魔纹 + 裂隙 + 内层侵蚀,自动跟随
border-radius 和 clip-path。
const fx = aura.demonic('#agent', {
container: '#stage',
offset: 7,
fieldCount: 180,
detailCount: 110,
pathSamples: 420,
speed: 1,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
7 |
魔气光圈相对元素外扩的像素距离 |
fieldCount |
180 |
外围魔雾粒子数量 |
detailCount |
110 |
沿轮廓的魔焰粒子数量 |
pathSamples |
420 |
轮廓采样点数 |
speed |
1 |
整体时间倍率 |
cornerSegments |
20 |
圆角采样分段数 |
aura.thunder
形状感知雷劫电弧。WebGL2 沿轮廓游走的雷霆边框 + 能量粒子 + 随机外放电弧,自动跟随
border-radius 和 clip-path。
const fx = aura.thunder('#agent', {
container: '#stage',
offset: 8,
particleCount: 90,
maxBranches: 16,
branchInterval: 85,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
8 |
雷电光圈相对元素外扩的像素距离 |
particleCount |
90 |
沿轮廓奔走的能量粒子数量 |
maxBranches |
16 |
同时存在的最大外放电弧数 |
branchInterval |
85 |
外放电弧生成间隔(毫秒级基准) |
cornerSegments |
12 |
圆角采样分段数 |
aura.void
形状感知黑洞虚空。WebGL2 暗影光带 + 事件视界 + 紫白高光 + 虚空雾 + 星屑,自动跟随
border-radius 和 clip-path。
const fx = aura.void('#agent', {
container: '#stage',
offset: 6,
shadowWidth: 78,
horizonWidth: 30,
highlightWidth: 12,
mistCount: 190,
sparkCount: 95,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
6 |
光圈相对元素外扩的像素距离 |
shadowWidth |
78 |
暗影光带半宽(像素) |
horizonWidth |
30 |
事件视界光带半宽(像素) |
highlightWidth |
12 |
高光带半宽(像素) |
mistCount |
190 |
虚空雾粒子数量 |
sparkCount |
95 |
星屑粒子数量 |
pathSamples |
520 |
轮廓采样点数 |
speed |
1 |
整体时间倍率 |
cornerSegments |
24 |
圆角采样分段数 |
aura.glitch
形状感知故障崩坏。WebGL2 RGB 错位 + 数字撕裂 + 边缘断层 + 方形数据碎片,自动跟随
border-radius 和 clip-path。
const fx = aura.glitch('#agent', {
container: '#stage',
offset: 5,
outerWidth: 45,
rgbWidth: 11,
fragmentCount: 130,
})
| 字段 | 默认 | 说明 |
|---|---|---|
offset |
5 |
光圈相对元素外扩的像素距离 |
outerWidth |
45 |
外层噪声光带半宽(像素) |
rgbWidth |
11 |
RGB 错位光带半宽(像素) |
fragmentCount |
130 |
数据碎片数量 |
burstIntervalMin |
900 |
崩坏爆发最短间隔(毫秒) |
burstIntervalMax |
2600 |
崩坏爆发最长间隔(毫秒) |
burstDuration |
140 |
单次爆发持续时间(毫秒) |
pathSamples |
500 |
轮廓采样点数 |
speed |
1 |
整体时间倍率 |
cornerSegments |
22 |
圆角采样分段数 |
框架
// React
useEffect(() => {
const fx = aura.border(el)
return () => fx.dispose()
}, [])
// Vue 3
onMounted(() => { fx = aura.fire(card.value) })
onBeforeUnmount(() => fx?.dispose())
class 导出:Glow、MotionBorder、FireBorder、
BurningFire、ShapeAura、WaterAura、CultivationAura、DemonicAura、ThunderAura、VoidAura、GlitchAura。推荐使用
aura.* 或 X.attach()。