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.
- package/LICENSE +20 -20
- package/README.md +403 -386
- package/dist/textmode.filters.esm.js +5 -6
- package/dist/textmode.filters.umd.js +3 -3
- package/dist/types/index.d.ts +75 -35
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +1033 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +78 -43
package/README.md
CHANGED
|
@@ -1,386 +1,403 @@
|
|
|
1
|
-
# textmode.filters.js
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
|
|
5
|
-
<!-- Add your banner image here when ready -->
|
|
6
|
-
<!-- <img alt="textmode_filters_banner" src="YOUR_BANNER_IMAGE_URL" /> -->
|
|
7
|
-
|
|
8
|
-
| [](https://www.typescriptlang.org/) [](https://www.khronos.org/webgl/) [](https://vitejs.dev/) | [](https://www.npmjs.com/package/textmode.filters.js) [](https://github.com/humanbydefinition/textmode.filters.js/blob/main/LICENSE) | [](https://discord.gg/sjrw8QXNks) [](https://ko-fi.com/V7V8JG2FY) [. Built with [`WebGL2`](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext) fragment shaders, it provides a collection of customizable visual effects that run entirely on the GPU for maximum performance.
|
|
14
|
-
|
|
15
|
-
[Installation](#installation) •
|
|
16
|
-
[Usage](#usage) •
|
|
17
|
-
[Filters](#filters) •
|
|
18
|
-
[Contributing](#contributing)
|
|
19
|
-
|
|
20
|
-
## Features
|
|
21
|
-
|
|
22
|
-
- 🚀 **GPU-accelerated** - All filters run on the GPU via WebGL2 fragment shaders
|
|
23
|
-
- 🎛️ **Customizable parameters** - Fine-tune each filter to your needs
|
|
24
|
-
- 📦 **Lightweight** - Minimal footprint, no external dependencies
|
|
25
|
-
- 🤝 **Open to contributions** - Easy to add your own custom filters!
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm install textmode.filters.js
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
You can also use it via CDN:
|
|
34
|
-
|
|
35
|
-
```html
|
|
36
|
-
<!-- ESM -->
|
|
37
|
-
<script type="module" src="https://unpkg.com/textmode.js/dist/textmode.esm.js"></script>
|
|
38
|
-
<script type="module" src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.esm.js"></script>
|
|
39
|
-
|
|
40
|
-
<!-- UMD -->
|
|
41
|
-
<script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
|
|
42
|
-
<script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Usage
|
|
46
|
-
|
|
47
|
-
### ESM
|
|
48
|
-
|
|
49
|
-
```javascript
|
|
50
|
-
import { textmode } from 'textmode.js';
|
|
51
|
-
import {
|
|
52
|
-
|
|
53
|
-
const t = textmode.create({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
t.draw(() => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### UMD
|
|
70
|
-
|
|
71
|
-
```html
|
|
72
|
-
<script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
|
|
73
|
-
<script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
|
|
74
|
-
<script>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
</script>
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Filters
|
|
86
|
-
|
|
87
|
-
### `brightness`
|
|
88
|
-
|
|
89
|
-
Adjust image brightness *(1.0 = normal, >1 = brighter, <1 = darker)*
|
|
90
|
-
|
|
91
|
-
**Parameters:**
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
**
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
- `
|
|
255
|
-
Default: `0
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
//
|
|
310
|
-
t.layers.base.filter('
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
t.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
//
|
|
326
|
-
t.layers.base.filter('
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
1
|
+
# textmode.filters.js
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<!-- Add your banner image here when ready -->
|
|
6
|
+
<!-- <img alt="textmode_filters_banner" src="YOUR_BANNER_IMAGE_URL" /> -->
|
|
7
|
+
|
|
8
|
+
| [](https://www.typescriptlang.org/) [](https://www.khronos.org/webgl/) [](https://vitejs.dev/) | [](https://www.npmjs.com/package/textmode.filters.js) [](https://github.com/humanbydefinition/textmode.filters.js/blob/main/LICENSE) | [](https://discord.gg/sjrw8QXNks) [](https://ko-fi.com/V7V8JG2FY) [](https://github.com/sponsors/humanbydefinition) |
|
|
9
|
+
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
textmode.filters.js is a GPU-accelerated image filters plugin for [textmode.js](https://code.textmode.art/). Built with [`WebGL2`](https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext) fragment shaders, it provides a collection of customizable visual effects that run entirely on the GPU for maximum performance.
|
|
14
|
+
|
|
15
|
+
[Installation](#installation) •
|
|
16
|
+
[Usage](#usage) •
|
|
17
|
+
[Filters](#filters) •
|
|
18
|
+
[Contributing](#contributing)
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- 🚀 **GPU-accelerated** - All filters run on the GPU via WebGL2 fragment shaders
|
|
23
|
+
- 🎛️ **Customizable parameters** - Fine-tune each filter to your needs
|
|
24
|
+
- 📦 **Lightweight** - Minimal footprint, no external dependencies
|
|
25
|
+
- 🤝 **Open to contributions** - Easy to add your own custom filters!
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install textmode.filters.js
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can also use it via CDN:
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<!-- ESM -->
|
|
37
|
+
<script type="module" src="https://unpkg.com/textmode.js/dist/textmode.esm.js"></script>
|
|
38
|
+
<script type="module" src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.esm.js"></script>
|
|
39
|
+
|
|
40
|
+
<!-- UMD -->
|
|
41
|
+
<script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
|
|
42
|
+
<script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### ESM
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
import { textmode } from 'textmode.js';
|
|
51
|
+
import { FiltersPlugin } from 'textmode.filters.js';
|
|
52
|
+
|
|
53
|
+
const t = textmode.create({
|
|
54
|
+
width: 800,
|
|
55
|
+
height: 600,
|
|
56
|
+
plugins: [FiltersPlugin],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
t.draw(() => {
|
|
60
|
+
// Apply filters to layers
|
|
61
|
+
t.layers.base.filter('brightness', 1.2);
|
|
62
|
+
t.layers.base.filter('contrast', { amount: 1.5 });
|
|
63
|
+
|
|
64
|
+
t.background(0);
|
|
65
|
+
// ... draw something ...
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### UMD
|
|
70
|
+
|
|
71
|
+
```html
|
|
72
|
+
<script src="https://unpkg.com/textmode.js/dist/textmode.umd.js"></script>
|
|
73
|
+
<script src="https://unpkg.com/textmode.filters.js/dist/textmode.filters.umd.js"></script>
|
|
74
|
+
<script>
|
|
75
|
+
const t = textmode.create({
|
|
76
|
+
plugins: [FiltersPlugin],
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
t.draw(() => {
|
|
80
|
+
t.layers.base.filter('brightness', 1.3);
|
|
81
|
+
});
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Filters
|
|
86
|
+
|
|
87
|
+
### `brightness`
|
|
88
|
+
|
|
89
|
+
Adjust image brightness *(1.0 = normal, >1 = brighter, <1 = darker)*
|
|
90
|
+
|
|
91
|
+
**Parameters:**
|
|
92
|
+
|
|
93
|
+
- `amount` - Brightness multiplier
|
|
94
|
+
Default: `1.0` | Range: `0.0` - `∞`
|
|
95
|
+
|
|
96
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
### `contrast`
|
|
101
|
+
|
|
102
|
+
Adjust image contrast *(1.0 = normal, >1 = more contrast, <1 = less)*
|
|
103
|
+
|
|
104
|
+
**Parameters:**
|
|
105
|
+
|
|
106
|
+
- `amount` - Contrast multiplier
|
|
107
|
+
Default: `1.0` | Range: `0.0` - `∞`
|
|
108
|
+
|
|
109
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
### `hueRotate`
|
|
114
|
+
|
|
115
|
+
Shift colors around the color wheel
|
|
116
|
+
|
|
117
|
+
**Parameters:**
|
|
118
|
+
|
|
119
|
+
- `angle` - Rotation angle in degrees
|
|
120
|
+
Default: `0.0` | Range: `0.0` - `360.0`
|
|
121
|
+
|
|
122
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### `glitch`
|
|
127
|
+
|
|
128
|
+
Digital glitch effect with RGB channel separation, scanlines, and noise
|
|
129
|
+
|
|
130
|
+
**Parameters:**
|
|
131
|
+
|
|
132
|
+
- `amount` - Glitch intensity
|
|
133
|
+
Default: `0.0` | Range: `0.0` - `∞`
|
|
134
|
+
|
|
135
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
### `chromaticAberration`
|
|
140
|
+
|
|
141
|
+
RGB color channel separation effect that simulates lens distortion
|
|
142
|
+
|
|
143
|
+
**Parameters:**
|
|
144
|
+
|
|
145
|
+
- `amount` - Offset amount in pixels
|
|
146
|
+
Default: `5.0` | Range: `0.0` - `∞`
|
|
147
|
+
- `direction` - Direction of the color separation as `[x, y]`
|
|
148
|
+
Default: `[1.0, 0.0]` (horizontal)
|
|
149
|
+
|
|
150
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
### `pixelate`
|
|
155
|
+
|
|
156
|
+
Reduce image resolution to create a mosaic/pixelated effect
|
|
157
|
+
|
|
158
|
+
**Parameters:**
|
|
159
|
+
|
|
160
|
+
- `pixelSize` - Size of each pixel block in pixels
|
|
161
|
+
Default: `4.0` | Range: `1.0` - `∞`
|
|
162
|
+
|
|
163
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### `gridDistortion`
|
|
168
|
+
|
|
169
|
+
Distort a monospaced character grid by varying the width and height of individual cells. Create wave effects, perspective distortions, or other grid warping effects by providing custom factor arrays.
|
|
170
|
+
|
|
171
|
+
**Parameters:**
|
|
172
|
+
|
|
173
|
+
- `gridSize` - Grid dimensions as `[columns, rows]`
|
|
174
|
+
Default: `[80, 40]` | Maximum: `[128, 128]`
|
|
175
|
+
- `widthFactors` - Array of distortion values (0-1) for each column
|
|
176
|
+
Must contain at least as many elements as columns (max 128)
|
|
177
|
+
- `heightFactors` - Array of distortion values (0-1) for each row
|
|
178
|
+
Must contain at least as many elements as rows (max 128)
|
|
179
|
+
- `widthVariationScale` - Intensity multiplier for width distortion
|
|
180
|
+
Default: `0.5` | Range: `0.0` - `∞`
|
|
181
|
+
- `heightVariationScale` - Intensity multiplier for height distortion
|
|
182
|
+
Default: `0.5` | Range: `0.0` - `∞`
|
|
183
|
+
|
|
184
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
### `crtMattias`
|
|
189
|
+
|
|
190
|
+
CRT monitor emulation effect with screen curvature, animated scanlines, blur, vignette, and film grain noise.
|
|
191
|
+
|
|
192
|
+
**Parameters:**
|
|
193
|
+
|
|
194
|
+
- `curvature` - Amount of screen curvature/barrel distortion
|
|
195
|
+
Default: `0.5` | Range: `0.0` - `1.0`
|
|
196
|
+
- `scanSpeed` - Speed of the scrolling scanline effect
|
|
197
|
+
Default: `1.0` | Range: `0.0` - `10.0`
|
|
198
|
+
- `time` - Animation time
|
|
199
|
+
Default: `0.0`
|
|
200
|
+
|
|
201
|
+
**Author:** [@mattiasgustavsson](https://github.com/mattiasgustavsson)
|
|
202
|
+
**Source:** https://github.com/libretro/glsl-shaders/blob/master/crt/shaders/crt-mattias.glsl
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### `scanlines`
|
|
207
|
+
|
|
208
|
+
A standalone scanline effect that adds horizontal lines to the image to simulate a CRT display or old monitor. Adjustable density, thickness, and movement speed.
|
|
209
|
+
|
|
210
|
+
**Parameters:**
|
|
211
|
+
|
|
212
|
+
- `count` - Number of scanlines
|
|
213
|
+
Default: `300.0` | Range: `10.0` - `∞`
|
|
214
|
+
- `lineWidth` - Width of the lines relative to the spacing
|
|
215
|
+
Default: `0.5` | Range: `0.0` - `1.0`
|
|
216
|
+
- `intensity` - Opacity of the scanlines
|
|
217
|
+
Default: `0.75` | Range: `0.0` - `1.0`
|
|
218
|
+
- `speed` - Scrolling speed of the lines
|
|
219
|
+
Default: `1.0` | Range: `0.0` - `∞`
|
|
220
|
+
- `time` - Animation time
|
|
221
|
+
Default: `0.0`
|
|
222
|
+
|
|
223
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### `vignette`
|
|
228
|
+
|
|
229
|
+
Darkens the edges and corners of the image, drawing focus to the center. Useful for creating a cinematic look or highlighting central content.
|
|
230
|
+
|
|
231
|
+
**Parameters:**
|
|
232
|
+
|
|
233
|
+
- `amount` - Intensity of the darkening effect
|
|
234
|
+
Default: `0.5` | Range: `0.0` - `1.0`
|
|
235
|
+
- `softness` - Falloff gradient softness (0 = hard edge, 1 = very soft)
|
|
236
|
+
Default: `0.5` | Range: `0.0` - `1.0`
|
|
237
|
+
- `roundness` - Shape of the vignette (0 = rectangular, 1 = circular)
|
|
238
|
+
Default: `0.5` | Range: `0.0` - `1.0`
|
|
239
|
+
|
|
240
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### `bloom`
|
|
245
|
+
|
|
246
|
+
Creates a glow effect around bright areas of the image. Pixels above the brightness threshold emit a soft glow that spreads outward, perfect for creating neon, glowing text, or dreamy effects.
|
|
247
|
+
|
|
248
|
+
**Parameters:**
|
|
249
|
+
|
|
250
|
+
- `threshold` - Brightness level above which pixels will glow
|
|
251
|
+
Default: `0.5` | Range: `0.0` - `1.0`
|
|
252
|
+
- `intensity` - Strength of the glow effect
|
|
253
|
+
Default: `1.0` | Range: `0.0` - `∞`
|
|
254
|
+
- `radius` - Size of the glow spread in pixels
|
|
255
|
+
Default: `4.0` | Range: `1.0` - `∞`
|
|
256
|
+
|
|
257
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
### `filmGrain`
|
|
262
|
+
|
|
263
|
+
Adds an animated film grain/noise texture overlay to simulate vintage film stock or analog video. The multi-layered noise creates an organic, moving grain pattern that's less visible in darker areas, mimicking real film characteristics.
|
|
264
|
+
|
|
265
|
+
**Parameters:**
|
|
266
|
+
|
|
267
|
+
- `intensity` - Strength of the grain effect
|
|
268
|
+
Default: `0.2` | Range: `0.0` - `1.0`
|
|
269
|
+
- `size` - Size of grain particles
|
|
270
|
+
Default: `2.0` | Range: `1.0` - `10.0`
|
|
271
|
+
- `speed` - Animation speed of the grain
|
|
272
|
+
Default: `1.0` | Range: `0.0` - `∞`
|
|
273
|
+
- `time` - Animation time parameter
|
|
274
|
+
Default: `0.0`
|
|
275
|
+
|
|
276
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
### `saturation`
|
|
281
|
+
|
|
282
|
+
Adjust color intensity without affecting luminance. Perfect for creating vivid, oversaturated looks or desaturating to grayscale.
|
|
283
|
+
|
|
284
|
+
**Parameters:**
|
|
285
|
+
|
|
286
|
+
- `amount` - Saturation multiplier
|
|
287
|
+
Default: `1.0` | Range: `0.0` (grayscale) - `∞` (vivid)
|
|
288
|
+
|
|
289
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
### `posterize`
|
|
294
|
+
|
|
295
|
+
Reduces the color palette to a limited number of bands, creating a retro quantized look.
|
|
296
|
+
|
|
297
|
+
**Parameters:**
|
|
298
|
+
|
|
299
|
+
- `levels` - Number of color levels per channel
|
|
300
|
+
Default: `4.0` | Range: `1.0` - `∞`
|
|
301
|
+
|
|
302
|
+
**Author:** [@humanbydefinition](https://github.com/humanbydefinition)
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
### Usage examples
|
|
307
|
+
|
|
308
|
+
```javascript
|
|
309
|
+
// Using a single value (shorthand)
|
|
310
|
+
t.layers.base.filter('brightness', 1.5);
|
|
311
|
+
t.layers.base.filter('hueRotate', 180);
|
|
312
|
+
|
|
313
|
+
// Using an options object
|
|
314
|
+
t.layers.base.filter('contrast', { amount: 0.8 });
|
|
315
|
+
t.layers.base.filter('glitch', { amount: 2.0 });
|
|
316
|
+
|
|
317
|
+
// Chaining multiple filters in sequence
|
|
318
|
+
t.layers.base.filter('brightness', 1.2);
|
|
319
|
+
t.layers.base.filter('contrast', 1.3);
|
|
320
|
+
t.layers.base.filter('hueRotate', 90);
|
|
321
|
+
|
|
322
|
+
// Chromatic aberration with custom direction
|
|
323
|
+
t.layers.base.filter('chromaticAberration', { amount: 10, direction: [1, 1] });
|
|
324
|
+
|
|
325
|
+
// Pixelate effect
|
|
326
|
+
t.layers.base.filter('pixelate', 8);
|
|
327
|
+
|
|
328
|
+
// Vignette with custom shape
|
|
329
|
+
t.layers.base.filter('vignette', { amount: 0.7, softness: 0.4, roundness: 1.0 });
|
|
330
|
+
|
|
331
|
+
// Bloom for glowing bright areas
|
|
332
|
+
t.layers.base.filter('bloom', { threshold: 0.6, intensity: 1.5, radius: 8 });
|
|
333
|
+
|
|
334
|
+
// Film grain with animation
|
|
335
|
+
let time = 0;
|
|
336
|
+
t.draw(() => {
|
|
337
|
+
t.layers.base.filter('filmGrain', { intensity: 0.3, size: 2, speed: 1.0, time: time });
|
|
338
|
+
time += 0.016;
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// Saturation adjustments
|
|
342
|
+
t.layers.base.filter('saturation', 0); // Grayscale
|
|
343
|
+
t.layers.base.filter('saturation', 1.5); // Vivid colors
|
|
344
|
+
|
|
345
|
+
// Posterize effect (quantize colors)
|
|
346
|
+
t.layers.base.filter('posterize', { levels: 4 });
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Adding custom filters
|
|
350
|
+
|
|
351
|
+
Want to create your own filter? Check out the [Contributing Guide](CONTRIBUTING.md) for detailed instructions on how to add new filters to this library!
|
|
352
|
+
|
|
353
|
+
The basic structure of a filter shader:
|
|
354
|
+
|
|
355
|
+
```glsl
|
|
356
|
+
#version 300 es
|
|
357
|
+
precision highp float;
|
|
358
|
+
|
|
359
|
+
uniform sampler2D u_texture; // Input texture
|
|
360
|
+
uniform vec2 u_resolution; // Canvas resolution
|
|
361
|
+
uniform float u_yourParam; // Your custom parameter
|
|
362
|
+
|
|
363
|
+
in vec2 v_uv;
|
|
364
|
+
out vec4 fragColor;
|
|
365
|
+
|
|
366
|
+
void main() {
|
|
367
|
+
vec4 color = texture(u_texture, v_uv);
|
|
368
|
+
|
|
369
|
+
// Your filter logic here
|
|
370
|
+
vec3 result = color.rgb; // Modify this!
|
|
371
|
+
|
|
372
|
+
fragColor = vec4(result, color.a);
|
|
373
|
+
}
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Contributing
|
|
377
|
+
|
|
378
|
+
Contributions are welcome and greatly appreciated! 🎉
|
|
379
|
+
|
|
380
|
+
Whether you want to:
|
|
381
|
+
|
|
382
|
+
- 🐛 Report a bug
|
|
383
|
+
- 💡 Suggest a new filter
|
|
384
|
+
- 🔧 Submit a pull request
|
|
385
|
+
- 📖 Improve documentation
|
|
386
|
+
|
|
387
|
+
Please read our [Contributing Guide](CONTRIBUTING.md) to get started.
|
|
388
|
+
|
|
389
|
+
## Related projects
|
|
390
|
+
|
|
391
|
+
- **[textmode.js](https://github.com/humanbydefinition/textmode.js)** - The main textmode.js library
|
|
392
|
+
- **[code.textmode.art](https://code.textmode.art/)** - Documentation & examples
|
|
393
|
+
- **[editor.textmode.art](https://editor.textmode.art/)** - textmode.js web editor
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
<div align="center">
|
|
398
|
+
|
|
399
|
+
<br />
|
|
400
|
+
|
|
401
|
+
**[↑ back to top](#textmodefiltersjs)**
|
|
402
|
+
|
|
403
|
+
</div>
|