@diabolic/borealis 1.0.2 → 1.0.4

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/README.md CHANGED
@@ -1,511 +1,518 @@
1
- # Borealis
2
-
3
- An interactive, animated canvas background with noise-based patterns and visual effects.
4
-
5
- [![npm version](https://badge.fury.io/js/@diabolic%2Fborealis.svg)](https://www.npmjs.com/package/@diabolic/borealis)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
-
8
- > đŸŽŦ [Live Demo](https://bugrakaan.github.io/borealis/)
9
-
10
- ## Features
11
-
12
- - ✨ **Multiple effects** - Wave, twinkle, and noise-based patterns with domain warping
13
- - 🌈 **Aurora colors** - Customizable gradient color schemes
14
- - đŸŽ¯ **Animations** - Smooth radial collapse/expand show/hide transitions
15
- - ⚡ **Highly customizable** - 40+ configurable options
16
- - 📱 **Responsive** - Automatically adapts to container or window size
17
- - đŸĒļ **Lightweight** - No dependencies, pure JavaScript
18
- - đŸ“Ļ **TypeScript support** - Full type definitions included
19
-
20
- ## Installation
21
-
22
- ### npm
23
-
24
- ```bash
25
- npm install @diabolic/borealis
26
- ```
27
-
28
- ### yarn
29
-
30
- ```bash
31
- yarn add @diabolic/borealis
32
- ```
33
-
34
- ### pnpm
35
-
36
- ```bash
37
- pnpm add @diabolic/borealis
38
- ```
39
-
40
- ### CDN
41
-
42
- ```html
43
- <!-- UMD (Global variable) -->
44
- <script src="https://unpkg.com/@diabolic/borealis/dist/borealis.min.js"></script>
45
-
46
- <!-- Or from jsDelivr -->
47
- <script src="https://cdn.jsdelivr.net/npm/@diabolic/borealis/dist/borealis.min.js"></script>
48
- ```
49
-
50
- ### Direct Script Include
51
-
52
- ```html
53
- <script src="borealis.js"></script>
54
- ```
55
-
56
- ## Quick Start
57
-
58
- ### ES Module
59
-
60
- ```javascript
61
- import Borealis from '@diabolic/borealis';
62
-
63
- // Create with default options (fullscreen)
64
- const borealis = new Borealis();
65
-
66
- // Create with custom options
67
- const borealis = new Borealis({
68
- effect: {
69
- type: 'twinkle',
70
- aurora: true
71
- },
72
- patternAurora: true,
73
- density: 70
74
- });
75
- ```
76
-
77
- ### Target a Specific Container
78
-
79
- ```javascript
80
- // Render inside a specific element
81
- const borealis = new Borealis({
82
- container: document.getElementById('my-container'),
83
- fullscreen: false // Use container dimensions instead of viewport
84
- });
85
-
86
- // With explicit dimensions
87
- const borealis = new Borealis({
88
- container: document.getElementById('hero-section'),
89
- fullscreen: false,
90
- width: 800,
91
- height: 400
92
- });
93
- ```
94
-
95
- ### CommonJS
96
-
97
- ```javascript
98
- const Borealis = require('@diabolic/borealis');
99
-
100
- const borealis = new Borealis();
101
- ```
102
-
103
- ### Browser (UMD)
104
-
105
- ```html
106
- <script src="https://unpkg.com/@diabolic/borealis/dist/borealis.min.js"></script>
107
- <script>
108
- const borealis = new Borealis({
109
- effect: { type: 'wave' }
110
- });
111
- </script>
112
- ```
113
-
114
- ## API Reference
115
-
116
- ### Constructor
117
-
118
- ```javascript
119
- new Borealis(options)
120
- ```
121
-
122
- Creates a new Borealis instance with the specified options.
123
-
124
- ### Methods
125
-
126
- #### `start()`
127
- Start the animation loop.
128
-
129
- ```javascript
130
- borealis.start();
131
- ```
132
-
133
- #### `stop()`
134
- Stop the animation loop.
135
-
136
- ```javascript
137
- borealis.stop();
138
- ```
139
-
140
- #### `resize([width], [height])`
141
- Manually trigger a resize. Useful when container size changes.
142
-
143
- ```javascript
144
- // Resize to specific dimensions
145
- borealis.resize(800, 600);
146
-
147
- // Resize using current container dimensions
148
- borealis.resize();
149
- ```
150
-
151
- #### `redraw()`
152
- Force a single frame redraw. Useful when animation is stopped but you want to update the display.
153
-
154
- ```javascript
155
- borealis.stop();
156
- borealis.setOption('patternAurora', true);
157
- borealis.redraw(); // Update display without starting animation
158
- ```
159
-
160
- #### `show([callback])`
161
- Expand the pattern from center (reverse collapse).
162
-
163
- ```javascript
164
- borealis.show(() => {
165
- console.log('Pattern is now visible');
166
- });
167
- ```
168
-
169
- #### `hide([callback])`
170
- Collapse the pattern to center.
171
-
172
- ```javascript
173
- borealis.hide(() => {
174
- console.log('Pattern is now hidden');
175
- });
176
- ```
177
-
178
-
179
- #### `toggle([callback])`
180
- Toggle between show and hide states.
181
-
182
- ```javascript
183
- borealis.toggle();
184
- ```
185
-
186
- #### `isVisible()`
187
- Returns `true` if the pattern is fully visible (not collapsed).
188
-
189
- ```javascript
190
- if (borealis.isVisible()) {
191
- console.log('Pattern is visible');
192
- }
193
- ```
194
-
195
- #### `isHidden()`
196
- Returns `true` if the pattern is fully hidden (collapsed).
197
-
198
- ```javascript
199
- if (borealis.isHidden()) {
200
- console.log('Pattern is hidden');
201
- }
202
- ```
203
-
204
- #### `setOption(key, value)`
205
- Set a single option value.
206
-
207
- ```javascript
208
- borealis.setOption('effect', 'twinkle');
209
- borealis.setOption('density', 80);
210
- ```
211
-
212
- #### `setOptions(options)`
213
- Set multiple options at once.
214
-
215
- ```javascript
216
- borealis.setOptions({
217
- effect: 'twinkle',
218
- patternAurora: true,
219
- twinkleSpeed: 70
220
- });
221
- ```
222
-
223
- #### `getOption(key)`
224
- Get a specific option value.
225
-
226
- ```javascript
227
- const currentEffect = borealis.getOption('effect');
228
- ```
229
-
230
- #### `getOptions()`
231
- Get all current options.
232
-
233
- ```javascript
234
- const options = borealis.getOptions();
235
- ```
236
-
237
- #### `destroy()`
238
- Clean up and remove the canvas from DOM.
239
-
240
- ```javascript
241
- borealis.destroy();
242
- ```
243
-
244
- ## Options Reference
245
-
246
- ### Container Options
247
-
248
- | Option | Type | Default | Description |
249
- |--------|------|---------|-------------|
250
- | `container` | `HTMLElement` | `document.body` | Parent element for the canvas |
251
-
252
- ### Grid Options
253
-
254
- | Option | Type | Default | Description |
255
- |--------|------|---------|-------------|
256
- | `density` | `number` | `50` | Grid density (10-100). Higher = more dots |
257
- | `densityMinCell` | `number` | `2` | Minimum cell size at max density |
258
- | `densityMaxCell` | `number` | `8` | Maximum cell size at min density |
259
- | `dotSize` | `number` | `0` | Fixed dot size (0-10). 0 = noise-based size |
260
- | `solidPattern` | `boolean` | `false` | Use uniform solid dots instead of noise pattern |
261
- | `densityMinGap` | `number` | `1` | Minimum gap at max density |
262
- | `densityMaxGap` | `number` | `4` | Maximum gap at min density |
263
-
264
- ### Pattern Options
265
-
266
- | Option | Type | Default | Description |
267
- |--------|------|---------|-------------|
268
- | `patternScale` | `number` | `0.001` | Noise scale (smaller = larger patterns) |
269
- | `patternAurora` | `boolean` | `false` | Use aurora colors for base pattern |
270
- | `warpScale` | `number` | `0.5` | Domain warp frequency multiplier |
271
- | `warpAmount` | `number` | `20` | Domain warp intensity |
272
- | `animationSpeed` | `number` | `0.00002` | Base animation speed |
273
- | `ridgePower` | `number` | `2` | Ridge sharpness (higher = sharper lines) |
274
- | `minOpacity` | `number` | `0` | Minimum dot opacity (0-1) |
275
- | `maxOpacity` | `number` | `1` | Maximum dot opacity (0-1) |
276
- | `waveFrequency` | `number` | `3` | Wave oscillation frequency |
277
- | `waveAmplitude` | `number` | `0.5` | Wave intensity (0-1) |
278
-
279
- ### Effect Options
280
-
281
- | Option | Type | Default | Description |
282
- |--------|------|---------|-------------|
283
- | `effect` | `string` | `'wave'` | Effect type: `'none'`, `'wave'`, or `'twinkle'` |
284
- | `effectAurora` | `boolean` | `false` | Use aurora colors for effect |
285
- | `deadzone` | `number` | `0` | Effect dead zone around cursor (0-100) |
286
-
287
- ### Wave Effect Options
288
-
289
- | Option | Type | Default | Description |
290
- |--------|------|---------|-------------|
291
- | `waveSpeed` | `number` | `0.0008` | Diagonal wave speed |
292
- | `waveWidth` | `number` | `120` | Width of the wave band |
293
- | `waveChance` | `number` | `0.08` | Chance of a cell sparkling (0-1) |
294
- | `waveIntensity` | `number` | `1` | Maximum wave brightness |
295
- | `waveDelayMin` | `number` | `1000` | Minimum delay between waves (ms) |
296
- | `waveDelayMax` | `number` | `3000` | Maximum delay between waves (ms) |
297
- | `waveCombineSparkle` | `boolean` | `false` | Combine wave with sparkle effect |
298
- | `waveSparkleBaseOpacity` | `number` | `0.3` | Base opacity for combined sparkle (0-1) |
299
-
300
- ### Twinkle Effect Options
301
-
302
- | Option | Type | Default | Description |
303
- |--------|------|---------|-------------|
304
- | `twinkleSpeed` | `number` | `50` | Animation speed (10-100) |
305
- | `twinkleSize` | `number` | `50` | Pattern size (10-100, higher = larger groups) |
306
- | `twinkleDensity` | `number` | `50` | Star density (0-100, higher = more stars) |
307
- | `twinkleDeadzone` | `number` | `20` | Center dead zone size (0-50) |
308
- | `twinkleIntensity` | `number` | `1` | Maximum twinkle brightness |
309
- | `twinkleMode` | `string` | `'sparkle'` | Twinkle style: `'sparkle'` or `'wave'` |
310
- | `twinkleCombined` | `boolean` | `false` | Combine with base pattern |
311
- | `twinkleBaseOpacity` | `number` | `0.3` | Base opacity when combined (0-1) |
312
-
313
- ### Aurora Color Options
314
-
315
- | Option | Type | Default | Description |
316
- |--------|------|---------|-------------|
317
- | `auroraColor1` | `array` | `[0, 255, 128]` | First aurora color (RGB) - Cyan-green |
318
- | `auroraColor2` | `array` | `[148, 0, 211]` | Second aurora color (RGB) - Violet |
319
- | `colorScale` | `number` | `0.003` | Color variation scale |
320
-
321
- ### Collapse Options
322
-
323
- | Option | Type | Default | Description |
324
- |--------|------|---------|-------------|
325
- | `collapseSpeed` | `number` | `0.1` | Collapse/expand animation speed |
326
- | `collapseWaveWidth` | `number` | `0.4` | Width of the collapse transition |
327
-
328
- ### Animation Options
329
-
330
- | Option | Type | Default | Description |
331
- |--------|------|---------|-------------|
332
- | `animateOnHover` | `boolean` | `true` | Only animate when mouse is over document |
333
- | `autoStart` | `boolean` | `true` | Start animation automatically |
334
-
335
- ### Callback Options
336
-
337
- | Option | Type | Default | Description |
338
- |--------|------|---------|-------------|
339
- | `onShow` | `function` | `null` | Called when show animation completes |
340
- | `onHide` | `function` | `null` | Called when hide animation completes |
341
-
342
- ## Examples
343
-
344
- ### Basic Usage
345
-
346
- ```html
347
- <!DOCTYPE html>
348
- <html>
349
- <head>
350
- <style>
351
- body {
352
- margin: 0;
353
- min-height: 100vh;
354
- background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
355
- }
356
- </style>
357
- </head>
358
- <body>
359
- <script src="borealis.js"></script>
360
- <script>
361
- const borealis = new Borealis();
362
- </script>
363
- </body>
364
- </html>
365
- ```
366
-
367
- ### Twinkle Effect with Aurora Colors
368
-
369
- ```javascript
370
- const borealis = new Borealis({
371
- effect: 'twinkle',
372
- patternAurora: true,
373
- effectAurora: true,
374
- twinkleSpeed: 70,
375
- twinkleDensity: 60,
376
- twinkleDeadzone: 25
377
- });
378
- ```
379
-
380
- ### Show/Hide on Button Click
381
-
382
- ```javascript
383
- const borealis = new Borealis();
384
-
385
- document.getElementById('toggleBtn').addEventListener('click', () => {
386
- borealis.toggle(() => {
387
- console.log('Animation complete');
388
- });
389
- });
390
- ```
391
-
392
- ### Custom Aurora Colors
393
-
394
- ```javascript
395
- const borealis = new Borealis({
396
- patternAurora: true,
397
- auroraColor1: [255, 100, 100], // Pink
398
- auroraColor2: [100, 100, 255], // Blue
399
- });
400
- ```
401
-
402
- ### Programmatic Control
403
-
404
- ```javascript
405
- const borealis = new Borealis({ autoStart: false });
406
-
407
- // Start when ready
408
- setTimeout(() => {
409
- borealis.start();
410
- }, 1000);
411
-
412
- // Change effect dynamically
413
- borealis.setOption('effect', 'twinkle');
414
-
415
- // Hide and perform action
416
- borealis.hide(() => {
417
- // Navigate or perform other action
418
- window.location.href = '/next-page';
419
- });
420
- ```
421
-
422
- ### Inside a Specific Container
423
-
424
- ```javascript
425
- const container = document.getElementById('hero-section');
426
-
427
- const borealis = new Borealis({
428
- container: container,
429
- density: 60,
430
- effect: 'wave'
431
- });
432
- ```
433
-
434
- ## Browser Support
435
-
436
- - Chrome 60+
437
- - Firefox 55+
438
- - Safari 12+
439
- - Edge 79+
440
-
441
- ## Demo Page Features
442
-
443
- The included `index.html` demo page provides a comprehensive interface for testing and configuring Borealis:
444
-
445
- ### Settings Panel
446
-
447
- - **Two-column layout** - Organized controls for all options
448
- - **Live preview** - Changes apply instantly
449
- - **URL state persistence** - Settings are saved to URL parameters for easy sharing
450
- - **Copy Code button** - Generate JavaScript initialization code from current settings
451
-
452
- ### Recording Features
453
-
454
- The demo page includes WebM video recording capabilities:
455
-
456
- | Feature | Description |
457
- |---------|-------------|
458
- | **Format** | WebM with VP9 codec |
459
- | **Framerate** | 30 fps |
460
- | **Main Video Bitrate** | 5 Mbps |
461
- | **Alpha Mask Bitrate** | 3 Mbps |
462
- | **Resolutions** | 640×360, 854×480, 1280×720, 1440×900, 1920×1080, 2560×1440 |
463
- | **Durations** | 5s, 10s, 15s, 30s, 60s, 120s |
464
-
465
- #### Alpha Mask Export
466
-
467
- When "Include Alpha Mask" is enabled, a separate grayscale WebM video is generated alongside the main recording:
468
-
469
- - **Purpose**: Luma matte for video compositing
470
- - **Format**: Grayscale video where white = opaque, black = transparent
471
- - **Usage**: Import into video editors (After Effects, Premiere, DaVinci Resolve) as a track matte
472
- - **Filename**: `borealis-alpha-{timestamp}.webm`
473
-
474
- Both files share the same timestamp for easy pairing.
475
-
476
- ### URL State Persistence
477
-
478
- All settings are automatically saved to URL parameters. You can:
479
-
480
- 1. Configure settings using the panel
481
- 2. Copy the URL to share your exact configuration
482
- 3. Open the URL to restore all settings
483
-
484
- Example URL:
485
- ```
486
- index.html?effect=twinkle&patternAurora=true&density=70&twinkleSpeed=60
487
- ```
488
-
489
- ## Performance Tips
490
-
491
- 1. **Lower density on mobile** - Use lower density values (30-50) on mobile devices
492
- 2. **Disable on low-power mode** - Consider detecting battery status
493
- 3. **Use `stop()` when hidden** - Stop animation when tab is not visible
494
-
495
- ```javascript
496
- document.addEventListener('visibilitychange', () => {
497
- if (document.hidden) {
498
- borealis.stop();
499
- } else {
500
- borealis.start();
501
- }
502
- });
503
- ```
504
-
505
- ## License
506
-
507
- MIT License - feel free to use in personal and commercial projects.
508
-
509
- ## Contributing
510
-
1
+ # Borealis
2
+
3
+ An interactive, animated canvas background with noise-based patterns and visual effects.
4
+
5
+ [![npm version](https://badge.fury.io/js/@diabolic%2Fborealis.svg)](https://www.npmjs.com/package/@diabolic/borealis)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ > đŸŽŦ [Live Demo](https://bugrakaan.github.io/borealis/)
9
+
10
+ ## Features
11
+
12
+ - ✨ **Multiple effects** - Wave, twinkle, and noise-based patterns with domain warping
13
+ - 🌈 **Aurora colors** - Customizable gradient color schemes
14
+ - đŸŽ¯ **Animations** - Smooth radial collapse/expand show/hide transitions
15
+ - ⚡ **Highly customizable** - 40+ configurable options
16
+ - 📱 **Responsive** - Automatically adapts to container or window size
17
+ - đŸĒļ **Lightweight** - No dependencies, pure JavaScript
18
+ - đŸ“Ļ **TypeScript support** - Full type definitions included
19
+
20
+ ## Installation
21
+
22
+ ### npm
23
+
24
+ ```bash
25
+ npm install @diabolic/borealis
26
+ ```
27
+
28
+ ### yarn
29
+
30
+ ```bash
31
+ yarn add @diabolic/borealis
32
+ ```
33
+
34
+ ### pnpm
35
+
36
+ ```bash
37
+ pnpm add @diabolic/borealis
38
+ ```
39
+
40
+ ### CDN
41
+
42
+ ```html
43
+ <!-- UMD (Global variable) -->
44
+ <script src="https://unpkg.com/@diabolic/borealis/dist/borealis.min.js"></script>
45
+
46
+ <!-- Or from jsDelivr -->
47
+ <script src="https://cdn.jsdelivr.net/npm/@diabolic/borealis/dist/borealis.min.js"></script>
48
+ ```
49
+
50
+ ### Direct Script Include
51
+
52
+ ```html
53
+ <script src="borealis.js"></script>
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ ### ES Module
59
+
60
+ ```javascript
61
+ import Borealis from '@diabolic/borealis';
62
+
63
+ // Create with default options (fullscreen)
64
+ const borealis = new Borealis();
65
+
66
+ // Create with custom options
67
+ const borealis = new Borealis({
68
+ effect: {
69
+ type: 'twinkle',
70
+ aurora: true
71
+ },
72
+ patternAurora: true,
73
+ density: 70
74
+ });
75
+ ```
76
+
77
+ ### Target a Specific Container
78
+
79
+ ```javascript
80
+ // Render inside a specific element
81
+ const borealis = new Borealis({
82
+ container: document.getElementById('my-container'),
83
+ fullscreen: false // Use container dimensions instead of viewport
84
+ });
85
+
86
+ // With explicit dimensions
87
+ const borealis = new Borealis({
88
+ container: document.getElementById('hero-section'),
89
+ fullscreen: false,
90
+ width: 800,
91
+ height: 400
92
+ });
93
+ ```
94
+
95
+ ### CommonJS
96
+
97
+ ```javascript
98
+ const Borealis = require('@diabolic/borealis');
99
+
100
+ const borealis = new Borealis();
101
+ ```
102
+
103
+ ### Browser (UMD)
104
+
105
+ ```html
106
+ <script src="https://unpkg.com/@diabolic/borealis/dist/borealis.min.js"></script>
107
+ <script>
108
+ const borealis = new Borealis({
109
+ effect: { type: 'wave' }
110
+ });
111
+ </script>
112
+ ```
113
+
114
+ ## API Reference
115
+
116
+ ### Constructor
117
+
118
+ ```javascript
119
+ new Borealis(options)
120
+ ```
121
+
122
+ Creates a new Borealis instance with the specified options.
123
+
124
+ ### Methods
125
+
126
+ #### `start()`
127
+ Start the animation loop.
128
+
129
+ ```javascript
130
+ borealis.start();
131
+ ```
132
+
133
+ #### `stop()`
134
+ Stop the animation loop.
135
+
136
+ ```javascript
137
+ borealis.stop();
138
+ ```
139
+
140
+ #### `resize([width], [height])`
141
+ Manually trigger a resize. Useful when container size changes.
142
+
143
+ ```javascript
144
+ // Resize to specific dimensions
145
+ borealis.resize(800, 600);
146
+
147
+ // Resize using current container dimensions
148
+ borealis.resize();
149
+ ```
150
+
151
+ #### `redraw()`
152
+ Force a single frame redraw. Useful when animation is stopped but you want to update the display.
153
+
154
+ ```javascript
155
+ borealis.stop();
156
+ borealis.setOption('patternAurora', true);
157
+ borealis.redraw(); // Update display without starting animation
158
+ ```
159
+
160
+ #### `show([callback])`
161
+ Expand the pattern from center (reverse collapse).
162
+
163
+ ```javascript
164
+ borealis.show(() => {
165
+ console.log('Pattern is now visible');
166
+ });
167
+ ```
168
+
169
+ #### `hide([callback])`
170
+ Collapse the pattern to center.
171
+
172
+ ```javascript
173
+ borealis.hide(() => {
174
+ console.log('Pattern is now hidden');
175
+ });
176
+ ```
177
+
178
+
179
+ #### `toggle([callback])`
180
+ Toggle between show and hide states.
181
+
182
+ ```javascript
183
+ borealis.toggle();
184
+ ```
185
+
186
+ #### `isVisible()`
187
+ Returns `true` if the pattern is fully visible (not collapsed).
188
+
189
+ ```javascript
190
+ if (borealis.isVisible()) {
191
+ console.log('Pattern is visible');
192
+ }
193
+ ```
194
+
195
+ #### `isHidden()`
196
+ Returns `true` if the pattern is fully hidden (collapsed).
197
+
198
+ ```javascript
199
+ if (borealis.isHidden()) {
200
+ console.log('Pattern is hidden');
201
+ }
202
+ ```
203
+
204
+ #### `setOption(key, value)`
205
+ Set a single option value.
206
+
207
+ ```javascript
208
+ borealis.setOption('effect', 'twinkle');
209
+ borealis.setOption('density', 80);
210
+ ```
211
+
212
+ #### `setOptions(options)`
213
+ Set multiple options at once.
214
+
215
+ ```javascript
216
+ borealis.setOptions({
217
+ effect: 'twinkle',
218
+ patternAurora: true,
219
+ twinkleSpeed: 70
220
+ });
221
+ ```
222
+
223
+ #### `getOption(key)`
224
+ Get a specific option value.
225
+
226
+ ```javascript
227
+ const currentEffect = borealis.getOption('effect');
228
+ ```
229
+
230
+ #### `getOptions()`
231
+ Get all current options.
232
+
233
+ ```javascript
234
+ const options = borealis.getOptions();
235
+ ```
236
+
237
+ #### `destroy()`
238
+ Clean up and remove the canvas from DOM.
239
+
240
+ ```javascript
241
+ borealis.destroy();
242
+ ```
243
+
244
+ ## Options Reference
245
+
246
+ ### Container Options
247
+
248
+ | Option | Type | Default | Description |
249
+ |--------|------|---------|-------------|
250
+ | `container` | `HTMLElement` | `document.body` | Parent element for the canvas |
251
+ | `width` | `number \| null` | `null` | Canvas width (null = auto from container/window) |
252
+ | `height` | `number \| null` | `null` | Canvas height (null = auto from container/window) |
253
+ | `fullscreen` | `boolean` | `true` | Use fixed positioning to cover viewport |
254
+ | `zIndex` | `number` | `0` | Canvas z-index |
255
+ | `initiallyHidden` | `boolean` | `false` | Start collapsed/hidden |
256
+ | `className` | `string \| null` | `null` | Custom class name for canvas |
257
+ | `background` | `string \| null` | `null` | Canvas background (color, gradient, etc.) |
258
+
259
+ ### Grid Options
260
+
261
+ | Option | Type | Default | Description |
262
+ |--------|------|---------|-------------|
263
+ | `density` | `number` | `50` | Grid density (10-100). Higher = more dots |
264
+ | `densityMinCell` | `number` | `2` | Minimum cell size at max density |
265
+ | `densityMaxCell` | `number` | `8` | Maximum cell size at min density |
266
+ | `dotSize` | `number` | `0` | Fixed dot size (0-10). 0 = noise-based size |
267
+ | `solidPattern` | `boolean` | `false` | Use uniform solid dots instead of noise pattern |
268
+ | `densityMinGap` | `number` | `1` | Minimum gap at max density |
269
+ | `densityMaxGap` | `number` | `4` | Maximum gap at min density |
270
+
271
+ ### Pattern Options
272
+
273
+ | Option | Type | Default | Description |
274
+ |--------|------|---------|-------------|
275
+ | `patternScale` | `number` | `0.001` | Noise scale (smaller = larger patterns) |
276
+ | `patternAurora` | `boolean` | `false` | Use aurora colors for base pattern |
277
+ | `warpScale` | `number` | `0.5` | Domain warp frequency multiplier |
278
+ | `warpAmount` | `number` | `20` | Domain warp intensity |
279
+ | `animationSpeed` | `number` | `0.00002` | Base animation speed |
280
+ | `ridgePower` | `number` | `2` | Ridge sharpness (higher = sharper lines) |
281
+ | `minOpacity` | `number` | `0` | Minimum dot opacity (0-1) |
282
+ | `maxOpacity` | `number` | `1` | Maximum dot opacity (0-1) |
283
+ | `waveFrequency` | `number` | `3` | Wave oscillation frequency |
284
+ | `waveAmplitude` | `number` | `0.5` | Wave intensity (0-1) |
285
+
286
+ ### Effect Options
287
+
288
+ | Option | Type | Default | Description |
289
+ |--------|------|---------|-------------|
290
+ | `effect` | `string` | `'wave'` | Effect type: `'none'`, `'wave'`, or `'twinkle'` |
291
+ | `effectAurora` | `boolean` | `false` | Use aurora colors for effect |
292
+ | `deadzone` | `number` | `0` | Effect dead zone around cursor (0-100) |
293
+
294
+ ### Wave Effect Options
295
+
296
+ | Option | Type | Default | Description |
297
+ |--------|------|---------|-------------|
298
+ | `waveSpeed` | `number` | `0.0008` | Diagonal wave speed |
299
+ | `waveWidth` | `number` | `120` | Width of the wave band |
300
+ | `waveChance` | `number` | `0.08` | Chance of a cell sparkling (0-1) |
301
+ | `waveIntensity` | `number` | `1` | Maximum wave brightness |
302
+ | `waveDelayMin` | `number` | `1000` | Minimum delay between waves (ms) |
303
+ | `waveDelayMax` | `number` | `3000` | Maximum delay between waves (ms) |
304
+ | `waveCombineSparkle` | `boolean` | `false` | Combine wave with sparkle effect |
305
+ | `waveSparkleBaseOpacity` | `number` | `0.3` | Base opacity for combined sparkle (0-1) |
306
+
307
+ ### Twinkle Effect Options
308
+
309
+ | Option | Type | Default | Description |
310
+ |--------|------|---------|-------------|
311
+ | `twinkleSpeed` | `number` | `50` | Animation speed (10-100) |
312
+ | `twinkleSize` | `number` | `50` | Pattern size (10-100, higher = larger groups) |
313
+ | `twinkleDensity` | `number` | `50` | Star density (0-100, higher = more stars) |
314
+ | `twinkleDeadzone` | `number` | `20` | Center dead zone size (0-50) |
315
+ | `twinkleIntensity` | `number` | `1` | Maximum twinkle brightness |
316
+ | `twinkleMode` | `string` | `'sparkle'` | Twinkle style: `'sparkle'` or `'wave'` |
317
+ | `twinkleCombined` | `boolean` | `false` | Combine with base pattern |
318
+ | `twinkleBaseOpacity` | `number` | `0.3` | Base opacity when combined (0-1) |
319
+
320
+ ### Aurora Color Options
321
+
322
+ | Option | Type | Default | Description |
323
+ |--------|------|---------|-------------|
324
+ | `auroraColor1` | `array` | `[0, 255, 128]` | First aurora color (RGB) - Cyan-green |
325
+ | `auroraColor2` | `array` | `[148, 0, 211]` | Second aurora color (RGB) - Violet |
326
+ | `colorScale` | `number` | `0.003` | Color variation scale |
327
+
328
+ ### Collapse Options
329
+
330
+ | Option | Type | Default | Description |
331
+ |--------|------|---------|-------------|
332
+ | `collapseSpeed` | `number` | `0.1` | Collapse/expand animation speed |
333
+ | `collapseWaveWidth` | `number` | `0.4` | Width of the collapse transition |
334
+
335
+ ### Animation Options
336
+
337
+ | Option | Type | Default | Description |
338
+ |--------|------|---------|-------------|
339
+ | `animateOnHover` | `boolean` | `true` | Only animate when mouse is over document |
340
+ | `autoStart` | `boolean` | `true` | Start animation automatically |
341
+
342
+ ### Callback Options
343
+
344
+ | Option | Type | Default | Description |
345
+ |--------|------|---------|-------------|
346
+ | `onShow` | `function` | `null` | Called when show animation completes |
347
+ | `onHide` | `function` | `null` | Called when hide animation completes |
348
+
349
+ ## Examples
350
+
351
+ ### Basic Usage
352
+
353
+ ```html
354
+ <!DOCTYPE html>
355
+ <html>
356
+ <head>
357
+ <style>
358
+ body {
359
+ margin: 0;
360
+ min-height: 100vh;
361
+ background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
362
+ }
363
+ </style>
364
+ </head>
365
+ <body>
366
+ <script src="borealis.js"></script>
367
+ <script>
368
+ const borealis = new Borealis();
369
+ </script>
370
+ </body>
371
+ </html>
372
+ ```
373
+
374
+ ### Twinkle Effect with Aurora Colors
375
+
376
+ ```javascript
377
+ const borealis = new Borealis({
378
+ effect: 'twinkle',
379
+ patternAurora: true,
380
+ effectAurora: true,
381
+ twinkleSpeed: 70,
382
+ twinkleDensity: 60,
383
+ twinkleDeadzone: 25
384
+ });
385
+ ```
386
+
387
+ ### Show/Hide on Button Click
388
+
389
+ ```javascript
390
+ const borealis = new Borealis();
391
+
392
+ document.getElementById('toggleBtn').addEventListener('click', () => {
393
+ borealis.toggle(() => {
394
+ console.log('Animation complete');
395
+ });
396
+ });
397
+ ```
398
+
399
+ ### Custom Aurora Colors
400
+
401
+ ```javascript
402
+ const borealis = new Borealis({
403
+ patternAurora: true,
404
+ auroraColor1: [255, 100, 100], // Pink
405
+ auroraColor2: [100, 100, 255], // Blue
406
+ });
407
+ ```
408
+
409
+ ### Programmatic Control
410
+
411
+ ```javascript
412
+ const borealis = new Borealis({ autoStart: false });
413
+
414
+ // Start when ready
415
+ setTimeout(() => {
416
+ borealis.start();
417
+ }, 1000);
418
+
419
+ // Change effect dynamically
420
+ borealis.setOption('effect', 'twinkle');
421
+
422
+ // Hide and perform action
423
+ borealis.hide(() => {
424
+ // Navigate or perform other action
425
+ window.location.href = '/next-page';
426
+ });
427
+ ```
428
+
429
+ ### Inside a Specific Container
430
+
431
+ ```javascript
432
+ const container = document.getElementById('hero-section');
433
+
434
+ const borealis = new Borealis({
435
+ container: container,
436
+ density: 60,
437
+ effect: 'wave'
438
+ });
439
+ ```
440
+
441
+ ## Browser Support
442
+
443
+ - Chrome 60+
444
+ - Firefox 55+
445
+ - Safari 12+
446
+ - Edge 79+
447
+
448
+ ## Demo Page Features
449
+
450
+ The included `index.html` demo page provides a comprehensive interface for testing and configuring Borealis:
451
+
452
+ ### Settings Panel
453
+
454
+ - **Two-column layout** - Organized controls for all options
455
+ - **Live preview** - Changes apply instantly
456
+ - **URL state persistence** - Settings are saved to URL parameters for easy sharing
457
+ - **Copy Code button** - Generate JavaScript initialization code from current settings
458
+
459
+ ### Recording Features
460
+
461
+ The demo page includes WebM video recording capabilities:
462
+
463
+ | Feature | Description |
464
+ |---------|-------------|
465
+ | **Format** | WebM with VP9 codec |
466
+ | **Framerate** | 30 fps |
467
+ | **Main Video Bitrate** | 5 Mbps |
468
+ | **Alpha Mask Bitrate** | 3 Mbps |
469
+ | **Resolutions** | 640×360, 854×480, 1280×720, 1440×900, 1920×1080, 2560×1440 |
470
+ | **Durations** | 5s, 10s, 15s, 30s, 60s, 120s |
471
+
472
+ #### Alpha Mask Export
473
+
474
+ When "Include Alpha Mask" is enabled, a separate grayscale WebM video is generated alongside the main recording:
475
+
476
+ - **Purpose**: Luma matte for video compositing
477
+ - **Format**: Grayscale video where white = opaque, black = transparent
478
+ - **Usage**: Import into video editors (After Effects, Premiere, DaVinci Resolve) as a track matte
479
+ - **Filename**: `borealis-alpha-{timestamp}.webm`
480
+
481
+ Both files share the same timestamp for easy pairing.
482
+
483
+ ### URL State Persistence
484
+
485
+ All settings are automatically saved to URL parameters. You can:
486
+
487
+ 1. Configure settings using the panel
488
+ 2. Copy the URL to share your exact configuration
489
+ 3. Open the URL to restore all settings
490
+
491
+ Example URL:
492
+ ```
493
+ index.html?effect=twinkle&patternAurora=true&density=70&twinkleSpeed=60
494
+ ```
495
+
496
+ ## Performance Tips
497
+
498
+ 1. **Lower density on mobile** - Use lower density values (30-50) on mobile devices
499
+ 2. **Disable on low-power mode** - Consider detecting battery status
500
+ 3. **Use `stop()` when hidden** - Stop animation when tab is not visible
501
+
502
+ ```javascript
503
+ document.addEventListener('visibilitychange', () => {
504
+ if (document.hidden) {
505
+ borealis.stop();
506
+ } else {
507
+ borealis.start();
508
+ }
509
+ });
510
+ ```
511
+
512
+ ## License
513
+
514
+ MIT License - feel free to use in personal and commercial projects.
515
+
516
+ ## Contributing
517
+
511
518
  Contributions are welcome! Please feel free to submit a Pull Request.