own-the-canvas 1.0.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/CHANGELOG.md +15 -0
- package/README.md +355 -0
- package/dist/components/AudioVisualizer/AudioVisualizer.d.ts +48 -0
- package/dist/components/AudioVisualizer/AudioVisualizer.stories.d.ts +10 -0
- package/dist/components/AudioVisualizer/index.d.ts +3 -0
- package/dist/components/AudioVisualizer/useAudioVisualizer.d.ts +25 -0
- package/dist/components/Boids/Boids.d.ts +43 -0
- package/dist/components/Boids/index.d.ts +2 -0
- package/dist/components/Boids/useBoids.d.ts +22 -0
- package/dist/components/ClothSimulation/ClothSimulation.d.ts +47 -0
- package/dist/components/ClothSimulation/index.d.ts +2 -0
- package/dist/components/ClothSimulation/useClothSimulation.d.ts +24 -0
- package/dist/components/Confetti/Confetti.d.ts +51 -0
- package/dist/components/Confetti/Confetti.stories.d.ts +10 -0
- package/dist/components/Confetti/index.d.ts +3 -0
- package/dist/components/Confetti/useConfetti.d.ts +25 -0
- package/dist/components/ConstellationMap/ConstellationMap.d.ts +42 -0
- package/dist/components/ConstellationMap/ConstellationMap.stories.d.ts +9 -0
- package/dist/components/ConstellationMap/index.d.ts +3 -0
- package/dist/components/ConstellationMap/useConstellationMap.d.ts +22 -0
- package/dist/components/FireEffect/FireEffect.d.ts +28 -0
- package/dist/components/FireEffect/FireEffect.stories.d.ts +10 -0
- package/dist/components/FireEffect/index.d.ts +3 -0
- package/dist/components/FireEffect/useFireEffect.d.ts +15 -0
- package/dist/components/Fireworks/Fireworks.d.ts +37 -0
- package/dist/components/Fireworks/index.d.ts +2 -0
- package/dist/components/Fireworks/useFireworks.d.ts +21 -0
- package/dist/components/FlowField/FlowField.d.ts +31 -0
- package/dist/components/FlowField/index.d.ts +2 -0
- package/dist/components/FlowField/useFlowField.d.ts +16 -0
- package/dist/components/FluidSimulation/FluidSimulation.d.ts +33 -0
- package/dist/components/FluidSimulation/index.d.ts +2 -0
- package/dist/components/FluidSimulation/useFluidSimulation.d.ts +17 -0
- package/dist/components/GameOfLife/GameOfLife.d.ts +30 -0
- package/dist/components/GameOfLife/index.d.ts +2 -0
- package/dist/components/GameOfLife/useGameOfLife.d.ts +21 -0
- package/dist/components/GlitchOverlay/GlitchOverlay.d.ts +35 -0
- package/dist/components/GlitchOverlay/index.d.ts +2 -0
- package/dist/components/GlitchOverlay/useGlitchOverlay.d.ts +18 -0
- package/dist/components/Lightning/Lightning.d.ts +37 -0
- package/dist/components/Lightning/index.d.ts +2 -0
- package/dist/components/Lightning/useLightning.d.ts +19 -0
- package/dist/components/LiveChart/LiveChart.d.ts +46 -0
- package/dist/components/LiveChart/index.d.ts +2 -0
- package/dist/components/LiveChart/useLiveChart.d.ts +31 -0
- package/dist/components/MagneticBlob/MagneticBlob.d.ts +35 -0
- package/dist/components/MagneticBlob/index.d.ts +2 -0
- package/dist/components/MagneticBlob/useMagneticBlob.d.ts +18 -0
- package/dist/components/Mandala/Mandala.d.ts +35 -0
- package/dist/components/Mandala/index.d.ts +2 -0
- package/dist/components/Mandala/useMandala.d.ts +18 -0
- package/dist/components/MatrixRain/MatrixRain.d.ts +22 -0
- package/dist/components/MatrixRain/MatrixRain.stories.d.ts +11 -0
- package/dist/components/MatrixRain/index.d.ts +3 -0
- package/dist/components/MatrixRain/useMatrixRain.d.ts +13 -0
- package/dist/components/NoiseGradient/NoiseGradient.d.ts +27 -0
- package/dist/components/NoiseGradient/NoiseGradient.stories.d.ts +9 -0
- package/dist/components/NoiseGradient/index.d.ts +2 -0
- package/dist/components/NoiseGradient/useNoiseGradient.d.ts +14 -0
- package/dist/components/ParticleField/ParticleField.d.ts +39 -0
- package/dist/components/ParticleField/ParticleField.stories.d.ts +9 -0
- package/dist/components/ParticleField/index.d.ts +2 -0
- package/dist/components/ParticleField/useParticleField.d.ts +20 -0
- package/dist/components/PixelDissolve/PixelDissolve.d.ts +25 -0
- package/dist/components/PixelDissolve/PixelDissolve.stories.d.ts +8 -0
- package/dist/components/PixelDissolve/index.d.ts +3 -0
- package/dist/components/PixelDissolve/usePixelDissolve.d.ts +15 -0
- package/dist/components/Rain/Rain.d.ts +31 -0
- package/dist/components/Rain/index.d.ts +2 -0
- package/dist/components/Rain/useRain.d.ts +16 -0
- package/dist/components/RippleEffect/RippleEffect.d.ts +33 -0
- package/dist/components/RippleEffect/RippleEffect.stories.d.ts +7 -0
- package/dist/components/RippleEffect/index.d.ts +2 -0
- package/dist/components/RippleEffect/useRippleEffect.d.ts +17 -0
- package/dist/components/Shockwave/Shockwave.d.ts +35 -0
- package/dist/components/Shockwave/index.d.ts +2 -0
- package/dist/components/Shockwave/useShockwave.d.ts +20 -0
- package/dist/components/Spotlight/Spotlight.d.ts +37 -0
- package/dist/components/Spotlight/index.d.ts +2 -0
- package/dist/components/Spotlight/useSpotlight.d.ts +19 -0
- package/dist/components/Starfield/Starfield.d.ts +40 -0
- package/dist/components/Starfield/Starfield.stories.d.ts +9 -0
- package/dist/components/Starfield/index.d.ts +3 -0
- package/dist/components/Starfield/useStarfield.d.ts +21 -0
- package/dist/components/Wormhole/Wormhole.d.ts +33 -0
- package/dist/components/Wormhole/index.d.ts +2 -0
- package/dist/components/Wormhole/useWormhole.d.ts +17 -0
- package/dist/hooks/useCanvasSetup.d.ts +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.es.js +4619 -0
- package/dist/types/index.d.ts +28 -0
- package/package.json +68 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [1.0.0] - 2026-05-17
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
Initial release with 26 canvas-based React components:
|
|
10
|
+
|
|
11
|
+
- AudioVisualizer, Boids, ClothSimulation, Confetti, ConstellationMap
|
|
12
|
+
- FireEffect, Fireworks, FlowField, FluidSimulation, GameOfLife
|
|
13
|
+
- GlitchOverlay, Lightning, LiveChart, MagneticBlob, Mandala
|
|
14
|
+
- MatrixRain, NoiseGradient, ParticleField, PixelDissolve, Rain
|
|
15
|
+
- RippleEffect, Shockwave, Spotlight, Starfield, Wormhole
|
package/README.md
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
# own-the-canvas
|
|
2
|
+
|
|
3
|
+
> Beautiful, responsive, fully customizable HTML canvas–based React visual components. Zero dependencies. TypeScript. 60fps.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install own-the-canvas
|
|
11
|
+
# or
|
|
12
|
+
pnpm add own-the-canvas
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
> **Peer deps:** React 18+
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { MatrixRain, ParticleField, Starfield } from 'own-the-canvas';
|
|
23
|
+
|
|
24
|
+
export default function App() {
|
|
25
|
+
return (
|
|
26
|
+
<div style={{ width: '100vw', height: '100vh' }}>
|
|
27
|
+
<MatrixRain color="#00ff41" glowEffect />
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
All components default to `width: "100%"` and `height: "100%"` so they fill their parent.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Components
|
|
38
|
+
|
|
39
|
+
### MatrixRain
|
|
40
|
+
|
|
41
|
+
Classic falling character rain effect.
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { MatrixRain } from 'own-the-canvas';
|
|
47
|
+
|
|
48
|
+
<MatrixRain
|
|
49
|
+
color="#00ff41"
|
|
50
|
+
fontSize={16}
|
|
51
|
+
speed={1}
|
|
52
|
+
charset="katakana"
|
|
53
|
+
glowEffect
|
|
54
|
+
/>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
| Prop | Type | Default | Description |
|
|
58
|
+
|------|------|---------|-------------|
|
|
59
|
+
| `color` | `string` | `"#00ff41"` | Character color |
|
|
60
|
+
| `backgroundColor` | `string` | `"rgba(0,0,0,0.05)"` | Canvas background (use rgba for trail) |
|
|
61
|
+
| `fontSize` | `number` | `16` | Character font size in px |
|
|
62
|
+
| `speed` | `number` | `1` | Fall speed multiplier |
|
|
63
|
+
| `charset` | `"katakana" \| "latin" \| "binary" \| string` | `"katakana"` | Character set |
|
|
64
|
+
| `density` | `number` | `0.85` | Column density 0–1 |
|
|
65
|
+
| `fadeStrength` | `number` | `0.05` | Trail fade 0–1 |
|
|
66
|
+
| `glowEffect` | `boolean` | `true` | Neon glow |
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### ParticleField
|
|
71
|
+
|
|
72
|
+
Floating particles with optional connections and mouse repulsion.
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
```tsx
|
|
77
|
+
import { ParticleField } from 'own-the-canvas';
|
|
78
|
+
|
|
79
|
+
<ParticleField
|
|
80
|
+
particleCount={120}
|
|
81
|
+
particleColor="#7eb8f7"
|
|
82
|
+
connectParticles
|
|
83
|
+
interactive
|
|
84
|
+
/>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
| Prop | Type | Default | Description |
|
|
88
|
+
|------|------|---------|-------------|
|
|
89
|
+
| `particleCount` | `number` | `120` | Number of particles |
|
|
90
|
+
| `particleColor` | `string` | `"#7eb8f7"` | Particle fill color |
|
|
91
|
+
| `lineColor` | `string` | `"#7eb8f7"` | Connection line color |
|
|
92
|
+
| `lineDistance` | `number` | `120` | Max distance for lines |
|
|
93
|
+
| `particleSize` | `number` | `2.5` | Max particle radius |
|
|
94
|
+
| `speed` | `number` | `0.8` | Movement speed |
|
|
95
|
+
| `connectParticles` | `boolean` | `true` | Draw lines between close particles |
|
|
96
|
+
| `interactive` | `boolean` | `true` | Repel on mouse move |
|
|
97
|
+
| `backgroundColor` | `string` | `"transparent"` | Background color |
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### Starfield
|
|
102
|
+
|
|
103
|
+
2D twinkle or 3D warp tunnel starfield.
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { Starfield } from 'own-the-canvas';
|
|
109
|
+
|
|
110
|
+
<Starfield
|
|
111
|
+
starCount={200}
|
|
112
|
+
perspective="3D"
|
|
113
|
+
speed={2}
|
|
114
|
+
shootingStars
|
|
115
|
+
/>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Prop | Type | Default | Description |
|
|
119
|
+
|------|------|---------|-------------|
|
|
120
|
+
| `starCount` | `number` | `200` | Number of stars |
|
|
121
|
+
| `starColor` | `string` | `"#ffffff"` | Star color |
|
|
122
|
+
| `backgroundColor` | `string` | `"#000010"` | Background |
|
|
123
|
+
| `speed` | `number` | `0.5` | Movement speed |
|
|
124
|
+
| `twinkle` | `boolean` | `true` | Twinkle effect |
|
|
125
|
+
| `shootingStars` | `boolean` | `true` | Shooting stars |
|
|
126
|
+
| `shootingStarInterval` | `number` | `3000` | Ms between shooting stars |
|
|
127
|
+
| `perspective` | `"2D" \| "3D"` | `"2D"` | Flat or warp tunnel |
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
### FireEffect
|
|
132
|
+
|
|
133
|
+
Pixel-level fire simulation with multiple palettes.
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { FireEffect } from 'own-the-canvas';
|
|
139
|
+
|
|
140
|
+
<FireEffect palette="inferno" intensity={0.95} />
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
| Prop | Type | Default | Description |
|
|
144
|
+
|------|------|---------|-------------|
|
|
145
|
+
| `palette` | `"inferno" \| "toxic" \| "ice" \| "plasma"` | `"inferno"` | Color theme |
|
|
146
|
+
| `intensity` | `number` | `0.95` | Flame intensity 0–1 |
|
|
147
|
+
| `windStrength` | `number` | `0.3` | Horizontal wind 0–1 |
|
|
148
|
+
| `windDirection` | `number` | `1` | 1 = right, -1 = left |
|
|
149
|
+
| `spread` | `number` | `0.7` | Flame spread 0–1 |
|
|
150
|
+
| `cooling` | `number` | `0.3` | Cooling rate 0–1 |
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### AudioVisualizer
|
|
155
|
+
|
|
156
|
+
Web Audio API visualizer with 4 modes.
|
|
157
|
+
|
|
158
|
+

|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { AudioVisualizer } from 'own-the-canvas';
|
|
162
|
+
|
|
163
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
164
|
+
|
|
165
|
+
<AudioVisualizer
|
|
166
|
+
audioSource={stream}
|
|
167
|
+
mode="bars"
|
|
168
|
+
barCount={64}
|
|
169
|
+
gradient
|
|
170
|
+
/>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
| Prop | Type | Default | Description |
|
|
174
|
+
|------|------|---------|-------------|
|
|
175
|
+
| `audioSource` | `MediaStream \| null` | `null` | Audio stream (shows idle anim when null) |
|
|
176
|
+
| `barCount` | `number` | `64` | Number of frequency bars |
|
|
177
|
+
| `barColor` | `string` | `"#00cfff"` | Bar fill color |
|
|
178
|
+
| `waveColor` | `string` | `"#00cfff"` | Wave stroke color |
|
|
179
|
+
| `mode` | `"bars" \| "wave" \| "circular" \| "mirror"` | `"bars"` | Visualization mode |
|
|
180
|
+
| `sensitivity` | `number` | `1` | Amplitude multiplier |
|
|
181
|
+
| `gapBetweenBars` | `number` | `2` | Gap between bars (px) |
|
|
182
|
+
| `rounded` | `boolean` | `true` | Rounded bar caps |
|
|
183
|
+
| `gradient` | `boolean` | `true` | Color gradient on bars |
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### Confetti
|
|
188
|
+
|
|
189
|
+
Burst or continuous confetti cannon.
|
|
190
|
+
|
|
191
|
+

|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
import { Confetti } from 'own-the-canvas';
|
|
195
|
+
const [fire, setFire] = useState(false);
|
|
196
|
+
|
|
197
|
+
<Confetti trigger={fire} particleCount={150} />
|
|
198
|
+
<button onClick={() => { setFire(false); setTimeout(() => setFire(true), 50); }}>
|
|
199
|
+
🎉
|
|
200
|
+
</button>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Prop | Type | Default | Description |
|
|
204
|
+
|------|------|---------|-------------|
|
|
205
|
+
| `trigger` | `boolean` | `false` | Rising edge fires a burst |
|
|
206
|
+
| `particleCount` | `number` | `150` | Pieces per burst |
|
|
207
|
+
| `spread` | `number` | `0.8` | Spread angle 0–1 |
|
|
208
|
+
| `gravity` | `number` | `0.5` | Gravity strength |
|
|
209
|
+
| `colors` | `string[]` | multi-color | Confetti colors |
|
|
210
|
+
| `shapes` | `ConfettiShape[]` | all shapes | Shapes to include |
|
|
211
|
+
| `duration` | `number` | `4000` | Piece lifetime (ms) |
|
|
212
|
+
| `continuous` | `boolean` | `false` | Trickle while trigger is true |
|
|
213
|
+
| `wind` | `number` | `0.5` | Horizontal wind |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
### RippleEffect
|
|
218
|
+
|
|
219
|
+
Expanding ring ripples on click or auto.
|
|
220
|
+
|
|
221
|
+

|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
import { RippleEffect } from 'own-the-canvas';
|
|
225
|
+
|
|
226
|
+
<RippleEffect color="#00cfff" maxRadius={150} interactive />
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
| Prop | Type | Default | Description |
|
|
230
|
+
|------|------|---------|-------------|
|
|
231
|
+
| `color` | `string` | `"#00cfff"` | Ring stroke color |
|
|
232
|
+
| `maxRadius` | `number` | `150` | Max ring radius |
|
|
233
|
+
| `speed` | `number` | `2` | Expansion speed |
|
|
234
|
+
| `lineWidth` | `number` | `1.5` | Stroke width |
|
|
235
|
+
| `decay` | `number` | `0.8` | Opacity decay rate |
|
|
236
|
+
| `multiRipple` | `boolean` | `true` | Allow multiple simultaneous ripples |
|
|
237
|
+
| `backgroundColor` | `string` | `"transparent"` | Canvas background |
|
|
238
|
+
| `interactive` | `boolean` | `true` | Spawn ripple on click |
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### NoiseGradient
|
|
243
|
+
|
|
244
|
+
Animated Perlin noise–driven color gradient.
|
|
245
|
+
|
|
246
|
+

|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { NoiseGradient } from 'own-the-canvas';
|
|
250
|
+
|
|
251
|
+
<NoiseGradient
|
|
252
|
+
colors={["#0d0221", "#2d1b69", "#11998e", "#38ef7d"]}
|
|
253
|
+
speed={0.3}
|
|
254
|
+
octaves={3}
|
|
255
|
+
animated
|
|
256
|
+
/>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
| Prop | Type | Default | Description |
|
|
260
|
+
|------|------|---------|-------------|
|
|
261
|
+
| `colors` | `string[]` | deep space | 2–5 hex gradient stops |
|
|
262
|
+
| `speed` | `number` | `0.3` | Animation speed |
|
|
263
|
+
| `scale` | `number` | `1` | Noise zoom level |
|
|
264
|
+
| `octaves` | `number` | `3` | Fractal detail 1–6 |
|
|
265
|
+
| `animated` | `boolean` | `true` | Enable animation |
|
|
266
|
+
| `blendMode` | `string` | `"source-over"` | Canvas composite mode |
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### PixelDissolve
|
|
271
|
+
|
|
272
|
+
Pixelated dissolve transition overlay for any React content.
|
|
273
|
+
|
|
274
|
+

|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
import { PixelDissolve } from 'own-the-canvas';
|
|
278
|
+
|
|
279
|
+
<PixelDissolve trigger={show} direction="out" pixelSize={8}>
|
|
280
|
+
<YourComponent />
|
|
281
|
+
</PixelDissolve>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
| Prop | Type | Default | Description |
|
|
285
|
+
|------|------|---------|-------------|
|
|
286
|
+
| `children` | `ReactNode` | — | Content to dissolve over |
|
|
287
|
+
| `pixelSize` | `number` | `8` | Block size in px |
|
|
288
|
+
| `speed` | `number` | `0.5` | Animation speed 0–2 |
|
|
289
|
+
| `direction` | `"in" \| "out" \| "both"` | `"out"` | Dissolve direction |
|
|
290
|
+
| `trigger` | `boolean` | `false` | Rising edge triggers animation |
|
|
291
|
+
| `color` | `string` | `"#0a0a0a"` | Pixel fill color |
|
|
292
|
+
| `onComplete` | `() => void` | — | Called when animation finishes |
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### ConstellationMap
|
|
297
|
+
|
|
298
|
+
Draggable star constellation with animated connections.
|
|
299
|
+
|
|
300
|
+

|
|
301
|
+
|
|
302
|
+
```tsx
|
|
303
|
+
import { ConstellationMap } from 'own-the-canvas';
|
|
304
|
+
|
|
305
|
+
<ConstellationMap
|
|
306
|
+
starCount={80}
|
|
307
|
+
lineColor="#8888ff"
|
|
308
|
+
interactive
|
|
309
|
+
glowStars
|
|
310
|
+
/>
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
| Prop | Type | Default | Description |
|
|
314
|
+
|------|------|---------|-------------|
|
|
315
|
+
| `starCount` | `number` | `80` | Number of stars |
|
|
316
|
+
| `starColor` | `string` | `"#ffffff"` | Star color |
|
|
317
|
+
| `lineColor` | `string` | `"#8888ff"` | Connection line color |
|
|
318
|
+
| `backgroundColor` | `string` | `"#050510"` | Background |
|
|
319
|
+
| `speed` | `number` | `0.3` | Star drift speed |
|
|
320
|
+
| `interactive` | `boolean` | `true` | Drag stars with mouse |
|
|
321
|
+
| `lineStyle` | `"solid" \| "dashed"` | `"solid"` | Line style |
|
|
322
|
+
| `glowStars` | `boolean` | `true` | Glow on stars |
|
|
323
|
+
| `connectionDistance` | `number` | `100` | Max distance for lines |
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## Base Props (all components)
|
|
328
|
+
|
|
329
|
+
Every component accepts these:
|
|
330
|
+
|
|
331
|
+
| Prop | Type | Default |
|
|
332
|
+
|------|------|---------|
|
|
333
|
+
| `width` | `number \| string` | `"100%"` |
|
|
334
|
+
| `height` | `number \| string` | `"100%"` |
|
|
335
|
+
| `className` | `string` | — |
|
|
336
|
+
| `style` | `React.CSSProperties` | — |
|
|
337
|
+
|
|
338
|
+
All components use `forwardRef` — the ref is forwarded to the underlying `<canvas>` element.
|
|
339
|
+
|
|
340
|
+
---
|
|
341
|
+
|
|
342
|
+
## Tree-shaking
|
|
343
|
+
|
|
344
|
+
Import only what you use:
|
|
345
|
+
|
|
346
|
+
```tsx
|
|
347
|
+
import { MatrixRain } from 'own-the-canvas'; // ✓ only MatrixRain bundled
|
|
348
|
+
import { ParticleField } from 'own-the-canvas'; // ✓ only ParticleField bundled
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## License
|
|
354
|
+
|
|
355
|
+
MIT
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { BaseCanvasProps } from '../../types';
|
|
2
|
+
import { VisualizerMode } from './useAudioVisualizer';
|
|
3
|
+
|
|
4
|
+
type AudioVisualizerPreset = "default" | "neon" | "minimal" | "fire" | "ocean";
|
|
5
|
+
export interface AudioVisualizerProps extends BaseCanvasProps {
|
|
6
|
+
/** MediaStream from getUserMedia (default: null — shows idle animation) */
|
|
7
|
+
audioSource?: MediaStream | null;
|
|
8
|
+
/** Number of frequency bars (default: 64) */
|
|
9
|
+
barCount?: number;
|
|
10
|
+
/** Bar fill color (default: "#00cfff") */
|
|
11
|
+
barColor?: string;
|
|
12
|
+
/** Wave stroke color (default: "#00cfff") */
|
|
13
|
+
waveColor?: string;
|
|
14
|
+
/** Visualization mode (default: "bars") */
|
|
15
|
+
mode?: VisualizerMode;
|
|
16
|
+
/** Amplitude sensitivity multiplier (default: 1) */
|
|
17
|
+
sensitivity?: number;
|
|
18
|
+
/** Gap between bars in px (default: 2) */
|
|
19
|
+
gapBetweenBars?: number;
|
|
20
|
+
/** Rounded bar caps (default: true) */
|
|
21
|
+
rounded?: boolean;
|
|
22
|
+
/** Color gradient on bars/wave (default: true) */
|
|
23
|
+
gradient?: boolean;
|
|
24
|
+
/** Gradient top/end color (default: "#ffffff") */
|
|
25
|
+
gradientEndColor?: string;
|
|
26
|
+
/** Canvas background color (default: "transparent") */
|
|
27
|
+
backgroundColor?: string;
|
|
28
|
+
/** Enable glow effect (default: true) */
|
|
29
|
+
glowEffect?: boolean;
|
|
30
|
+
/** Glow color — defaults to barColor */
|
|
31
|
+
glowColor?: string;
|
|
32
|
+
/** Glow blur radius in px (default: 12) */
|
|
33
|
+
glowBlur?: number;
|
|
34
|
+
/** Web Audio FFT size — must be power of 2 (default: 2048) */
|
|
35
|
+
fftSize?: number;
|
|
36
|
+
/** Analyser smoothing time constant 0–1 (default: 0.8) */
|
|
37
|
+
smoothingTimeConstant?: number;
|
|
38
|
+
/** Circular mode inner radius as fraction of min(w,h) (default: 0.25) */
|
|
39
|
+
circularRadiusRatio?: number;
|
|
40
|
+
/** Idle animation wave amplitude in px (default: 5) */
|
|
41
|
+
idleAmplitude?: number;
|
|
42
|
+
/** Idle animation speed multiplier (default: 1) */
|
|
43
|
+
idleAnimationSpeed?: number;
|
|
44
|
+
/** Named preset: "default" | "neon" | "minimal" | "fire" | "ocean" */
|
|
45
|
+
preset?: AudioVisualizerPreset | string;
|
|
46
|
+
}
|
|
47
|
+
export declare const AudioVisualizer: import('react').ForwardRefExoticComponent<AudioVisualizerProps & import('react').RefAttributes<HTMLCanvasElement>>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { AudioVisualizer } from './AudioVisualizer';
|
|
3
|
+
|
|
4
|
+
declare const meta: Meta<typeof AudioVisualizer>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof AudioVisualizer>;
|
|
7
|
+
export declare const Bars: Story;
|
|
8
|
+
export declare const Wave: Story;
|
|
9
|
+
export declare const Circular: Story;
|
|
10
|
+
export declare const Mirror: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
export type VisualizerMode = "bars" | "wave" | "circular" | "mirror";
|
|
4
|
+
export interface UseAudioVisualizerOptions {
|
|
5
|
+
audioSource: MediaStream | null;
|
|
6
|
+
barCount: number;
|
|
7
|
+
barColor: string;
|
|
8
|
+
waveColor: string;
|
|
9
|
+
mode: VisualizerMode;
|
|
10
|
+
sensitivity: number;
|
|
11
|
+
gapBetweenBars: number;
|
|
12
|
+
rounded: boolean;
|
|
13
|
+
gradient: boolean;
|
|
14
|
+
gradientEndColor: string;
|
|
15
|
+
backgroundColor: string;
|
|
16
|
+
glowEffect: boolean;
|
|
17
|
+
glowColor: string;
|
|
18
|
+
glowBlur: number;
|
|
19
|
+
fftSize: number;
|
|
20
|
+
smoothingTimeConstant: number;
|
|
21
|
+
circularRadiusRatio: number;
|
|
22
|
+
idleAmplitude: number;
|
|
23
|
+
idleAnimationSpeed: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function useAudioVisualizer(canvasRef: RefObject<HTMLCanvasElement | null>, options: UseAudioVisualizerOptions): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { BaseCanvasProps } from '../../types';
|
|
2
|
+
|
|
3
|
+
type BoidsPreset = "default" | "birds" | "fish" | "swarm" | "neon";
|
|
4
|
+
export interface BoidsProps extends BaseCanvasProps {
|
|
5
|
+
/** Number of boids. (default: 80) */
|
|
6
|
+
count?: number;
|
|
7
|
+
/** Maximum speed in px/frame. (default: 3) */
|
|
8
|
+
maxSpeed?: number;
|
|
9
|
+
/** Radius for separation rule in px. (default: 25) */
|
|
10
|
+
separationRadius?: number;
|
|
11
|
+
/** Radius for alignment rule in px. (default: 50) */
|
|
12
|
+
alignmentRadius?: number;
|
|
13
|
+
/** Radius for cohesion rule in px. (default: 60) */
|
|
14
|
+
cohesionRadius?: number;
|
|
15
|
+
/** Separation steering force. (default: 0.05) */
|
|
16
|
+
separationForce?: number;
|
|
17
|
+
/** Alignment steering force. (default: 0.05) */
|
|
18
|
+
alignmentForce?: number;
|
|
19
|
+
/** Cohesion steering force. (default: 0.03) */
|
|
20
|
+
cohesionForce?: number;
|
|
21
|
+
/** Boid and trail color. (default: "#7C3AED") */
|
|
22
|
+
color?: string;
|
|
23
|
+
/** Trail history length in frames. (default: 8) */
|
|
24
|
+
trailLength?: number;
|
|
25
|
+
/** Trail line opacity 0–1. (default: 0.4) */
|
|
26
|
+
trailOpacity?: number;
|
|
27
|
+
/** Boid triangle size in px. (default: 6) */
|
|
28
|
+
boidSize?: number;
|
|
29
|
+
/** Canvas background color. (default: "#050010") */
|
|
30
|
+
backgroundColor?: string;
|
|
31
|
+
/** Boids flee from mouse cursor. (default: true) */
|
|
32
|
+
interactive?: boolean;
|
|
33
|
+
/** Mouse avoidance radius in px. (default: 80) */
|
|
34
|
+
mouseRadius?: number;
|
|
35
|
+
/** Mouse avoidance force. (default: 0.2) */
|
|
36
|
+
mouseForce?: number;
|
|
37
|
+
/** Wrap boids at canvas edges. (default: true) */
|
|
38
|
+
wrapEdges?: boolean;
|
|
39
|
+
/** Named preset. */
|
|
40
|
+
preset?: BoidsPreset | string;
|
|
41
|
+
}
|
|
42
|
+
export declare const Boids: import('react').ForwardRefExoticComponent<BoidsProps & import('react').RefAttributes<HTMLCanvasElement>>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface UseBoidsOptions {
|
|
4
|
+
count: number;
|
|
5
|
+
maxSpeed: number;
|
|
6
|
+
separationRadius: number;
|
|
7
|
+
alignmentRadius: number;
|
|
8
|
+
cohesionRadius: number;
|
|
9
|
+
separationForce: number;
|
|
10
|
+
alignmentForce: number;
|
|
11
|
+
cohesionForce: number;
|
|
12
|
+
color: string;
|
|
13
|
+
trailLength: number;
|
|
14
|
+
trailOpacity: number;
|
|
15
|
+
boidSize: number;
|
|
16
|
+
backgroundColor: string;
|
|
17
|
+
interactive: boolean;
|
|
18
|
+
mouseRadius: number;
|
|
19
|
+
mouseForce: number;
|
|
20
|
+
wrapEdges: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function useBoids(canvasRef: RefObject<HTMLCanvasElement | null>, options: UseBoidsOptions): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseCanvasProps } from '../../types';
|
|
2
|
+
|
|
3
|
+
type ClothPreset = "default" | "silk" | "net" | "heavy" | "spider";
|
|
4
|
+
export interface ClothSimulationProps extends BaseCanvasProps {
|
|
5
|
+
/** Grid columns (default: 25) */
|
|
6
|
+
cols?: number;
|
|
7
|
+
/** Grid rows (default: 20) */
|
|
8
|
+
rows?: number;
|
|
9
|
+
/** Point spacing in px (default: 18) */
|
|
10
|
+
spacing?: number;
|
|
11
|
+
/** Gravity per frame (default: 0.4) */
|
|
12
|
+
gravity?: number;
|
|
13
|
+
/** Velocity friction 0–1 (default: 0.99) */
|
|
14
|
+
friction?: number;
|
|
15
|
+
/** Constraint stiffness 0–1 (default: 1) */
|
|
16
|
+
stiffness?: number;
|
|
17
|
+
/** Relaxation iterations per frame (default: 3) */
|
|
18
|
+
iterations?: number;
|
|
19
|
+
/** Cloth mesh color (default: "#7C3AED") */
|
|
20
|
+
lineColor?: string;
|
|
21
|
+
/** Pin point color (default: "#ffffff") */
|
|
22
|
+
pinColor?: string;
|
|
23
|
+
/** Mesh stroke width (default: 1) */
|
|
24
|
+
lineWidth?: number;
|
|
25
|
+
/** Canvas background (default: "#050010") */
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
/** Wind oscillation amplitude (default: 0.3) */
|
|
28
|
+
wind?: number;
|
|
29
|
+
/** Wind oscillation frequency (default: 0.5) */
|
|
30
|
+
windSpeed?: number;
|
|
31
|
+
/** Enable cloth tearing on drag (default: false) */
|
|
32
|
+
tearable?: boolean;
|
|
33
|
+
/** Tear multiplier — ratio above rest length that tears constraint (default: 3) */
|
|
34
|
+
tearDistance?: number;
|
|
35
|
+
/** Enable mouse interaction (default: true) */
|
|
36
|
+
interactive?: boolean;
|
|
37
|
+
/** Mouse influence radius in px (default: 30) */
|
|
38
|
+
mouseRadius?: number;
|
|
39
|
+
/** Mouse push force (default: 5) */
|
|
40
|
+
mouseForce?: number;
|
|
41
|
+
/** Show pin points at top (default: true) */
|
|
42
|
+
showPins?: boolean;
|
|
43
|
+
/** Named preset */
|
|
44
|
+
preset?: ClothPreset | string;
|
|
45
|
+
}
|
|
46
|
+
export declare const ClothSimulation: import('react').ForwardRefExoticComponent<ClothSimulationProps & import('react').RefAttributes<HTMLCanvasElement>>;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface UseClothSimulationOptions {
|
|
4
|
+
cols: number;
|
|
5
|
+
rows: number;
|
|
6
|
+
spacing: number;
|
|
7
|
+
gravity: number;
|
|
8
|
+
friction: number;
|
|
9
|
+
stiffness: number;
|
|
10
|
+
iterations: number;
|
|
11
|
+
lineColor: string;
|
|
12
|
+
pinColor: string;
|
|
13
|
+
lineWidth: number;
|
|
14
|
+
backgroundColor: string;
|
|
15
|
+
wind: number;
|
|
16
|
+
windSpeed: number;
|
|
17
|
+
tearable: boolean;
|
|
18
|
+
tearDistance: number;
|
|
19
|
+
interactive: boolean;
|
|
20
|
+
mouseRadius: number;
|
|
21
|
+
mouseForce: number;
|
|
22
|
+
showPins: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function useClothSimulation(canvasRef: RefObject<HTMLCanvasElement | null>, options: UseClothSimulationOptions): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseCanvasProps } from '../../types';
|
|
2
|
+
import { ConfettiShape } from './useConfetti';
|
|
3
|
+
|
|
4
|
+
export type ConfettiPalette = "monochrome" | "colorful";
|
|
5
|
+
type ConfettiPreset = "default" | "celebration" | "pastel" | "gold";
|
|
6
|
+
export interface ConfettiProps extends BaseCanvasProps {
|
|
7
|
+
/** Color variant: "monochrome" (default) or "colorful" */
|
|
8
|
+
palette?: ConfettiPalette;
|
|
9
|
+
/** Rising edge fires a burst (default: false) */
|
|
10
|
+
trigger?: boolean;
|
|
11
|
+
/** Number of pieces per burst (default: 150) */
|
|
12
|
+
particleCount?: number;
|
|
13
|
+
/** Spread angle 0–1 where 1 = full hemisphere (default: 0.8) */
|
|
14
|
+
spread?: number;
|
|
15
|
+
/** Gravity strength (default: 0.5) */
|
|
16
|
+
gravity?: number;
|
|
17
|
+
/** Override confetti colors directly (overrides palette) */
|
|
18
|
+
colors?: string[];
|
|
19
|
+
/** Shapes to include (default: all) */
|
|
20
|
+
shapes?: ConfettiShape[];
|
|
21
|
+
/** Duration of each piece in ms (default: 4000) */
|
|
22
|
+
duration?: number;
|
|
23
|
+
/** Emit continuously while trigger is true (default: false) */
|
|
24
|
+
continuous?: boolean;
|
|
25
|
+
/** Horizontal wind force (default: 0.5) */
|
|
26
|
+
wind?: number;
|
|
27
|
+
/** Spawn X position as fraction of canvas width (default: 0.5) */
|
|
28
|
+
spawnX?: number;
|
|
29
|
+
/** Spawn Y position as fraction of canvas height (default: 0.4) */
|
|
30
|
+
spawnY?: number;
|
|
31
|
+
/** Spawn position random spread in px (default: 60) */
|
|
32
|
+
spawnSpread?: number;
|
|
33
|
+
/** Minimum piece launch speed (default: 4) */
|
|
34
|
+
speedMin?: number;
|
|
35
|
+
/** Maximum piece launch speed (default: 16) */
|
|
36
|
+
speedMax?: number;
|
|
37
|
+
/** Minimum piece size in px (default: 6) */
|
|
38
|
+
sizeMin?: number;
|
|
39
|
+
/** Maximum piece size in px (default: 14) */
|
|
40
|
+
sizeMax?: number;
|
|
41
|
+
/** Max angular velocity per frame (default: 0.3) */
|
|
42
|
+
angularVelocity?: number;
|
|
43
|
+
/** Pieces per second in continuous mode (default: 10) */
|
|
44
|
+
emissionRate?: number;
|
|
45
|
+
/** Called when animation finishes */
|
|
46
|
+
onComplete?: () => void;
|
|
47
|
+
/** Named preset: "default" | "celebration" | "pastel" | "gold" */
|
|
48
|
+
preset?: ConfettiPreset | string;
|
|
49
|
+
}
|
|
50
|
+
export declare const Confetti: import('react').ForwardRefExoticComponent<ConfettiProps & import('react').RefAttributes<HTMLCanvasElement>>;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Confetti } from './Confetti';
|
|
3
|
+
|
|
4
|
+
declare const meta: Meta<typeof Confetti>;
|
|
5
|
+
export default meta;
|
|
6
|
+
type Story = StoryObj<typeof Confetti>;
|
|
7
|
+
export declare const Default: Story;
|
|
8
|
+
export declare const Colorful: Story;
|
|
9
|
+
export declare const Celebration: Story;
|
|
10
|
+
export declare const Continuous: Story;
|