@diabolic/borealis 1.0.2 → 1.0.3

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,516 @@
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
+
257
+ ### Grid Options
258
+
259
+ | Option | Type | Default | Description |
260
+ |--------|------|---------|-------------|
261
+ | `density` | `number` | `50` | Grid density (10-100). Higher = more dots |
262
+ | `densityMinCell` | `number` | `2` | Minimum cell size at max density |
263
+ | `densityMaxCell` | `number` | `8` | Maximum cell size at min density |
264
+ | `dotSize` | `number` | `0` | Fixed dot size (0-10). 0 = noise-based size |
265
+ | `solidPattern` | `boolean` | `false` | Use uniform solid dots instead of noise pattern |
266
+ | `densityMinGap` | `number` | `1` | Minimum gap at max density |
267
+ | `densityMaxGap` | `number` | `4` | Maximum gap at min density |
268
+
269
+ ### Pattern Options
270
+
271
+ | Option | Type | Default | Description |
272
+ |--------|------|---------|-------------|
273
+ | `patternScale` | `number` | `0.001` | Noise scale (smaller = larger patterns) |
274
+ | `patternAurora` | `boolean` | `false` | Use aurora colors for base pattern |
275
+ | `warpScale` | `number` | `0.5` | Domain warp frequency multiplier |
276
+ | `warpAmount` | `number` | `20` | Domain warp intensity |
277
+ | `animationSpeed` | `number` | `0.00002` | Base animation speed |
278
+ | `ridgePower` | `number` | `2` | Ridge sharpness (higher = sharper lines) |
279
+ | `minOpacity` | `number` | `0` | Minimum dot opacity (0-1) |
280
+ | `maxOpacity` | `number` | `1` | Maximum dot opacity (0-1) |
281
+ | `waveFrequency` | `number` | `3` | Wave oscillation frequency |
282
+ | `waveAmplitude` | `number` | `0.5` | Wave intensity (0-1) |
283
+
284
+ ### Effect Options
285
+
286
+ | Option | Type | Default | Description |
287
+ |--------|------|---------|-------------|
288
+ | `effect` | `string` | `'wave'` | Effect type: `'none'`, `'wave'`, or `'twinkle'` |
289
+ | `effectAurora` | `boolean` | `false` | Use aurora colors for effect |
290
+ | `deadzone` | `number` | `0` | Effect dead zone around cursor (0-100) |
291
+
292
+ ### Wave Effect Options
293
+
294
+ | Option | Type | Default | Description |
295
+ |--------|------|---------|-------------|
296
+ | `waveSpeed` | `number` | `0.0008` | Diagonal wave speed |
297
+ | `waveWidth` | `number` | `120` | Width of the wave band |
298
+ | `waveChance` | `number` | `0.08` | Chance of a cell sparkling (0-1) |
299
+ | `waveIntensity` | `number` | `1` | Maximum wave brightness |
300
+ | `waveDelayMin` | `number` | `1000` | Minimum delay between waves (ms) |
301
+ | `waveDelayMax` | `number` | `3000` | Maximum delay between waves (ms) |
302
+ | `waveCombineSparkle` | `boolean` | `false` | Combine wave with sparkle effect |
303
+ | `waveSparkleBaseOpacity` | `number` | `0.3` | Base opacity for combined sparkle (0-1) |
304
+
305
+ ### Twinkle Effect Options
306
+
307
+ | Option | Type | Default | Description |
308
+ |--------|------|---------|-------------|
309
+ | `twinkleSpeed` | `number` | `50` | Animation speed (10-100) |
310
+ | `twinkleSize` | `number` | `50` | Pattern size (10-100, higher = larger groups) |
311
+ | `twinkleDensity` | `number` | `50` | Star density (0-100, higher = more stars) |
312
+ | `twinkleDeadzone` | `number` | `20` | Center dead zone size (0-50) |
313
+ | `twinkleIntensity` | `number` | `1` | Maximum twinkle brightness |
314
+ | `twinkleMode` | `string` | `'sparkle'` | Twinkle style: `'sparkle'` or `'wave'` |
315
+ | `twinkleCombined` | `boolean` | `false` | Combine with base pattern |
316
+ | `twinkleBaseOpacity` | `number` | `0.3` | Base opacity when combined (0-1) |
317
+
318
+ ### Aurora Color Options
319
+
320
+ | Option | Type | Default | Description |
321
+ |--------|------|---------|-------------|
322
+ | `auroraColor1` | `array` | `[0, 255, 128]` | First aurora color (RGB) - Cyan-green |
323
+ | `auroraColor2` | `array` | `[148, 0, 211]` | Second aurora color (RGB) - Violet |
324
+ | `colorScale` | `number` | `0.003` | Color variation scale |
325
+
326
+ ### Collapse Options
327
+
328
+ | Option | Type | Default | Description |
329
+ |--------|------|---------|-------------|
330
+ | `collapseSpeed` | `number` | `0.1` | Collapse/expand animation speed |
331
+ | `collapseWaveWidth` | `number` | `0.4` | Width of the collapse transition |
332
+
333
+ ### Animation Options
334
+
335
+ | Option | Type | Default | Description |
336
+ |--------|------|---------|-------------|
337
+ | `animateOnHover` | `boolean` | `true` | Only animate when mouse is over document |
338
+ | `autoStart` | `boolean` | `true` | Start animation automatically |
339
+
340
+ ### Callback Options
341
+
342
+ | Option | Type | Default | Description |
343
+ |--------|------|---------|-------------|
344
+ | `onShow` | `function` | `null` | Called when show animation completes |
345
+ | `onHide` | `function` | `null` | Called when hide animation completes |
346
+
347
+ ## Examples
348
+
349
+ ### Basic Usage
350
+
351
+ ```html
352
+ <!DOCTYPE html>
353
+ <html>
354
+ <head>
355
+ <style>
356
+ body {
357
+ margin: 0;
358
+ min-height: 100vh;
359
+ background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
360
+ }
361
+ </style>
362
+ </head>
363
+ <body>
364
+ <script src="borealis.js"></script>
365
+ <script>
366
+ const borealis = new Borealis();
367
+ </script>
368
+ </body>
369
+ </html>
370
+ ```
371
+
372
+ ### Twinkle Effect with Aurora Colors
373
+
374
+ ```javascript
375
+ const borealis = new Borealis({
376
+ effect: 'twinkle',
377
+ patternAurora: true,
378
+ effectAurora: true,
379
+ twinkleSpeed: 70,
380
+ twinkleDensity: 60,
381
+ twinkleDeadzone: 25
382
+ });
383
+ ```
384
+
385
+ ### Show/Hide on Button Click
386
+
387
+ ```javascript
388
+ const borealis = new Borealis();
389
+
390
+ document.getElementById('toggleBtn').addEventListener('click', () => {
391
+ borealis.toggle(() => {
392
+ console.log('Animation complete');
393
+ });
394
+ });
395
+ ```
396
+
397
+ ### Custom Aurora Colors
398
+
399
+ ```javascript
400
+ const borealis = new Borealis({
401
+ patternAurora: true,
402
+ auroraColor1: [255, 100, 100], // Pink
403
+ auroraColor2: [100, 100, 255], // Blue
404
+ });
405
+ ```
406
+
407
+ ### Programmatic Control
408
+
409
+ ```javascript
410
+ const borealis = new Borealis({ autoStart: false });
411
+
412
+ // Start when ready
413
+ setTimeout(() => {
414
+ borealis.start();
415
+ }, 1000);
416
+
417
+ // Change effect dynamically
418
+ borealis.setOption('effect', 'twinkle');
419
+
420
+ // Hide and perform action
421
+ borealis.hide(() => {
422
+ // Navigate or perform other action
423
+ window.location.href = '/next-page';
424
+ });
425
+ ```
426
+
427
+ ### Inside a Specific Container
428
+
429
+ ```javascript
430
+ const container = document.getElementById('hero-section');
431
+
432
+ const borealis = new Borealis({
433
+ container: container,
434
+ density: 60,
435
+ effect: 'wave'
436
+ });
437
+ ```
438
+
439
+ ## Browser Support
440
+
441
+ - Chrome 60+
442
+ - Firefox 55+
443
+ - Safari 12+
444
+ - Edge 79+
445
+
446
+ ## Demo Page Features
447
+
448
+ The included `index.html` demo page provides a comprehensive interface for testing and configuring Borealis:
449
+
450
+ ### Settings Panel
451
+
452
+ - **Two-column layout** - Organized controls for all options
453
+ - **Live preview** - Changes apply instantly
454
+ - **URL state persistence** - Settings are saved to URL parameters for easy sharing
455
+ - **Copy Code button** - Generate JavaScript initialization code from current settings
456
+
457
+ ### Recording Features
458
+
459
+ The demo page includes WebM video recording capabilities:
460
+
461
+ | Feature | Description |
462
+ |---------|-------------|
463
+ | **Format** | WebM with VP9 codec |
464
+ | **Framerate** | 30 fps |
465
+ | **Main Video Bitrate** | 5 Mbps |
466
+ | **Alpha Mask Bitrate** | 3 Mbps |
467
+ | **Resolutions** | 640×360, 854×480, 1280×720, 1440×900, 1920×1080, 2560×1440 |
468
+ | **Durations** | 5s, 10s, 15s, 30s, 60s, 120s |
469
+
470
+ #### Alpha Mask Export
471
+
472
+ When "Include Alpha Mask" is enabled, a separate grayscale WebM video is generated alongside the main recording:
473
+
474
+ - **Purpose**: Luma matte for video compositing
475
+ - **Format**: Grayscale video where white = opaque, black = transparent
476
+ - **Usage**: Import into video editors (After Effects, Premiere, DaVinci Resolve) as a track matte
477
+ - **Filename**: `borealis-alpha-{timestamp}.webm`
478
+
479
+ Both files share the same timestamp for easy pairing.
480
+
481
+ ### URL State Persistence
482
+
483
+ All settings are automatically saved to URL parameters. You can:
484
+
485
+ 1. Configure settings using the panel
486
+ 2. Copy the URL to share your exact configuration
487
+ 3. Open the URL to restore all settings
488
+
489
+ Example URL:
490
+ ```
491
+ index.html?effect=twinkle&patternAurora=true&density=70&twinkleSpeed=60
492
+ ```
493
+
494
+ ## Performance Tips
495
+
496
+ 1. **Lower density on mobile** - Use lower density values (30-50) on mobile devices
497
+ 2. **Disable on low-power mode** - Consider detecting battery status
498
+ 3. **Use `stop()` when hidden** - Stop animation when tab is not visible
499
+
500
+ ```javascript
501
+ document.addEventListener('visibilitychange', () => {
502
+ if (document.hidden) {
503
+ borealis.stop();
504
+ } else {
505
+ borealis.start();
506
+ }
507
+ });
508
+ ```
509
+
510
+ ## License
511
+
512
+ MIT License - feel free to use in personal and commercial projects.
513
+
514
+ ## Contributing
515
+
511
516
  Contributions are welcome! Please feel free to submit a Pull Request.