textmode.filters.js 1.1.0 → 1.2.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.
@@ -0,0 +1,1033 @@
1
+ /**
2
+ * Type definitions for all filter options in textmode.filters.js.
3
+ *
4
+ * Each filter can be applied using either:
5
+ * - A single value (shorthand for the primary parameter)
6
+ * - An options object with named parameters
7
+ *
8
+ * @example
9
+ * ```javascript
10
+ * const t = textmode.create({
11
+ * width: window.innerWidth,
12
+ * height: window.innerHeight,
13
+ * plugins: [FiltersPlugin],
14
+ * });
15
+ *
16
+ * let video;
17
+ *
18
+ * t.setup(async () => {
19
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
20
+ * video.play();
21
+ * video.loop();
22
+ * video.characters(' .:-=+*#%@');
23
+ * });
24
+ *
25
+ * t.draw(() => {
26
+ * t.background(0);
27
+ * if (video) {
28
+ * t.image(video, t.grid.cols, t.grid.rows);
29
+ * }
30
+ *
31
+ * const wobble = Math.sin(t.secs * 2);
32
+ * t.layers.base.filter('bloom', {
33
+ * threshold: 0.5,
34
+ * intensity: 1 + wobble * 0.35,
35
+ * radius: 6 + wobble * 2,
36
+ * });
37
+ * });
38
+ *
39
+ * t.windowResized(() => {
40
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
41
+ * });
42
+ * ```
43
+ *
44
+ * @module
45
+ */
46
+ /**
47
+ * Configuration options for the `'brightness'` filter.
48
+ *
49
+ * Adjusts image brightness by multiplying pixel values.
50
+ *
51
+ * @example
52
+ * ```javascript
53
+ * const t = textmode.create({
54
+ * width: window.innerWidth,
55
+ * height: window.innerHeight,
56
+ * plugins: [FiltersPlugin],
57
+ * });
58
+ *
59
+ * let video;
60
+ *
61
+ * t.setup(async () => {
62
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
63
+ * video.play();
64
+ * video.loop();
65
+ * video.characters(' .:-=+*#%@');
66
+ * });
67
+ *
68
+ * t.draw(() => {
69
+ * t.background(0);
70
+ * if (video) {
71
+ * t.image(video, t.grid.cols, t.grid.rows);
72
+ * }
73
+ *
74
+ * const wobble = Math.sin(t.secs * 2);
75
+ * t.layers.base.filter('brightness', {
76
+ * amount: 1 + wobble * 0.25,
77
+ * });
78
+ * });
79
+ *
80
+ * t.windowResized(() => {
81
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
82
+ * });
83
+ * ```
84
+ *
85
+ * @category Color adjustment filters
86
+ */
87
+ export interface BrightnessOptions {
88
+ /**
89
+ * Brightness multiplier.
90
+ *
91
+ * - `1.0` = normal brightness (no change)
92
+ * - `> 1.0` = brighter
93
+ * - `< 1.0` = darker
94
+ * - `0.0` = completely black
95
+ *
96
+ * @default 1.0
97
+ */
98
+ amount: number;
99
+ }
100
+ /**
101
+ * Configuration options for the `'contrast'` filter.
102
+ *
103
+ * Adjusts image contrast by scaling pixel values around mid-gray.
104
+ *
105
+ * @example
106
+ * ```javascript
107
+ * const t = textmode.create({
108
+ * width: window.innerWidth,
109
+ * height: window.innerHeight,
110
+ * plugins: [FiltersPlugin],
111
+ * });
112
+ *
113
+ * let video;
114
+ *
115
+ * t.setup(async () => {
116
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
117
+ * video.play();
118
+ * video.loop();
119
+ * video.characters(' .:-=+*#%@');
120
+ * });
121
+ *
122
+ * t.draw(() => {
123
+ * t.background(0);
124
+ * if (video) {
125
+ * t.image(video, t.grid.cols, t.grid.rows);
126
+ * }
127
+ *
128
+ * const wobble = Math.sin(t.secs * 2);
129
+ * t.layers.base.filter('contrast', {
130
+ * amount: 1 + wobble * 0.35,
131
+ * });
132
+ * });
133
+ *
134
+ * t.windowResized(() => {
135
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
136
+ * });
137
+ * ```
138
+ *
139
+ * @category Color adjustment filters
140
+ */
141
+ export interface ContrastOptions {
142
+ /**
143
+ * Contrast multiplier.
144
+ *
145
+ * - `1.0` = normal contrast (no change)
146
+ * - `> 1.0` = more contrast (darker darks, brighter brights)
147
+ * - `< 1.0` = less contrast (more gray/washed out)
148
+ * - `0.0` = solid gray
149
+ *
150
+ * @default 1.0
151
+ */
152
+ amount: number;
153
+ }
154
+ /**
155
+ * Configuration options for the `'saturation'` filter.
156
+ *
157
+ * Adjusts color intensity without affecting luminance.
158
+ * Perfect for creating vivid, oversaturated looks or desaturating to grayscale.
159
+ *
160
+ * @example
161
+ * ```javascript
162
+ * const t = textmode.create({
163
+ * width: window.innerWidth,
164
+ * height: window.innerHeight,
165
+ * plugins: [FiltersPlugin],
166
+ * });
167
+ *
168
+ * let video;
169
+ *
170
+ * t.setup(async () => {
171
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
172
+ * video.play();
173
+ * video.loop();
174
+ * video.characters(' .:-=+*#%@');
175
+ * });
176
+ *
177
+ * t.draw(() => {
178
+ * t.background(0);
179
+ * if (video) {
180
+ * t.image(video, t.grid.cols, t.grid.rows);
181
+ * }
182
+ *
183
+ * const wobble = Math.sin(t.secs * 2);
184
+ * t.layers.base.filter('saturation', {
185
+ * amount: 1 + wobble * 0.45,
186
+ * });
187
+ * });
188
+ *
189
+ * t.windowResized(() => {
190
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
191
+ * });
192
+ * ```
193
+ *
194
+ * @category Color adjustment filters
195
+ */
196
+ export interface SaturationOptions {
197
+ /**
198
+ * Saturation multiplier.
199
+ *
200
+ * - `0.0` = grayscale (no color)
201
+ * - `1.0` = normal saturation (no change)
202
+ * - `> 1.0` = vivid/oversaturated colors
203
+ *
204
+ * @default 1.0
205
+ */
206
+ amount: number;
207
+ }
208
+ /**
209
+ * Configuration options for the `'hueRotate'` filter.
210
+ *
211
+ * Shifts all colors around the color wheel by a specified angle.
212
+ * Useful for color grading or creating surreal color effects.
213
+ *
214
+ * @example
215
+ * ```javascript
216
+ * const t = textmode.create({
217
+ * width: window.innerWidth,
218
+ * height: window.innerHeight,
219
+ * plugins: [FiltersPlugin],
220
+ * });
221
+ *
222
+ * let video;
223
+ *
224
+ * t.setup(async () => {
225
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
226
+ * video.play();
227
+ * video.loop();
228
+ * video.characters(' .:-=+*#%@');
229
+ * });
230
+ *
231
+ * t.draw(() => {
232
+ * t.background(0);
233
+ * if (video) {
234
+ * t.image(video, t.grid.cols, t.grid.rows);
235
+ * }
236
+ *
237
+ * const wobble = Math.sin(t.secs * 2);
238
+ * const hue = (t.frameCount * 2 + wobble * 45) % 360;
239
+ * t.layers.base.filter('hueRotate', {
240
+ * angle: hue,
241
+ * });
242
+ * });
243
+ *
244
+ * t.windowResized(() => {
245
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
246
+ * });
247
+ * ```
248
+ *
249
+ * @category Color adjustment filters
250
+ */
251
+ export interface HueRotateOptions {
252
+ /**
253
+ * Rotation angle in degrees.
254
+ *
255
+ * - `0` = no change
256
+ * - `180` = complementary colors
257
+ * - `360` = full rotation (same as 0)
258
+ *
259
+ * Values wrap around, so `370` is equivalent to `10`.
260
+ *
261
+ * @default 0.0
262
+ */
263
+ angle: number;
264
+ }
265
+ /**
266
+ * Configuration options for the `'posterize'` filter.
267
+ *
268
+ * Reduces the color palette to a limited number of bands per channel,
269
+ * creating a retro quantized/poster-like look.
270
+ *
271
+ * @example
272
+ * ```javascript
273
+ * const t = textmode.create({
274
+ * width: window.innerWidth,
275
+ * height: window.innerHeight,
276
+ * plugins: [FiltersPlugin],
277
+ * });
278
+ *
279
+ * let video;
280
+ *
281
+ * t.setup(async () => {
282
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
283
+ * video.play();
284
+ * video.loop();
285
+ * video.characters(' .:-=+*#%@');
286
+ * });
287
+ *
288
+ * t.draw(() => {
289
+ * t.background(0);
290
+ * if (video) {
291
+ * t.image(video, t.grid.cols, t.grid.rows);
292
+ * }
293
+ *
294
+ * const wobble = Math.sin(t.secs * 2);
295
+ * t.layers.base.filter('posterize', {
296
+ * levels: Math.max(2, Math.round(5 + wobble * 3)),
297
+ * });
298
+ * });
299
+ *
300
+ * t.windowResized(() => {
301
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
302
+ * });
303
+ * ```
304
+ *
305
+ * @category Color adjustment filters
306
+ */
307
+ export interface PosterizeOptions {
308
+ /**
309
+ * Number of color levels per channel.
310
+ *
311
+ * Lower values create more dramatic banding effects.
312
+ * Higher values approach the original image quality.
313
+ *
314
+ * - `2` = extreme posterization (very few colors)
315
+ * - `4` = strong posterization (default)
316
+ * - `8+` = subtle posterization
317
+ *
318
+ * @default 4.0
319
+ */
320
+ levels: number;
321
+ }
322
+ /**
323
+ * Configuration options for the `'chromaticAberration'` filter.
324
+ *
325
+ * RGB color channel separation effect that simulates lens distortion
326
+ * found in cheap cameras or creates stylized glitch aesthetics.
327
+ *
328
+ * @example
329
+ * ```javascript
330
+ * const t = textmode.create({
331
+ * width: window.innerWidth,
332
+ * height: window.innerHeight,
333
+ * plugins: [FiltersPlugin],
334
+ * });
335
+ *
336
+ * let video;
337
+ *
338
+ * t.setup(async () => {
339
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
340
+ * video.play();
341
+ * video.loop();
342
+ * video.characters(' .:-=+*#%@');
343
+ * });
344
+ *
345
+ * t.draw(() => {
346
+ * t.background(0);
347
+ * if (video) {
348
+ * t.image(video, t.grid.cols, t.grid.rows);
349
+ * }
350
+ *
351
+ * const wobble = Math.sin(t.secs * 2);
352
+ * t.layers.base.filter('chromaticAberration', {
353
+ * amount: 6 + wobble * 4,
354
+ * direction: [Math.sin(t.secs), Math.cos(t.secs)],
355
+ * });
356
+ * });
357
+ *
358
+ * t.windowResized(() => {
359
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
360
+ * });
361
+ * ```
362
+ *
363
+ * @category Distortion filters
364
+ */
365
+ export interface ChromaticAberrationOptions {
366
+ /**
367
+ * Offset amount in pixels.
368
+ *
369
+ * Controls how far the red and blue channels are separated from green.
370
+ *
371
+ * @default 5.0
372
+ */
373
+ amount: number;
374
+ /**
375
+ * Direction of the color separation as `[x, y]`.
376
+ *
377
+ * - `[1, 0]` = horizontal separation
378
+ * - `[0, 1]` = vertical separation
379
+ * - `[1, 1]` = diagonal separation
380
+ *
381
+ * The vector is normalized internally, so `[2, 0]` is the same as `[1, 0]`.
382
+ *
383
+ * @default [1.0, 0.0]
384
+ */
385
+ direction: [number, number];
386
+ }
387
+ /**
388
+ * Configuration options for the `'pixelate'` filter.
389
+ *
390
+ * Reduces image resolution to create a mosaic/pixelated effect
391
+ * reminiscent of retro video games or censored content.
392
+ *
393
+ * @example
394
+ * ```javascript
395
+ * const t = textmode.create({
396
+ * width: window.innerWidth,
397
+ * height: window.innerHeight,
398
+ * plugins: [FiltersPlugin],
399
+ * });
400
+ *
401
+ * let video;
402
+ *
403
+ * t.setup(async () => {
404
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
405
+ * video.play();
406
+ * video.loop();
407
+ * video.characters(' .:-=+*#%@');
408
+ * });
409
+ *
410
+ * t.draw(() => {
411
+ * t.background(0);
412
+ * if (video) {
413
+ * t.image(video, t.grid.cols, t.grid.rows);
414
+ * }
415
+ *
416
+ * const wobble = Math.sin(t.secs * 2);
417
+ * t.layers.base.filter('pixelate', {
418
+ * pixelSize: 6 + wobble * 3,
419
+ * });
420
+ * });
421
+ *
422
+ * t.windowResized(() => {
423
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
424
+ * });
425
+ * ```
426
+ *
427
+ * @category Distortion filters
428
+ */
429
+ export interface PixelateOptions {
430
+ /**
431
+ * Size of each pixel block in pixels.
432
+ *
433
+ * Larger values create bigger, more visible pixels.
434
+ *
435
+ * Minimum value: `1.0`
436
+ *
437
+ * @default 4.0
438
+ */
439
+ pixelSize: number;
440
+ }
441
+ /**
442
+ * Configuration options for the `'gridDistortion'` filter.
443
+ *
444
+ * Distorts a monospaced character grid by varying the width and height
445
+ * of individual cells. Create wave effects, perspective distortions,
446
+ * or other grid warping effects by providing custom factor arrays.
447
+ *
448
+ * This filter is designed specifically for textmode.js grids, allowing
449
+ * you to create dynamic text distortion effects.
450
+ *
451
+ * @example
452
+ * ```javascript
453
+ * const t = textmode.create({
454
+ * width: window.innerWidth,
455
+ * height: window.innerHeight,
456
+ * plugins: [FiltersPlugin],
457
+ * });
458
+ *
459
+ * let video;
460
+ *
461
+ * t.setup(async () => {
462
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
463
+ * video.play();
464
+ * video.loop();
465
+ * video.characters(' .:-=+*#%@');
466
+ * });
467
+ *
468
+ * t.draw(() => {
469
+ * t.background(0);
470
+ * if (video) {
471
+ * t.image(video, t.grid.cols, t.grid.rows);
472
+ * }
473
+ *
474
+ * const wobble = Math.sin(t.secs * 2);
475
+ * const widthFactors = Array.from({ length: t.grid.cols }, (_, i) => (Math.sin(i * 0.18 + t.frameCount * 0.04) + 1) * 0.5);
476
+ * const heightFactors = Array.from({ length: t.grid.rows }, (_, i) => (Math.sin(i * 0.24 + t.secs * 1.5) + 1) * 0.5);
477
+ * t.layers.base.filter('gridDistortion', {
478
+ * gridCellDimensions: [t.grid.cols, t.grid.rows],
479
+ * gridPixelDimensions: [t.grid.width, t.grid.height],
480
+ * gridOffsetDimensions: [t.grid.offsetX, t.grid.offsetY],
481
+ * widthFactors,
482
+ * heightFactors,
483
+ * widthVariationScale: 0.35 + wobble * 0.15,
484
+ * heightVariationScale: 0.35 + wobble * 0.15,
485
+ * });
486
+ * });
487
+ *
488
+ * t.windowResized(() => {
489
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
490
+ * });
491
+ * ```
492
+ *
493
+ * @category Distortion filters
494
+ */
495
+ export interface GridDistortionOptions {
496
+ /**
497
+ * Grid dimensions as `[columns, rows]`.
498
+ *
499
+ * Should match your textmode grid dimensions.
500
+ *
501
+ * Maximum value: `[128, 128]`
502
+ *
503
+ * @default [80.0, 40.0]
504
+ */
505
+ gridCellDimensions: [number, number];
506
+ /**
507
+ * Grid size in pixels as `[width, height]`.
508
+ *
509
+ * Typically calculated as:
510
+ * `[t.grid.cols * t.grid.cellWidth, t.grid.rows * t.grid.cellHeight]`
511
+ *
512
+ * @default [640.0, 320.0]
513
+ */
514
+ gridPixelDimensions: [number, number];
515
+ /**
516
+ * Grid offset in pixels as `[offsetX, offsetY]`.
517
+ *
518
+ * Use `[t.grid.offsetX, t.grid.offsetY]` to match your grid position.
519
+ *
520
+ * @default [0.0, 0.0]
521
+ */
522
+ gridOffsetDimensions: [number, number];
523
+ /**
524
+ * Array of distortion values (0-1) for each column.
525
+ *
526
+ * Must contain at least as many elements as columns (max 128).
527
+ * Values control the relative width of each column:
528
+ * - `0.0` = minimum width
529
+ * - `0.5` = normal width
530
+ * - `1.0` = maximum width
531
+ *
532
+ * @default Array(128).fill(0.5)
533
+ */
534
+ widthFactors: number[];
535
+ /**
536
+ * Array of distortion values (0-1) for each row.
537
+ *
538
+ * Must contain at least as many elements as rows (max 128).
539
+ * Values control the relative height of each row:
540
+ * - `0.0` = minimum height
541
+ * - `0.5` = normal height
542
+ * - `1.0` = maximum height
543
+ *
544
+ * @default Array(128).fill(0.5)
545
+ */
546
+ heightFactors: number[];
547
+ /**
548
+ * Intensity multiplier for width distortion.
549
+ *
550
+ * Higher values create more dramatic width variations.
551
+ *
552
+ * @default 0.5
553
+ */
554
+ widthVariationScale: number;
555
+ /**
556
+ * Intensity multiplier for height distortion.
557
+ *
558
+ * Higher values create more dramatic height variations.
559
+ *
560
+ * @default 0.5
561
+ */
562
+ heightVariationScale: number;
563
+ }
564
+ /**
565
+ * Configuration options for the `'glitch'` filter.
566
+ *
567
+ * Digital glitch effect with RGB channel separation, scanlines, and noise.
568
+ * Creates a corrupted/broken digital signal aesthetic.
569
+ *
570
+ * @example
571
+ * ```javascript
572
+ * const t = textmode.create({
573
+ * width: window.innerWidth,
574
+ * height: window.innerHeight,
575
+ * plugins: [FiltersPlugin],
576
+ * });
577
+ *
578
+ * let video;
579
+ *
580
+ * t.setup(async () => {
581
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
582
+ * video.play();
583
+ * video.loop();
584
+ * video.characters(' .:-=+*#%@');
585
+ * });
586
+ *
587
+ * t.draw(() => {
588
+ * t.background(0);
589
+ * if (video) {
590
+ * t.image(video, t.grid.cols, t.grid.rows);
591
+ * }
592
+ *
593
+ * const wobble = Math.sin(t.secs * 2);
594
+ * t.layers.base.filter('glitch', {
595
+ * amount: Math.max(0, 0.2 + wobble * 0.8),
596
+ * });
597
+ * });
598
+ *
599
+ * t.windowResized(() => {
600
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
601
+ * });
602
+ * ```
603
+ *
604
+ * @category Stylization filters
605
+ */
606
+ export interface GlitchOptions {
607
+ /**
608
+ * Glitch intensity.
609
+ *
610
+ * - `0.0` = no glitch effect
611
+ * - `0.5` = subtle glitching
612
+ * - `1.0+` = intense, chaotic glitching
613
+ *
614
+ * @default 0.0
615
+ */
616
+ amount: number;
617
+ }
618
+ /**
619
+ * Configuration options for the `'crtMattias'` filter.
620
+ *
621
+ * CRT monitor emulation effect with screen curvature, animated scanlines,
622
+ * blur, vignette, and film grain noise. Based on Mattias Gustavsson's
623
+ * classic CRT shader.
624
+ *
625
+ * @example
626
+ * ```javascript
627
+ * const t = textmode.create({
628
+ * width: window.innerWidth,
629
+ * height: window.innerHeight,
630
+ * plugins: [FiltersPlugin],
631
+ * });
632
+ *
633
+ * let video;
634
+ *
635
+ * t.setup(async () => {
636
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
637
+ * video.play();
638
+ * video.loop();
639
+ * video.characters(' .:-=+*#%@');
640
+ * });
641
+ *
642
+ * t.draw(() => {
643
+ * t.background(0);
644
+ * if (video) {
645
+ * t.image(video, t.grid.cols, t.grid.rows);
646
+ * }
647
+ *
648
+ * const wobble = Math.sin(t.secs * 2);
649
+ * t.layers.base.filter('crtMattias', {
650
+ * curvature: 0.45 + wobble * 0.1,
651
+ * scanSpeed: 1 + wobble * 0.25,
652
+ * time: t.secs,
653
+ * });
654
+ * });
655
+ *
656
+ * t.windowResized(() => {
657
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
658
+ * });
659
+ * ```
660
+ *
661
+ * @see {@link https://github.com/libretro/glsl-shaders/blob/master/crt/shaders/crt-mattias.glsl | Original shader by Mattias Gustavsson}
662
+ *
663
+ * @category Stylization filters
664
+ */
665
+ export interface CrtMattiasOptions {
666
+ /**
667
+ * Amount of screen curvature/barrel distortion.
668
+ *
669
+ * - `0.0` = flat screen
670
+ * - `0.5` = moderate curvature (default)
671
+ * - `1.0` = maximum curvature
672
+ *
673
+ * @default 0.5
674
+ */
675
+ curvature: number;
676
+ /**
677
+ * Speed of the scrolling scanline effect.
678
+ *
679
+ * Higher values make the scanline crawl faster.
680
+ *
681
+ * @default 1.0
682
+ */
683
+ scanSpeed: number;
684
+ /**
685
+ * Animation time parameter.
686
+ *
687
+ * Increment this value each frame to animate the effect.
688
+ * Typically use elapsed time in seconds or frame count.
689
+ *
690
+ * @default 0.0
691
+ */
692
+ time: number;
693
+ }
694
+ /**
695
+ * Configuration options for the `'scanlines'` filter.
696
+ *
697
+ * A standalone scanline effect that adds horizontal lines to the image
698
+ * to simulate a CRT display or old monitor. More customizable than
699
+ * the scanlines in crtMattias.
700
+ *
701
+ * @example
702
+ * ```javascript
703
+ * const t = textmode.create({
704
+ * width: window.innerWidth,
705
+ * height: window.innerHeight,
706
+ * plugins: [FiltersPlugin],
707
+ * });
708
+ *
709
+ * let video;
710
+ *
711
+ * t.setup(async () => {
712
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
713
+ * video.play();
714
+ * video.loop();
715
+ * video.characters(' .:-=+*#%@');
716
+ * });
717
+ *
718
+ * t.draw(() => {
719
+ * t.background(0);
720
+ * if (video) {
721
+ * t.image(video, t.grid.cols, t.grid.rows);
722
+ * }
723
+ *
724
+ * const wobble = Math.sin(t.secs * 2);
725
+ * t.layers.base.filter('scanlines', {
726
+ * count: 256,
727
+ * lineWidth: 0.5,
728
+ * intensity: 0.7 + wobble * 0.1,
729
+ * speed: 1 + wobble * 0.15,
730
+ * time: t.secs,
731
+ * });
732
+ * });
733
+ *
734
+ * t.windowResized(() => {
735
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
736
+ * });
737
+ * ```
738
+ *
739
+ * @category Stylization filters
740
+ */
741
+ export interface ScanlinesOptions {
742
+ /**
743
+ * Number of scanlines across the image height.
744
+ *
745
+ * Higher values create finer, more dense lines.
746
+ *
747
+ * Minimum value: `10.0`
748
+ *
749
+ * @default 300.0
750
+ */
751
+ count: number;
752
+ /**
753
+ * Width of the lines relative to the spacing.
754
+ *
755
+ * - `0.0` = very thin lines (mostly transparent)
756
+ * - `0.5` = equal line and gap width
757
+ * - `1.0` = solid (no gaps)
758
+ *
759
+ * @default 0.5
760
+ */
761
+ lineWidth: number;
762
+ /**
763
+ * Opacity/darkness of the scanlines.
764
+ *
765
+ * - `0.0` = invisible lines
766
+ * - `0.75` = clearly visible (default)
767
+ * - `1.0` = maximum darkness (solid black lines)
768
+ *
769
+ * @default 0.75
770
+ */
771
+ intensity: number;
772
+ /**
773
+ * Scrolling speed of the lines.
774
+ *
775
+ * - `0.0` = static lines
776
+ * - `1.0` = normal scrolling speed
777
+ * - Higher values = faster scrolling
778
+ *
779
+ * @default 1.0
780
+ */
781
+ speed: number;
782
+ /**
783
+ * Animation time parameter.
784
+ *
785
+ * Increment this value each frame to animate the scrolling effect.
786
+ *
787
+ * @default 0.0
788
+ */
789
+ time: number;
790
+ }
791
+ /**
792
+ * Configuration options for the `'vignette'` filter.
793
+ *
794
+ * Darkens the edges and corners of the image, drawing focus to the center.
795
+ * Useful for creating a cinematic look or highlighting central content.
796
+ *
797
+ * @example
798
+ * ```javascript
799
+ * const t = textmode.create({
800
+ * width: window.innerWidth,
801
+ * height: window.innerHeight,
802
+ * plugins: [FiltersPlugin],
803
+ * });
804
+ *
805
+ * let video;
806
+ *
807
+ * t.setup(async () => {
808
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
809
+ * video.play();
810
+ * video.loop();
811
+ * video.characters(' .:-=+*#%@');
812
+ * });
813
+ *
814
+ * t.draw(() => {
815
+ * t.background(0);
816
+ * if (video) {
817
+ * t.image(video, t.grid.cols, t.grid.rows);
818
+ * }
819
+ *
820
+ * const wobble = Math.sin(t.secs * 2);
821
+ * t.layers.base.filter('vignette', {
822
+ * amount: 0.5 + wobble * 0.2,
823
+ * softness: 0.5,
824
+ * roundness: 0.5 + wobble * 0.15,
825
+ * });
826
+ * });
827
+ *
828
+ * t.windowResized(() => {
829
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
830
+ * });
831
+ * ```
832
+ *
833
+ * @category Stylization filters
834
+ */
835
+ export interface VignetteOptions {
836
+ /**
837
+ * Intensity of the darkening effect.
838
+ *
839
+ * - `0.0` = no vignette
840
+ * - `0.5` = moderate vignette (default)
841
+ * - `1.0` = very dark edges
842
+ *
843
+ * @default 0.5
844
+ */
845
+ amount: number;
846
+ /**
847
+ * Falloff gradient softness.
848
+ *
849
+ * - `0.0` = hard edge (sharp transition)
850
+ * - `0.5` = moderate gradient (default)
851
+ * - `1.0` = very soft, gradual falloff
852
+ *
853
+ * @default 0.5
854
+ */
855
+ softness: number;
856
+ /**
857
+ * Shape of the vignette.
858
+ *
859
+ * - `0.0` = rectangular (follows screen edges)
860
+ * - `0.5` = rounded rectangle (default)
861
+ * - `1.0` = circular/elliptical
862
+ *
863
+ * @default 0.5
864
+ */
865
+ roundness: number;
866
+ }
867
+ /**
868
+ * Configuration options for the `'bloom'` filter.
869
+ *
870
+ * Creates a glow effect around bright areas of the image. Pixels above
871
+ * the brightness threshold emit a soft glow that spreads outward.
872
+ * Perfect for creating neon, glowing text, or dreamy effects.
873
+ *
874
+ * @example
875
+ * ```javascript
876
+ * const t = textmode.create({
877
+ * width: window.innerWidth,
878
+ * height: window.innerHeight,
879
+ * plugins: [FiltersPlugin],
880
+ * });
881
+ *
882
+ * let video;
883
+ *
884
+ * t.setup(async () => {
885
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
886
+ * video.play();
887
+ * video.loop();
888
+ * video.characters(' .:-=+*#%@');
889
+ * });
890
+ *
891
+ * t.draw(() => {
892
+ * t.background(0);
893
+ * if (video) {
894
+ * t.image(video, t.grid.cols, t.grid.rows);
895
+ * }
896
+ *
897
+ * const wobble = Math.sin(t.secs * 2);
898
+ * t.layers.base.filter('bloom', {
899
+ * threshold: 0.5,
900
+ * intensity: 1.2 + wobble * 0.5,
901
+ * radius: 6 + wobble * 2,
902
+ * });
903
+ * });
904
+ *
905
+ * t.windowResized(() => {
906
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
907
+ * });
908
+ * ```
909
+ *
910
+ * @category Stylization filters
911
+ */
912
+ export interface BloomOptions {
913
+ /**
914
+ * Brightness level above which pixels will glow.
915
+ *
916
+ * - `0.0` = everything glows
917
+ * - `0.5` = mid-brightness and above glows (default)
918
+ * - `1.0` = only the brightest pixels glow
919
+ *
920
+ * @default 0.5
921
+ */
922
+ threshold: number;
923
+ /**
924
+ * Strength of the glow effect.
925
+ *
926
+ * - `0.0` = no visible glow
927
+ * - `1.0` = normal glow intensity (default)
928
+ * - `2.0+` = very bright, intense glow
929
+ *
930
+ * @default 1.0
931
+ */
932
+ intensity: number;
933
+ /**
934
+ * Size of the glow spread in pixels.
935
+ *
936
+ * Larger values create a wider, softer glow.
937
+ *
938
+ * - `1.0` = tight glow
939
+ * - `4.0` = moderate spread (default)
940
+ * - `10.0+` = wide, diffuse glow
941
+ *
942
+ * @default 4.0
943
+ */
944
+ radius: number;
945
+ }
946
+ /**
947
+ * Configuration options for the `'filmGrain'` filter.
948
+ *
949
+ * Adds an animated film grain/noise texture overlay to simulate vintage
950
+ * film stock or analog video. The multi-layered noise creates an organic,
951
+ * moving grain pattern that's less visible in darker areas, mimicking
952
+ * real film characteristics.
953
+ *
954
+ * @example
955
+ * ```javascript
956
+ * const t = textmode.create({
957
+ * width: window.innerWidth,
958
+ * height: window.innerHeight,
959
+ * plugins: [FiltersPlugin],
960
+ * });
961
+ *
962
+ * let video;
963
+ *
964
+ * t.setup(async () => {
965
+ * video = await t.loadVideo('https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4');
966
+ * video.play();
967
+ * video.loop();
968
+ * video.characters(' .:-=+*#%@');
969
+ * });
970
+ *
971
+ * t.draw(() => {
972
+ * t.background(0);
973
+ * if (video) {
974
+ * t.image(video, t.grid.cols, t.grid.rows);
975
+ * }
976
+ *
977
+ * const wobble = Math.sin(t.secs * 2);
978
+ * t.layers.base.filter('filmGrain', {
979
+ * intensity: 0.2 + wobble * 0.1,
980
+ * size: 2 + wobble * 0.5,
981
+ * speed: 1 + wobble * 0.2,
982
+ * time: t.secs,
983
+ * });
984
+ * });
985
+ *
986
+ * t.windowResized(() => {
987
+ * t.resizeCanvas(window.innerWidth, window.innerHeight);
988
+ * });
989
+ * ```
990
+ *
991
+ * @category Stylization filters
992
+ */
993
+ export interface FilmGrainOptions {
994
+ /**
995
+ * Strength of the grain effect.
996
+ *
997
+ * - `0.0` = no grain
998
+ * - `0.2` = subtle grain (default)
999
+ * - `0.5+` = heavy, noticeable grain
1000
+ *
1001
+ * @default 0.2
1002
+ */
1003
+ intensity: number;
1004
+ /**
1005
+ * Size of grain particles.
1006
+ *
1007
+ * - `1.0` = fine grain
1008
+ * - `2.0` = medium grain (default)
1009
+ * - `5.0+` = coarse, chunky grain
1010
+ *
1011
+ * @default 2.0
1012
+ */
1013
+ size: number;
1014
+ /**
1015
+ * Animation speed of the grain.
1016
+ *
1017
+ * - `0.0` = static grain (not recommended)
1018
+ * - `1.0` = normal animation speed (default)
1019
+ * - `2.0+` = fast, flickering grain
1020
+ *
1021
+ * @default 1.0
1022
+ */
1023
+ speed: number;
1024
+ /**
1025
+ * Animation time parameter.
1026
+ *
1027
+ * Increment this value each frame to animate the grain effect.
1028
+ *
1029
+ * @default 0.0
1030
+ */
1031
+ time: number;
1032
+ }
1033
+ //# sourceMappingURL=types.d.ts.map