@opentui/core 0.1.88 → 0.1.90
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/3d.js +1 -1
- package/buffer.d.ts +5 -3
- package/index-dwq2qe5p.js +188 -0
- package/index-dwq2qe5p.js.map +10 -0
- package/{index-nkrr8a4c.js → index-e89anq5x.js} +743 -123
- package/{index-nkrr8a4c.js.map → index-e89anq5x.js.map} +13 -13
- package/{index-nyw5p3ep.js → index-k03avn41.js} +985 -328
- package/{index-nyw5p3ep.js.map → index-k03avn41.js.map} +7 -5
- package/index.d.ts +2 -0
- package/index.js +54 -12
- package/index.js.map +1 -1
- package/lib/stdin-parser.d.ts +10 -0
- package/lib/tree-sitter/default-parsers.d.ts +1 -1
- package/lib/tree-sitter/parsers-config.d.ts +15 -0
- package/lib/tree-sitter/resolve-ft.d.ts +3 -0
- package/lib/tree-sitter/types.d.ts +1 -0
- package/package.json +7 -7
- package/parser.worker.js +52 -18
- package/parser.worker.js.map +3 -3
- package/post/effects.d.ts +147 -0
- package/post/filters.d.ts +27 -67
- package/post/matrices.d.ts +20 -0
- package/renderables/Markdown.d.ts +9 -1
- package/renderer.d.ts +12 -1
- package/runtime-plugin-support.js +3 -3
- package/runtime-plugin.js +3 -3
- package/testing/manual-clock.d.ts +1 -0
- package/testing.js +1 -1
- package/types.d.ts +5 -0
- package/zig.d.ts +3 -1
- package/index-e4hzc2j2.js +0 -113
- package/index-e4hzc2j2.js.map +0 -10
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
StdinParser,
|
|
38
38
|
StyledText,
|
|
39
39
|
SystemClock,
|
|
40
|
+
TargetChannel,
|
|
40
41
|
TerminalConsole,
|
|
41
42
|
TerminalPalette,
|
|
42
43
|
TextAttributes,
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
__export,
|
|
46
47
|
addDefaultParsers,
|
|
47
48
|
attributesWithLink,
|
|
49
|
+
basenameToFiletype,
|
|
48
50
|
bg,
|
|
49
51
|
bgBlack,
|
|
50
52
|
bgBlue,
|
|
@@ -87,6 +89,7 @@ import {
|
|
|
87
89
|
envRegistry,
|
|
88
90
|
exports_src,
|
|
89
91
|
extToFiletype,
|
|
92
|
+
extensionToFiletype,
|
|
90
93
|
fg,
|
|
91
94
|
fonts,
|
|
92
95
|
generateEnvColored,
|
|
@@ -105,6 +108,7 @@ import {
|
|
|
105
108
|
hastToStyledText,
|
|
106
109
|
hexToRgb,
|
|
107
110
|
hsvToRgb,
|
|
111
|
+
infoStringToFiletype,
|
|
108
112
|
instantiate,
|
|
109
113
|
isRenderable,
|
|
110
114
|
isStyledText,
|
|
@@ -158,7 +162,7 @@ import {
|
|
|
158
162
|
white,
|
|
159
163
|
wrapWithDelegates,
|
|
160
164
|
yellow
|
|
161
|
-
} from "./index-
|
|
165
|
+
} from "./index-e89anq5x.js";
|
|
162
166
|
|
|
163
167
|
// src/index.ts
|
|
164
168
|
var exports_src2 = {};
|
|
@@ -217,6 +221,7 @@ __export(exports_src2, {
|
|
|
217
221
|
isStyledText: () => isStyledText,
|
|
218
222
|
isRenderable: () => isRenderable,
|
|
219
223
|
instantiate: () => instantiate,
|
|
224
|
+
infoStringToFiletype: () => infoStringToFiletype,
|
|
220
225
|
hsvToRgb: () => hsvToRgb,
|
|
221
226
|
hexToRgb: () => hexToRgb,
|
|
222
227
|
hastToStyledText: () => hastToStyledText,
|
|
@@ -233,6 +238,7 @@ __export(exports_src2, {
|
|
|
233
238
|
generateEnvColored: () => generateEnvColored,
|
|
234
239
|
fonts: () => fonts,
|
|
235
240
|
fg: () => fg,
|
|
241
|
+
extensionToFiletype: () => extensionToFiletype,
|
|
236
242
|
extToFiletype: () => extToFiletype,
|
|
237
243
|
envRegistry: () => envRegistry,
|
|
238
244
|
env: () => env,
|
|
@@ -277,13 +283,15 @@ __export(exports_src2, {
|
|
|
277
283
|
bgBlue: () => bgBlue,
|
|
278
284
|
bgBlack: () => bgBlack,
|
|
279
285
|
bg: () => bg,
|
|
286
|
+
basenameToFiletype: () => basenameToFiletype,
|
|
280
287
|
attributesWithLink: () => attributesWithLink,
|
|
281
|
-
applySepia: () => applySepia,
|
|
282
288
|
applyScanlines: () => applyScanlines,
|
|
289
|
+
applySaturation: () => applySaturation,
|
|
283
290
|
applyNoise: () => applyNoise,
|
|
284
291
|
applyInvert: () => applyInvert,
|
|
285
|
-
|
|
292
|
+
applyGain: () => applyGain,
|
|
286
293
|
applyChromaticAberration: () => applyChromaticAberration,
|
|
294
|
+
applyBrightness: () => applyBrightness,
|
|
287
295
|
applyAsciiArt: () => applyAsciiArt,
|
|
288
296
|
addDefaultParsers: () => addDefaultParsers,
|
|
289
297
|
Yoga: () => exports_src,
|
|
@@ -303,9 +311,13 @@ __export(exports_src2, {
|
|
|
303
311
|
Text: () => Text,
|
|
304
312
|
TerminalPalette: () => TerminalPalette,
|
|
305
313
|
TerminalConsole: () => TerminalConsole,
|
|
314
|
+
TargetChannel: () => TargetChannel,
|
|
306
315
|
TabSelectRenderableEvents: () => TabSelectRenderableEvents,
|
|
307
316
|
TabSelectRenderable: () => TabSelectRenderable,
|
|
308
317
|
TabSelect: () => TabSelect,
|
|
318
|
+
TRITANOPIA_SIM_MATRIX: () => TRITANOPIA_SIM_MATRIX,
|
|
319
|
+
TRITANOPIA_COMP_MATRIX: () => TRITANOPIA_COMP_MATRIX,
|
|
320
|
+
TECHNICOLOR_MATRIX: () => TECHNICOLOR_MATRIX,
|
|
309
321
|
SystemClock: () => SystemClock,
|
|
310
322
|
SyntaxStyle: () => SyntaxStyle,
|
|
311
323
|
StyledText: () => StyledText,
|
|
@@ -320,13 +332,19 @@ __export(exports_src2, {
|
|
|
320
332
|
ScrollBoxRenderable: () => ScrollBoxRenderable,
|
|
321
333
|
ScrollBox: () => ScrollBox,
|
|
322
334
|
ScrollBarRenderable: () => ScrollBarRenderable,
|
|
335
|
+
SYNTHWAVE_MATRIX: () => SYNTHWAVE_MATRIX,
|
|
336
|
+
SOLARIZATION_MATRIX: () => SOLARIZATION_MATRIX,
|
|
337
|
+
SEPIA_MATRIX: () => SEPIA_MATRIX,
|
|
323
338
|
RootTextNodeRenderable: () => RootTextNodeRenderable,
|
|
324
339
|
RootRenderable: () => RootRenderable,
|
|
325
340
|
RendererControlState: () => RendererControlState,
|
|
326
341
|
RenderableEvents: () => RenderableEvents,
|
|
327
342
|
Renderable: () => Renderable,
|
|
343
|
+
RainbowTextEffect: () => RainbowTextEffect,
|
|
328
344
|
RGBA: () => RGBA,
|
|
329
345
|
PasteEvent: () => PasteEvent,
|
|
346
|
+
PROTANOPIA_SIM_MATRIX: () => PROTANOPIA_SIM_MATRIX,
|
|
347
|
+
PROTANOPIA_COMP_MATRIX: () => PROTANOPIA_COMP_MATRIX,
|
|
330
348
|
OptimizedBuffer: () => OptimizedBuffer,
|
|
331
349
|
NativeSpanFeed: () => NativeSpanFeed,
|
|
332
350
|
MouseParser: () => MouseParser,
|
|
@@ -344,9 +362,13 @@ __export(exports_src2, {
|
|
|
344
362
|
InputRenderableEvents: () => InputRenderableEvents,
|
|
345
363
|
InputRenderable: () => InputRenderable,
|
|
346
364
|
Input: () => Input,
|
|
365
|
+
INVERT_MATRIX: () => INVERT_MATRIX,
|
|
347
366
|
Generic: () => Generic,
|
|
367
|
+
GREENSCALE_MATRIX: () => GREENSCALE_MATRIX,
|
|
368
|
+
GRAYSCALE_MATRIX: () => GRAYSCALE_MATRIX,
|
|
348
369
|
FrameBufferRenderable: () => FrameBufferRenderable,
|
|
349
370
|
FrameBuffer: () => FrameBuffer,
|
|
371
|
+
FlamesEffect: () => FlamesEffect,
|
|
350
372
|
ExtmarksController: () => ExtmarksController,
|
|
351
373
|
EditorView: () => EditorView,
|
|
352
374
|
EditBuffer: () => EditBuffer,
|
|
@@ -354,17 +376,19 @@ __export(exports_src2, {
|
|
|
354
376
|
DiffRenderable: () => DiffRenderable,
|
|
355
377
|
DebugOverlayCorner: () => DebugOverlayCorner,
|
|
356
378
|
DataPathsManager: () => DataPathsManager,
|
|
379
|
+
DEUTERANOPIA_SIM_MATRIX: () => DEUTERANOPIA_SIM_MATRIX,
|
|
380
|
+
DEUTERANOPIA_COMP_MATRIX: () => DEUTERANOPIA_COMP_MATRIX,
|
|
357
381
|
ConsolePosition: () => ConsolePosition,
|
|
358
382
|
CodeRenderable: () => CodeRenderable,
|
|
359
383
|
Code: () => Code,
|
|
384
|
+
CloudsEffect: () => CloudsEffect,
|
|
360
385
|
CliRenderer: () => CliRenderer,
|
|
361
386
|
CliRenderEvents: () => CliRenderEvents,
|
|
362
|
-
|
|
387
|
+
CRTRollingBarEffect: () => CRTRollingBarEffect,
|
|
363
388
|
BoxRenderable: () => BoxRenderable,
|
|
364
389
|
Box: () => Box,
|
|
365
390
|
BorderChars: () => BorderChars,
|
|
366
391
|
BorderCharArrays: () => BorderCharArrays,
|
|
367
|
-
BlurEffect: () => BlurEffect,
|
|
368
392
|
BloomEffect: () => BloomEffect,
|
|
369
393
|
BaseRenderable: () => BaseRenderable,
|
|
370
394
|
ArrowRenderable: () => ArrowRenderable,
|
|
@@ -372,7 +396,8 @@ __export(exports_src2, {
|
|
|
372
396
|
ATTRIBUTE_BASE_BITS: () => ATTRIBUTE_BASE_BITS,
|
|
373
397
|
ASCIIFontSelectionHelper: () => ASCIIFontSelectionHelper,
|
|
374
398
|
ASCIIFontRenderable: () => ASCIIFontRenderable,
|
|
375
|
-
ASCIIFont: () => ASCIIFont
|
|
399
|
+
ASCIIFont: () => ASCIIFont,
|
|
400
|
+
ACHROMATOPSIA_MATRIX: () => ACHROMATOPSIA_MATRIX
|
|
376
401
|
});
|
|
377
402
|
|
|
378
403
|
// src/text-buffer-view.ts
|
|
@@ -1197,141 +1222,7 @@ class SyntaxStyle {
|
|
|
1197
1222
|
this.lib.destroySyntaxStyle(this.stylePtr);
|
|
1198
1223
|
}
|
|
1199
1224
|
}
|
|
1200
|
-
// src/post/
|
|
1201
|
-
function applyScanlines(buffer, strength = 0.8, step = 2) {
|
|
1202
|
-
const width = buffer.width;
|
|
1203
|
-
const height = buffer.height;
|
|
1204
|
-
const bg2 = buffer.buffers.bg;
|
|
1205
|
-
for (let y = 0;y < height; y += step) {
|
|
1206
|
-
for (let x = 0;x < width; x++) {
|
|
1207
|
-
const colorIndex = (y * width + x) * 4;
|
|
1208
|
-
bg2[colorIndex] *= strength;
|
|
1209
|
-
bg2[colorIndex + 1] *= strength;
|
|
1210
|
-
bg2[colorIndex + 2] *= strength;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
function applyGrayscale(buffer) {
|
|
1215
|
-
const size = buffer.width * buffer.height;
|
|
1216
|
-
const fg2 = buffer.buffers.fg;
|
|
1217
|
-
const bg2 = buffer.buffers.bg;
|
|
1218
|
-
for (let i = 0;i < size; i++) {
|
|
1219
|
-
const colorIndex = i * 4;
|
|
1220
|
-
const fgR = fg2[colorIndex];
|
|
1221
|
-
const fgG = fg2[colorIndex + 1];
|
|
1222
|
-
const fgB = fg2[colorIndex + 2];
|
|
1223
|
-
const fgLum = 0.299 * fgR + 0.587 * fgG + 0.114 * fgB;
|
|
1224
|
-
fg2[colorIndex] = fgLum;
|
|
1225
|
-
fg2[colorIndex + 1] = fgLum;
|
|
1226
|
-
fg2[colorIndex + 2] = fgLum;
|
|
1227
|
-
const bgR = bg2[colorIndex];
|
|
1228
|
-
const bgG = bg2[colorIndex + 1];
|
|
1229
|
-
const bgB = bg2[colorIndex + 2];
|
|
1230
|
-
const bgLum = 0.299 * bgR + 0.587 * bgG + 0.114 * bgB;
|
|
1231
|
-
bg2[colorIndex] = bgLum;
|
|
1232
|
-
bg2[colorIndex + 1] = bgLum;
|
|
1233
|
-
bg2[colorIndex + 2] = bgLum;
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
function applySepia(buffer) {
|
|
1237
|
-
const size = buffer.width * buffer.height;
|
|
1238
|
-
const fg2 = buffer.buffers.fg;
|
|
1239
|
-
const bg2 = buffer.buffers.bg;
|
|
1240
|
-
for (let i = 0;i < size; i++) {
|
|
1241
|
-
const colorIndex = i * 4;
|
|
1242
|
-
let fgR = fg2[colorIndex];
|
|
1243
|
-
let fgG = fg2[colorIndex + 1];
|
|
1244
|
-
let fgB = fg2[colorIndex + 2];
|
|
1245
|
-
let newFgR = Math.min(1, fgR * 0.393 + fgG * 0.769 + fgB * 0.189);
|
|
1246
|
-
let newFgG = Math.min(1, fgR * 0.349 + fgG * 0.686 + fgB * 0.168);
|
|
1247
|
-
let newFgB = Math.min(1, fgR * 0.272 + fgG * 0.534 + fgB * 0.131);
|
|
1248
|
-
fg2[colorIndex] = newFgR;
|
|
1249
|
-
fg2[colorIndex + 1] = newFgG;
|
|
1250
|
-
fg2[colorIndex + 2] = newFgB;
|
|
1251
|
-
let bgR = bg2[colorIndex];
|
|
1252
|
-
let bgG = bg2[colorIndex + 1];
|
|
1253
|
-
let bgB = bg2[colorIndex + 2];
|
|
1254
|
-
let newBgR = Math.min(1, bgR * 0.393 + bgG * 0.769 + bgB * 0.189);
|
|
1255
|
-
let newBgG = Math.min(1, bgR * 0.349 + bgG * 0.686 + bgB * 0.168);
|
|
1256
|
-
let newBgB = Math.min(1, bgR * 0.272 + bgG * 0.534 + bgB * 0.131);
|
|
1257
|
-
bg2[colorIndex] = newBgR;
|
|
1258
|
-
bg2[colorIndex + 1] = newBgG;
|
|
1259
|
-
bg2[colorIndex + 2] = newBgB;
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
function applyInvert(buffer) {
|
|
1263
|
-
const size = buffer.width * buffer.height;
|
|
1264
|
-
const fg2 = buffer.buffers.fg;
|
|
1265
|
-
const bg2 = buffer.buffers.bg;
|
|
1266
|
-
for (let i = 0;i < size; i++) {
|
|
1267
|
-
const colorIndex = i * 4;
|
|
1268
|
-
fg2[colorIndex] = 1 - fg2[colorIndex];
|
|
1269
|
-
fg2[colorIndex + 1] = 1 - fg2[colorIndex + 1];
|
|
1270
|
-
fg2[colorIndex + 2] = 1 - fg2[colorIndex + 2];
|
|
1271
|
-
bg2[colorIndex] = 1 - bg2[colorIndex];
|
|
1272
|
-
bg2[colorIndex + 1] = 1 - bg2[colorIndex + 1];
|
|
1273
|
-
bg2[colorIndex + 2] = 1 - bg2[colorIndex + 2];
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
function applyNoise(buffer, strength = 0.1) {
|
|
1277
|
-
const size = buffer.width * buffer.height;
|
|
1278
|
-
const fg2 = buffer.buffers.fg;
|
|
1279
|
-
const bg2 = buffer.buffers.bg;
|
|
1280
|
-
for (let i = 0;i < size; i++) {
|
|
1281
|
-
const colorIndex = i * 4;
|
|
1282
|
-
const noise = (Math.random() - 0.5) * strength;
|
|
1283
|
-
fg2[colorIndex] = Math.max(0, Math.min(1, fg2[colorIndex] + noise));
|
|
1284
|
-
fg2[colorIndex + 1] = Math.max(0, Math.min(1, fg2[colorIndex + 1] + noise));
|
|
1285
|
-
fg2[colorIndex + 2] = Math.max(0, Math.min(1, fg2[colorIndex + 2] + noise));
|
|
1286
|
-
bg2[colorIndex] = Math.max(0, Math.min(1, bg2[colorIndex] + noise));
|
|
1287
|
-
bg2[colorIndex + 1] = Math.max(0, Math.min(1, bg2[colorIndex + 1] + noise));
|
|
1288
|
-
bg2[colorIndex + 2] = Math.max(0, Math.min(1, bg2[colorIndex + 2] + noise));
|
|
1289
|
-
}
|
|
1290
|
-
}
|
|
1291
|
-
function applyChromaticAberration(buffer, strength = 1) {
|
|
1292
|
-
const width = buffer.width;
|
|
1293
|
-
const height = buffer.height;
|
|
1294
|
-
const srcFg = Float32Array.from(buffer.buffers.fg);
|
|
1295
|
-
const destFg = buffer.buffers.fg;
|
|
1296
|
-
const centerX = width / 2;
|
|
1297
|
-
const centerY = height / 2;
|
|
1298
|
-
for (let y = 0;y < height; y++) {
|
|
1299
|
-
for (let x = 0;x < width; x++) {
|
|
1300
|
-
const dx = x - centerX;
|
|
1301
|
-
const dy = y - centerY;
|
|
1302
|
-
const offset = Math.round(Math.sqrt(dx * dx + dy * dy) / Math.max(centerX, centerY) * strength);
|
|
1303
|
-
const rX = Math.max(0, Math.min(width - 1, x - offset));
|
|
1304
|
-
const bX = Math.max(0, Math.min(width - 1, x + offset));
|
|
1305
|
-
const rIndex = (y * width + rX) * 4;
|
|
1306
|
-
const gIndex = (y * width + x) * 4;
|
|
1307
|
-
const bIndex = (y * width + bX) * 4;
|
|
1308
|
-
const destIndex = (y * width + x) * 4;
|
|
1309
|
-
destFg[destIndex] = srcFg[rIndex];
|
|
1310
|
-
destFg[destIndex + 1] = srcFg[gIndex + 1];
|
|
1311
|
-
destFg[destIndex + 2] = srcFg[bIndex + 2];
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
function applyAsciiArt(buffer, ramp = " .:-=+*#%@") {
|
|
1316
|
-
const width = buffer.width;
|
|
1317
|
-
const height = buffer.height;
|
|
1318
|
-
const chars = buffer.buffers.char;
|
|
1319
|
-
const bg2 = buffer.buffers.bg;
|
|
1320
|
-
const rampLength = ramp.length;
|
|
1321
|
-
for (let y = 0;y < height; y++) {
|
|
1322
|
-
for (let x = 0;x < width; x++) {
|
|
1323
|
-
const index = y * width + x;
|
|
1324
|
-
const colorIndex = index * 4;
|
|
1325
|
-
const bgR = bg2[colorIndex];
|
|
1326
|
-
const bgG = bg2[colorIndex + 1];
|
|
1327
|
-
const bgB = bg2[colorIndex + 2];
|
|
1328
|
-
const lum = 0.299 * bgR + 0.587 * bgG + 0.114 * bgB;
|
|
1329
|
-
const rampIndex = Math.min(rampLength - 1, Math.floor(lum * rampLength));
|
|
1330
|
-
chars[index] = ramp[rampIndex].charCodeAt(0);
|
|
1331
|
-
}
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1225
|
+
// src/post/effects.ts
|
|
1335
1226
|
class DistortionEffect {
|
|
1336
1227
|
glitchChancePerSecond = 0.5;
|
|
1337
1228
|
maxGlitchLines = 3;
|
|
@@ -1518,24 +1409,30 @@ class DistortionEffect {
|
|
|
1518
1409
|
|
|
1519
1410
|
class VignetteEffect {
|
|
1520
1411
|
_strength;
|
|
1521
|
-
|
|
1412
|
+
precomputedAttenuationCellMask = null;
|
|
1522
1413
|
cachedWidth = -1;
|
|
1523
1414
|
cachedHeight = -1;
|
|
1415
|
+
static zeroMatrix = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
1524
1416
|
constructor(strength = 0.5) {
|
|
1525
1417
|
this._strength = strength;
|
|
1526
1418
|
}
|
|
1527
1419
|
set strength(newStrength) {
|
|
1528
1420
|
this._strength = Math.max(0, newStrength);
|
|
1421
|
+
this.cachedWidth = -1;
|
|
1422
|
+
this.cachedHeight = -1;
|
|
1423
|
+
this.precomputedAttenuationCellMask = null;
|
|
1529
1424
|
}
|
|
1530
1425
|
get strength() {
|
|
1531
1426
|
return this._strength;
|
|
1532
1427
|
}
|
|
1533
1428
|
_computeFactors(width, height) {
|
|
1534
|
-
this.
|
|
1429
|
+
this.precomputedAttenuationCellMask = new Float32Array(width * height * 3);
|
|
1535
1430
|
const centerX = width / 2;
|
|
1536
1431
|
const centerY = height / 2;
|
|
1537
1432
|
const maxDistSq = centerX * centerX + centerY * centerY;
|
|
1538
1433
|
const safeMaxDistSq = maxDistSq === 0 ? 1 : maxDistSq;
|
|
1434
|
+
const strength = this._strength;
|
|
1435
|
+
let i = 0;
|
|
1539
1436
|
for (let y = 0;y < height; y++) {
|
|
1540
1437
|
const dy = y - centerY;
|
|
1541
1438
|
const dySq = dy * dy;
|
|
@@ -1543,8 +1440,10 @@ class VignetteEffect {
|
|
|
1543
1440
|
const dx = x - centerX;
|
|
1544
1441
|
const distSq = dx * dx + dySq;
|
|
1545
1442
|
const baseAttenuation = Math.min(1, distSq / safeMaxDistSq);
|
|
1546
|
-
const
|
|
1547
|
-
this.
|
|
1443
|
+
const attenuation = baseAttenuation * strength;
|
|
1444
|
+
this.precomputedAttenuationCellMask[i++] = x;
|
|
1445
|
+
this.precomputedAttenuationCellMask[i++] = y;
|
|
1446
|
+
this.precomputedAttenuationCellMask[i++] = attenuation;
|
|
1548
1447
|
}
|
|
1549
1448
|
}
|
|
1550
1449
|
this.cachedWidth = width;
|
|
@@ -1553,215 +1452,683 @@ class VignetteEffect {
|
|
|
1553
1452
|
apply(buffer) {
|
|
1554
1453
|
const width = buffer.width;
|
|
1555
1454
|
const height = buffer.height;
|
|
1556
|
-
|
|
1557
|
-
const size = width * height;
|
|
1558
|
-
if (width !== this.cachedWidth || height !== this.cachedHeight || !this.precomputedBaseAttenuation) {
|
|
1455
|
+
if (width !== this.cachedWidth || height !== this.cachedHeight || !this.precomputedAttenuationCellMask) {
|
|
1559
1456
|
this._computeFactors(width, height);
|
|
1560
1457
|
}
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1458
|
+
buffer.colorMatrix(VignetteEffect.zeroMatrix, this.precomputedAttenuationCellMask, 1, 3);
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
|
|
1462
|
+
class PerlinNoise {
|
|
1463
|
+
perm;
|
|
1464
|
+
grad3 = [
|
|
1465
|
+
[1, 1, 0],
|
|
1466
|
+
[-1, 1, 0],
|
|
1467
|
+
[1, -1, 0],
|
|
1468
|
+
[-1, -1, 0],
|
|
1469
|
+
[1, 0, 1],
|
|
1470
|
+
[-1, 0, 1],
|
|
1471
|
+
[1, 0, -1],
|
|
1472
|
+
[-1, 0, -1],
|
|
1473
|
+
[0, 1, 1],
|
|
1474
|
+
[0, -1, 1],
|
|
1475
|
+
[0, 1, -1],
|
|
1476
|
+
[0, -1, -1]
|
|
1477
|
+
];
|
|
1478
|
+
constructor() {
|
|
1479
|
+
this.perm = new Uint8Array(512);
|
|
1480
|
+
const p = new Uint8Array(256);
|
|
1481
|
+
for (let i = 0;i < 256; i++) {
|
|
1482
|
+
p[i] = i;
|
|
1483
|
+
}
|
|
1484
|
+
for (let i = 255;i > 0; i--) {
|
|
1485
|
+
const r = Math.floor(Math.random() * (i + 1));
|
|
1486
|
+
[p[i], p[r]] = [p[r], p[i]];
|
|
1487
|
+
}
|
|
1488
|
+
for (let i = 0;i < 512; i++) {
|
|
1489
|
+
this.perm[i] = p[i & 255];
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
dot(g, x, y, z) {
|
|
1493
|
+
return g[0] * x + g[1] * y + g[2] * z;
|
|
1494
|
+
}
|
|
1495
|
+
mix(a, b, t2) {
|
|
1496
|
+
return a + (b - a) * t2;
|
|
1497
|
+
}
|
|
1498
|
+
fade(t2) {
|
|
1499
|
+
return t2 * t2 * t2 * (t2 * (t2 * 6 - 15) + 10);
|
|
1500
|
+
}
|
|
1501
|
+
noise3d(x, y, z) {
|
|
1502
|
+
const X = Math.floor(x) & 255;
|
|
1503
|
+
const Y = Math.floor(y) & 255;
|
|
1504
|
+
const Z = Math.floor(z) & 255;
|
|
1505
|
+
const xf = x - Math.floor(x);
|
|
1506
|
+
const yf = y - Math.floor(y);
|
|
1507
|
+
const zf = z - Math.floor(z);
|
|
1508
|
+
const u = this.fade(xf);
|
|
1509
|
+
const v = this.fade(yf);
|
|
1510
|
+
const w = this.fade(zf);
|
|
1511
|
+
const A = this.perm[X] + Y;
|
|
1512
|
+
const AA = this.perm[A] + Z;
|
|
1513
|
+
const AB = this.perm[A + 1] + Z;
|
|
1514
|
+
const B = this.perm[X + 1] + Y;
|
|
1515
|
+
const BA = this.perm[B] + Z;
|
|
1516
|
+
const BB = this.perm[B + 1] + Z;
|
|
1517
|
+
let res = this.mix(this.mix(this.mix(this.dot(this.grad3[this.perm[AA] % 12], xf, yf, zf), this.dot(this.grad3[this.perm[BA] % 12], xf - 1, yf, zf), u), this.mix(this.dot(this.grad3[this.perm[AB] % 12], xf, yf - 1, zf), this.dot(this.grad3[this.perm[BB] % 12], xf - 1, yf - 1, zf), u), v), this.mix(this.mix(this.dot(this.grad3[this.perm[AA + 1] % 12], xf, yf, zf - 1), this.dot(this.grad3[this.perm[BA + 1] % 12], xf - 1, yf, zf - 1), u), this.mix(this.dot(this.grad3[this.perm[AB + 1] % 12], xf, yf - 1, zf - 1), this.dot(this.grad3[this.perm[BB + 1] % 12], xf - 1, yf - 1, zf - 1), u), v), w);
|
|
1518
|
+
return res;
|
|
1571
1519
|
}
|
|
1572
1520
|
}
|
|
1573
1521
|
|
|
1574
|
-
class
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1522
|
+
class CloudsEffect {
|
|
1523
|
+
noise;
|
|
1524
|
+
_scale;
|
|
1525
|
+
_speed;
|
|
1526
|
+
_density;
|
|
1527
|
+
_darkness;
|
|
1528
|
+
time = 0;
|
|
1529
|
+
constructor(scale = 0.02, speed = 0.5, density = 0.6, darkness = 0.7) {
|
|
1530
|
+
this.noise = new PerlinNoise;
|
|
1531
|
+
this._scale = scale;
|
|
1532
|
+
this._speed = speed;
|
|
1533
|
+
this._density = density;
|
|
1534
|
+
this._darkness = darkness;
|
|
1578
1535
|
}
|
|
1579
|
-
set
|
|
1580
|
-
this.
|
|
1536
|
+
set scale(newScale) {
|
|
1537
|
+
this._scale = Math.max(0.001, newScale);
|
|
1581
1538
|
}
|
|
1582
|
-
get
|
|
1583
|
-
return this.
|
|
1539
|
+
get scale() {
|
|
1540
|
+
return this._scale;
|
|
1584
1541
|
}
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1542
|
+
set speed(newSpeed) {
|
|
1543
|
+
this._speed = Math.max(0, newSpeed);
|
|
1544
|
+
}
|
|
1545
|
+
get speed() {
|
|
1546
|
+
return this._speed;
|
|
1547
|
+
}
|
|
1548
|
+
set density(newDensity) {
|
|
1549
|
+
this._density = Math.max(0, Math.min(1, newDensity));
|
|
1550
|
+
}
|
|
1551
|
+
get density() {
|
|
1552
|
+
return this._density;
|
|
1553
|
+
}
|
|
1554
|
+
set darkness(newDarkness) {
|
|
1555
|
+
this._darkness = Math.max(0, Math.min(1, newDarkness));
|
|
1556
|
+
}
|
|
1557
|
+
get darkness() {
|
|
1558
|
+
return this._darkness;
|
|
1559
|
+
}
|
|
1560
|
+
apply(buffer, deltaTime) {
|
|
1561
|
+
const width = buffer.width;
|
|
1562
|
+
const height = buffer.height;
|
|
1563
|
+
this.time += deltaTime * this._speed;
|
|
1564
|
+
const scale = this._scale;
|
|
1565
|
+
const timeOffset = this.time;
|
|
1566
|
+
const cellMask = new Float32Array(width * height * 3);
|
|
1567
|
+
let maskIdx = 0;
|
|
1568
|
+
for (let y = 0;y < height; y++) {
|
|
1569
|
+
for (let x = 0;x < width; x++) {
|
|
1570
|
+
let noiseValue = 0;
|
|
1571
|
+
let amplitude = 1;
|
|
1572
|
+
let frequency = 1;
|
|
1573
|
+
let maxValue = 0;
|
|
1574
|
+
for (let i = 0;i < 4; i++) {
|
|
1575
|
+
const nx = (x * scale * frequency + timeOffset) * 0.5;
|
|
1576
|
+
const ny = y * scale * frequency * 0.5;
|
|
1577
|
+
const nz = timeOffset * 0.3;
|
|
1578
|
+
noiseValue += this.noise.noise3d(nx, ny, nz) * amplitude;
|
|
1579
|
+
maxValue += amplitude;
|
|
1580
|
+
amplitude *= 0.5;
|
|
1581
|
+
frequency *= 2;
|
|
1582
|
+
}
|
|
1583
|
+
noiseValue = (noiseValue / maxValue + 1) * 0.5;
|
|
1584
|
+
const cloudDensity = Math.max(0, noiseValue - (1 - this._density));
|
|
1585
|
+
const attenuation = cloudDensity * this._darkness;
|
|
1586
|
+
cellMask[maskIdx++] = x;
|
|
1587
|
+
cellMask[maskIdx++] = y;
|
|
1588
|
+
cellMask[maskIdx++] = attenuation;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
const zeroMatrix = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
|
1592
|
+
buffer.colorMatrix(zeroMatrix, cellMask, 1, 2);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
class FlamesEffect {
|
|
1597
|
+
noise;
|
|
1598
|
+
_scale;
|
|
1599
|
+
_speed;
|
|
1600
|
+
_intensity;
|
|
1601
|
+
time = 0;
|
|
1602
|
+
constructor(scale = 0.03, speed = 0.02, intensity = 0.8) {
|
|
1603
|
+
this.noise = new PerlinNoise;
|
|
1604
|
+
this._scale = scale;
|
|
1605
|
+
this._speed = speed;
|
|
1606
|
+
this._intensity = intensity;
|
|
1607
|
+
}
|
|
1608
|
+
set scale(newScale) {
|
|
1609
|
+
this._scale = Math.max(0.001, newScale);
|
|
1610
|
+
}
|
|
1611
|
+
get scale() {
|
|
1612
|
+
return this._scale;
|
|
1613
|
+
}
|
|
1614
|
+
set speed(newSpeed) {
|
|
1615
|
+
this._speed = Math.max(0, newSpeed);
|
|
1616
|
+
}
|
|
1617
|
+
get speed() {
|
|
1618
|
+
return this._speed;
|
|
1619
|
+
}
|
|
1620
|
+
set intensity(newIntensity) {
|
|
1621
|
+
this._intensity = Math.max(0, Math.min(1, newIntensity));
|
|
1622
|
+
}
|
|
1623
|
+
get intensity() {
|
|
1624
|
+
return this._intensity;
|
|
1625
|
+
}
|
|
1626
|
+
apply(buffer, deltaTime) {
|
|
1627
|
+
const width = buffer.width;
|
|
1628
|
+
const height = buffer.height;
|
|
1588
1629
|
const bg2 = buffer.buffers.bg;
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1630
|
+
this.time += deltaTime * this._speed;
|
|
1631
|
+
const scale = this._scale;
|
|
1632
|
+
const timeOffset = this.time;
|
|
1633
|
+
for (let y = 0;y < height; y++) {
|
|
1634
|
+
const heightFactor = 1 - y / height;
|
|
1635
|
+
for (let x = 0;x < width; x++) {
|
|
1636
|
+
let noiseValue = 0;
|
|
1637
|
+
let amplitude = 1;
|
|
1638
|
+
let frequency = 1;
|
|
1639
|
+
let maxValue = 0;
|
|
1640
|
+
for (let i = 0;i < 3; i++) {
|
|
1641
|
+
const nx = (x * scale * frequency + timeOffset) * 0.5;
|
|
1642
|
+
const ny = (height - y) * scale * frequency * 2 * 0.5;
|
|
1643
|
+
const nz = timeOffset * 2;
|
|
1644
|
+
noiseValue += this.noise.noise3d(nx, ny, nz) * amplitude;
|
|
1645
|
+
maxValue += amplitude;
|
|
1646
|
+
amplitude *= 0.5;
|
|
1647
|
+
frequency *= 2;
|
|
1648
|
+
}
|
|
1649
|
+
noiseValue = (noiseValue / maxValue + 1) * 0.5;
|
|
1650
|
+
const flameIntensity = noiseValue * heightFactor * this._intensity;
|
|
1651
|
+
if (flameIntensity > 0) {
|
|
1652
|
+
const colorIndex = (y * width + x) * 4;
|
|
1653
|
+
let r, g, b;
|
|
1654
|
+
if (flameIntensity > 0.7) {
|
|
1655
|
+
r = 1;
|
|
1656
|
+
g = 1;
|
|
1657
|
+
b = 0.3 + (flameIntensity - 0.7) * 2.3;
|
|
1658
|
+
} else if (flameIntensity > 0.4) {
|
|
1659
|
+
r = 1;
|
|
1660
|
+
g = 0.5 + (flameIntensity - 0.4) * 1.67;
|
|
1661
|
+
b = 0;
|
|
1662
|
+
} else {
|
|
1663
|
+
r = 0.3 + flameIntensity * 1.75;
|
|
1664
|
+
g = flameIntensity * 0.5;
|
|
1665
|
+
b = 0;
|
|
1666
|
+
}
|
|
1667
|
+
bg2[colorIndex] = Math.max(bg2[colorIndex], r * flameIntensity);
|
|
1668
|
+
bg2[colorIndex + 1] = Math.max(bg2[colorIndex + 1], g * flameIntensity);
|
|
1669
|
+
bg2[colorIndex + 2] = Math.max(bg2[colorIndex + 2], b * flameIntensity);
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1601
1672
|
}
|
|
1602
1673
|
}
|
|
1603
1674
|
}
|
|
1604
1675
|
|
|
1605
|
-
class
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1676
|
+
class CRTRollingBarEffect {
|
|
1677
|
+
_speed;
|
|
1678
|
+
_height;
|
|
1679
|
+
_intensity;
|
|
1680
|
+
_fadeDistance;
|
|
1681
|
+
position = 0;
|
|
1682
|
+
constructor(speed = 0.5, height = 0.15, intensity = 0.3, fadeDistance = 0.3) {
|
|
1683
|
+
this._speed = speed;
|
|
1684
|
+
this._height = Math.max(0.01, Math.min(0.5, height));
|
|
1685
|
+
this._intensity = Math.max(0, Math.min(1, intensity));
|
|
1686
|
+
this._fadeDistance = Math.max(0, Math.min(1, fadeDistance));
|
|
1609
1687
|
}
|
|
1610
|
-
set
|
|
1611
|
-
this.
|
|
1688
|
+
set speed(newSpeed) {
|
|
1689
|
+
this._speed = newSpeed;
|
|
1612
1690
|
}
|
|
1613
|
-
get
|
|
1614
|
-
return this.
|
|
1691
|
+
get speed() {
|
|
1692
|
+
return this._speed;
|
|
1615
1693
|
}
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1694
|
+
set height(newHeight) {
|
|
1695
|
+
this._height = Math.max(0.01, Math.min(0.5, newHeight));
|
|
1696
|
+
}
|
|
1697
|
+
get height() {
|
|
1698
|
+
return this._height;
|
|
1699
|
+
}
|
|
1700
|
+
set intensity(newIntensity) {
|
|
1701
|
+
this._intensity = Math.max(0, Math.min(1, newIntensity));
|
|
1702
|
+
}
|
|
1703
|
+
get intensity() {
|
|
1704
|
+
return this._intensity;
|
|
1705
|
+
}
|
|
1706
|
+
set fadeDistance(newFadeDistance) {
|
|
1707
|
+
this._fadeDistance = Math.max(0, Math.min(1, newFadeDistance));
|
|
1708
|
+
}
|
|
1709
|
+
get fadeDistance() {
|
|
1710
|
+
return this._fadeDistance;
|
|
1711
|
+
}
|
|
1712
|
+
apply(buffer, deltaTime) {
|
|
1620
1713
|
const width = buffer.width;
|
|
1621
1714
|
const height = buffer.height;
|
|
1622
|
-
const
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1627
|
-
const
|
|
1628
|
-
const
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
const tempBufferBg = new Float32Array(size * numChannels);
|
|
1632
|
-
const windowSize = radius * 2 + 1;
|
|
1715
|
+
const fg2 = buffer.buffers.fg;
|
|
1716
|
+
const bg2 = buffer.buffers.bg;
|
|
1717
|
+
this.position += deltaTime / 1000 * this._speed;
|
|
1718
|
+
const cycleHeight = height + this._height * height * 2;
|
|
1719
|
+
this.position = this.position % cycleHeight;
|
|
1720
|
+
const barPixelHeight = this._height * height;
|
|
1721
|
+
const fadePixelDistance = this._fadeDistance * barPixelHeight;
|
|
1722
|
+
const totalEffectHeight = barPixelHeight + fadePixelDistance * 2;
|
|
1723
|
+
const effectCenter = this.position - totalEffectHeight / 2 + barPixelHeight / 2;
|
|
1633
1724
|
for (let y = 0;y < height; y++) {
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1639
|
-
sumR += srcFg[srcIndex];
|
|
1640
|
-
sumG += srcFg[srcIndex + 1];
|
|
1641
|
-
sumB += srcFg[srcIndex + 2];
|
|
1642
|
-
sumA += srcFg[srcIndex + 3];
|
|
1725
|
+
const distFromCenter = Math.abs(y - effectCenter);
|
|
1726
|
+
let barFactor = 0;
|
|
1727
|
+
if (distFromCenter <= totalEffectHeight / 2) {
|
|
1728
|
+
const normalizedDist = distFromCenter / (totalEffectHeight / 2);
|
|
1729
|
+
barFactor = Math.cos(normalizedDist * Math.PI / 2);
|
|
1643
1730
|
}
|
|
1644
|
-
|
|
1645
|
-
const
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
sumA -= srcFg[leavingIndex + 3];
|
|
1656
|
-
const enteringX = Math.max(0, Math.min(width - 1, x + radius + 1));
|
|
1657
|
-
const enteringIndex = (baseRowIndex + enteringX) * numChannels;
|
|
1658
|
-
sumR += srcFg[enteringIndex];
|
|
1659
|
-
sumG += srcFg[enteringIndex + 1];
|
|
1660
|
-
sumB += srcFg[enteringIndex + 2];
|
|
1661
|
-
sumA += srcFg[enteringIndex + 3];
|
|
1731
|
+
if (barFactor > 0.001) {
|
|
1732
|
+
const rowMultiplier = 1 + this._intensity * barFactor;
|
|
1733
|
+
for (let x = 0;x < width; x++) {
|
|
1734
|
+
const colorIndex = (y * width + x) * 4;
|
|
1735
|
+
fg2[colorIndex] = Math.min(1, fg2[colorIndex] * rowMultiplier);
|
|
1736
|
+
fg2[colorIndex + 1] = Math.min(1, fg2[colorIndex + 1] * rowMultiplier);
|
|
1737
|
+
fg2[colorIndex + 2] = Math.min(1, fg2[colorIndex + 2] * rowMultiplier);
|
|
1738
|
+
bg2[colorIndex] = Math.min(1, bg2[colorIndex] * rowMultiplier);
|
|
1739
|
+
bg2[colorIndex + 1] = Math.min(1, bg2[colorIndex + 1] * rowMultiplier);
|
|
1740
|
+
bg2[colorIndex + 2] = Math.min(1, bg2[colorIndex + 2] * rowMultiplier);
|
|
1741
|
+
}
|
|
1662
1742
|
}
|
|
1663
1743
|
}
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1747
|
+
class RainbowTextEffect {
|
|
1748
|
+
_speed;
|
|
1749
|
+
_saturation;
|
|
1750
|
+
_value;
|
|
1751
|
+
_repeats;
|
|
1752
|
+
time = 0;
|
|
1753
|
+
constructor(speed = 0.01, saturation = 1, value = 1, repeats = 3) {
|
|
1754
|
+
this._speed = speed;
|
|
1755
|
+
this._saturation = saturation;
|
|
1756
|
+
this._value = value;
|
|
1757
|
+
this._repeats = repeats;
|
|
1758
|
+
}
|
|
1759
|
+
set speed(newSpeed) {
|
|
1760
|
+
this._speed = Math.max(0, newSpeed);
|
|
1761
|
+
}
|
|
1762
|
+
get speed() {
|
|
1763
|
+
return this._speed;
|
|
1764
|
+
}
|
|
1765
|
+
set saturation(newSaturation) {
|
|
1766
|
+
this._saturation = Math.max(0, Math.min(1, newSaturation));
|
|
1767
|
+
}
|
|
1768
|
+
get saturation() {
|
|
1769
|
+
return this._saturation;
|
|
1770
|
+
}
|
|
1771
|
+
set value(newValue) {
|
|
1772
|
+
this._value = Math.max(0, Math.min(1, newValue));
|
|
1773
|
+
}
|
|
1774
|
+
get value() {
|
|
1775
|
+
return this._value;
|
|
1776
|
+
}
|
|
1777
|
+
set repeats(newRepeats) {
|
|
1778
|
+
this._repeats = Math.max(0.1, newRepeats);
|
|
1779
|
+
}
|
|
1780
|
+
get repeats() {
|
|
1781
|
+
return this._repeats;
|
|
1782
|
+
}
|
|
1783
|
+
hsvToRgb(h2, s, v) {
|
|
1784
|
+
let r = 0, g = 0, b = 0;
|
|
1785
|
+
const i = Math.floor(h2 * 6);
|
|
1786
|
+
const f = h2 * 6 - i;
|
|
1787
|
+
const p = v * (1 - s);
|
|
1788
|
+
const q = v * (1 - f * s);
|
|
1789
|
+
const t2 = v * (1 - (1 - f) * s);
|
|
1790
|
+
switch (i % 6) {
|
|
1791
|
+
case 0:
|
|
1792
|
+
r = v;
|
|
1793
|
+
g = t2;
|
|
1794
|
+
b = p;
|
|
1795
|
+
break;
|
|
1796
|
+
case 1:
|
|
1797
|
+
r = q;
|
|
1798
|
+
g = v;
|
|
1799
|
+
b = p;
|
|
1800
|
+
break;
|
|
1801
|
+
case 2:
|
|
1802
|
+
r = p;
|
|
1803
|
+
g = v;
|
|
1804
|
+
b = t2;
|
|
1805
|
+
break;
|
|
1806
|
+
case 3:
|
|
1807
|
+
r = p;
|
|
1808
|
+
g = q;
|
|
1809
|
+
b = v;
|
|
1810
|
+
break;
|
|
1811
|
+
case 4:
|
|
1812
|
+
r = t2;
|
|
1813
|
+
g = p;
|
|
1814
|
+
b = v;
|
|
1815
|
+
break;
|
|
1816
|
+
case 5:
|
|
1817
|
+
r = v;
|
|
1818
|
+
g = p;
|
|
1819
|
+
b = q;
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
return [r, g, b];
|
|
1823
|
+
}
|
|
1824
|
+
apply(buffer, deltaTime) {
|
|
1825
|
+
const width = buffer.width;
|
|
1826
|
+
const height = buffer.height;
|
|
1827
|
+
const fg2 = buffer.buffers.fg;
|
|
1828
|
+
this.time += deltaTime * this._speed;
|
|
1829
|
+
const saturation = this._saturation;
|
|
1830
|
+
const value = this._value;
|
|
1831
|
+
const repeats = this._repeats;
|
|
1832
|
+
const angleRad = 25 * Math.PI / 180;
|
|
1833
|
+
const cosAngle = Math.cos(angleRad);
|
|
1834
|
+
const sinAngle = Math.sin(angleRad);
|
|
1835
|
+
const whiteThreshold = 0.9;
|
|
1664
1836
|
for (let y = 0;y < height; y++) {
|
|
1665
|
-
let sumR = 0, sumG = 0, sumB = 0, sumA = 0;
|
|
1666
|
-
const baseRowIndex = y * width;
|
|
1667
|
-
for (let x = -radius;x <= radius; x++) {
|
|
1668
|
-
const sampleX = Math.max(0, Math.min(width - 1, x));
|
|
1669
|
-
const srcIndex = (baseRowIndex + sampleX) * numChannels;
|
|
1670
|
-
sumR += srcBg[srcIndex];
|
|
1671
|
-
sumG += srcBg[srcIndex + 1];
|
|
1672
|
-
sumB += srcBg[srcIndex + 2];
|
|
1673
|
-
sumA += srcBg[srcIndex + 3];
|
|
1674
|
-
}
|
|
1675
1837
|
for (let x = 0;x < width; x++) {
|
|
1676
|
-
const
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
sumR += srcBg[enteringIndex];
|
|
1690
|
-
sumG += srcBg[enteringIndex + 1];
|
|
1691
|
-
sumB += srcBg[enteringIndex + 2];
|
|
1692
|
-
sumA += srcBg[enteringIndex + 3];
|
|
1838
|
+
const colorIndex = (y * width + x) * 4;
|
|
1839
|
+
const r = fg2[colorIndex];
|
|
1840
|
+
const g = fg2[colorIndex + 1];
|
|
1841
|
+
const b = fg2[colorIndex + 2];
|
|
1842
|
+
if (r >= whiteThreshold && g >= whiteThreshold && b >= whiteThreshold) {
|
|
1843
|
+
const projection = x * cosAngle + y * sinAngle;
|
|
1844
|
+
const maxProjection = width * cosAngle + height * sinAngle;
|
|
1845
|
+
const hue = (projection / maxProjection * repeats + this.time * 0.1) % 1;
|
|
1846
|
+
const [newR, newG, newB] = this.hsvToRgb(hue, saturation, value);
|
|
1847
|
+
fg2[colorIndex] = newR;
|
|
1848
|
+
fg2[colorIndex + 1] = newG;
|
|
1849
|
+
fg2[colorIndex + 2] = newB;
|
|
1850
|
+
}
|
|
1693
1851
|
}
|
|
1694
1852
|
}
|
|
1853
|
+
}
|
|
1854
|
+
}
|
|
1855
|
+
// src/post/filters.ts
|
|
1856
|
+
function applyScanlines(buffer, strength = 0.8, step = 2) {
|
|
1857
|
+
if (strength === 1 || step < 1)
|
|
1858
|
+
return;
|
|
1859
|
+
const width = buffer.width;
|
|
1860
|
+
const height = buffer.height;
|
|
1861
|
+
const affectedRows = Math.ceil(height / step);
|
|
1862
|
+
const cellCount = width * affectedRows;
|
|
1863
|
+
const cellMask = new Float32Array(cellCount * 3);
|
|
1864
|
+
let maskIdx = 0;
|
|
1865
|
+
for (let y = 0;y < height; y += step) {
|
|
1695
1866
|
for (let x = 0;x < width; x++) {
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1867
|
+
cellMask[maskIdx++] = x;
|
|
1868
|
+
cellMask[maskIdx++] = y;
|
|
1869
|
+
cellMask[maskIdx++] = 1;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
const s = strength;
|
|
1873
|
+
const matrix = new Float32Array([
|
|
1874
|
+
s,
|
|
1875
|
+
0,
|
|
1876
|
+
0,
|
|
1877
|
+
0,
|
|
1878
|
+
0,
|
|
1879
|
+
s,
|
|
1880
|
+
0,
|
|
1881
|
+
0,
|
|
1882
|
+
0,
|
|
1883
|
+
0,
|
|
1884
|
+
s,
|
|
1885
|
+
0,
|
|
1886
|
+
0,
|
|
1887
|
+
0,
|
|
1888
|
+
0,
|
|
1889
|
+
1
|
|
1890
|
+
]);
|
|
1891
|
+
buffer.colorMatrix(matrix, cellMask, 1, 2);
|
|
1892
|
+
}
|
|
1893
|
+
function applyInvert(buffer, strength = 1) {
|
|
1894
|
+
if (strength === 0)
|
|
1895
|
+
return;
|
|
1896
|
+
const matrix = new Float32Array([
|
|
1897
|
+
-1,
|
|
1898
|
+
0,
|
|
1899
|
+
0,
|
|
1900
|
+
1,
|
|
1901
|
+
0,
|
|
1902
|
+
-1,
|
|
1903
|
+
0,
|
|
1904
|
+
1,
|
|
1905
|
+
0,
|
|
1906
|
+
0,
|
|
1907
|
+
-1,
|
|
1908
|
+
1,
|
|
1909
|
+
0,
|
|
1910
|
+
0,
|
|
1911
|
+
0,
|
|
1912
|
+
1
|
|
1913
|
+
]);
|
|
1914
|
+
buffer.colorMatrixUniform(matrix, strength, 3);
|
|
1915
|
+
}
|
|
1916
|
+
function applyNoise(buffer, strength = 0.1) {
|
|
1917
|
+
const width = buffer.width;
|
|
1918
|
+
const height = buffer.height;
|
|
1919
|
+
const size = width * height;
|
|
1920
|
+
if (strength === 0)
|
|
1921
|
+
return;
|
|
1922
|
+
const cellMask = new Float32Array(size * 3);
|
|
1923
|
+
let cellMaskIndex = 0;
|
|
1924
|
+
for (let y = 0;y < height; y++) {
|
|
1925
|
+
for (let x = 0;x < width; x++) {
|
|
1926
|
+
cellMask[cellMaskIndex++] = x;
|
|
1927
|
+
cellMask[cellMaskIndex++] = y;
|
|
1928
|
+
cellMask[cellMaskIndex++] = (Math.random() - 0.5) * 2;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
const b = 1 + strength;
|
|
1932
|
+
const matrix = new Float32Array([
|
|
1933
|
+
b,
|
|
1934
|
+
0,
|
|
1935
|
+
0,
|
|
1936
|
+
0,
|
|
1937
|
+
0,
|
|
1938
|
+
b,
|
|
1939
|
+
0,
|
|
1940
|
+
0,
|
|
1941
|
+
0,
|
|
1942
|
+
0,
|
|
1943
|
+
b,
|
|
1944
|
+
0,
|
|
1945
|
+
0,
|
|
1946
|
+
0,
|
|
1947
|
+
0,
|
|
1948
|
+
1
|
|
1949
|
+
]);
|
|
1950
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
1951
|
+
}
|
|
1952
|
+
function applyChromaticAberration(buffer, strength = 1) {
|
|
1953
|
+
const width = buffer.width;
|
|
1954
|
+
const height = buffer.height;
|
|
1955
|
+
const srcFg = Float32Array.from(buffer.buffers.fg);
|
|
1956
|
+
const destFg = buffer.buffers.fg;
|
|
1957
|
+
const centerX = width / 2;
|
|
1958
|
+
const centerY = height / 2;
|
|
1959
|
+
for (let y = 0;y < height; y++) {
|
|
1960
|
+
for (let x = 0;x < width; x++) {
|
|
1961
|
+
const dx = x - centerX;
|
|
1962
|
+
const dy = y - centerY;
|
|
1963
|
+
const offset = Math.round(Math.sqrt(dx * dx + dy * dy) / Math.max(centerX, centerY) * strength);
|
|
1964
|
+
const rX = Math.max(0, Math.min(width - 1, x - offset));
|
|
1965
|
+
const bX = Math.max(0, Math.min(width - 1, x + offset));
|
|
1966
|
+
const rIndex = (y * width + rX) * 4;
|
|
1967
|
+
const gIndex = (y * width + x) * 4;
|
|
1968
|
+
const bIndex = (y * width + bX) * 4;
|
|
1969
|
+
const destIndex = (y * width + x) * 4;
|
|
1970
|
+
destFg[destIndex] = srcFg[rIndex];
|
|
1971
|
+
destFg[destIndex + 1] = srcFg[gIndex + 1];
|
|
1972
|
+
destFg[destIndex + 2] = srcFg[bIndex + 2];
|
|
1724
1973
|
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function applyAsciiArt(buffer, ramp = ' .\'`^"",:;Il!i><~+_-?][}{1)(|\\/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$', fgColor = { r: 1, g: 1, b: 1 }, bgColor = { r: 0, g: 0, b: 0 }) {
|
|
1977
|
+
const width = buffer.width;
|
|
1978
|
+
const height = buffer.height;
|
|
1979
|
+
const chars = buffer.buffers.char;
|
|
1980
|
+
const bg2 = buffer.buffers.bg;
|
|
1981
|
+
const rampLength = ramp.length;
|
|
1982
|
+
for (let y = 0;y < height; y++) {
|
|
1725
1983
|
for (let x = 0;x < width; x++) {
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
}
|
|
1735
|
-
for (let y = 0;y < height; y++) {
|
|
1736
|
-
const destIndex = (y * width + x) * numChannels;
|
|
1737
|
-
destBg[destIndex] = sumR / windowSize;
|
|
1738
|
-
destBg[destIndex + 1] = sumG / windowSize;
|
|
1739
|
-
destBg[destIndex + 2] = sumB / windowSize;
|
|
1740
|
-
destBg[destIndex + 3] = sumA / windowSize;
|
|
1741
|
-
const leavingY = Math.max(0, Math.min(height - 1, y - radius));
|
|
1742
|
-
const leavingIndex = (leavingY * width + x) * numChannels;
|
|
1743
|
-
sumR -= tempBufferBg[leavingIndex];
|
|
1744
|
-
sumG -= tempBufferBg[leavingIndex + 1];
|
|
1745
|
-
sumB -= tempBufferBg[leavingIndex + 2];
|
|
1746
|
-
sumA -= tempBufferBg[leavingIndex + 3];
|
|
1747
|
-
const enteringY = Math.max(0, Math.min(height - 1, y + radius + 1));
|
|
1748
|
-
const enteringIndex = (enteringY * width + x) * numChannels;
|
|
1749
|
-
sumR += tempBufferBg[enteringIndex];
|
|
1750
|
-
sumG += tempBufferBg[enteringIndex + 1];
|
|
1751
|
-
sumB += tempBufferBg[enteringIndex + 2];
|
|
1752
|
-
sumA += tempBufferBg[enteringIndex + 3];
|
|
1753
|
-
}
|
|
1754
|
-
}
|
|
1755
|
-
const charRamp = [" ", "\u2591", "\u2592", "\u2593", " "];
|
|
1756
|
-
const rampLength = charRamp.length;
|
|
1757
|
-
for (let i = 0;i < size; i++) {
|
|
1758
|
-
const alphaIndex = i * numChannels + 3;
|
|
1759
|
-
const fgAlpha = destFg[alphaIndex];
|
|
1760
|
-
const clampedAlpha = Math.max(0, Math.min(1, fgAlpha));
|
|
1761
|
-
const rampIndex = Math.min(rampLength - 1, Math.floor(clampedAlpha * rampLength));
|
|
1762
|
-
chars[i] = charRamp[rampIndex].charCodeAt(0);
|
|
1984
|
+
const index = y * width + x;
|
|
1985
|
+
const colorIndex = index * 4;
|
|
1986
|
+
const bgR = bg2[colorIndex];
|
|
1987
|
+
const bgG = bg2[colorIndex + 1];
|
|
1988
|
+
const bgB = bg2[colorIndex + 2];
|
|
1989
|
+
const lum = 0.299 * bgR + 0.587 * bgG + 0.114 * bgB;
|
|
1990
|
+
const rampIndex = Math.min(rampLength - 1, Math.floor(lum * rampLength));
|
|
1991
|
+
chars[index] = ramp[rampIndex].charCodeAt(0);
|
|
1763
1992
|
}
|
|
1764
1993
|
}
|
|
1994
|
+
const fgMatrix = new Float32Array([
|
|
1995
|
+
0,
|
|
1996
|
+
0,
|
|
1997
|
+
0,
|
|
1998
|
+
fgColor.r,
|
|
1999
|
+
0,
|
|
2000
|
+
0,
|
|
2001
|
+
0,
|
|
2002
|
+
fgColor.g,
|
|
2003
|
+
0,
|
|
2004
|
+
0,
|
|
2005
|
+
0,
|
|
2006
|
+
fgColor.b,
|
|
2007
|
+
0,
|
|
2008
|
+
0,
|
|
2009
|
+
0,
|
|
2010
|
+
1
|
|
2011
|
+
]);
|
|
2012
|
+
const bgMatrix = new Float32Array([
|
|
2013
|
+
0,
|
|
2014
|
+
0,
|
|
2015
|
+
0,
|
|
2016
|
+
bgColor.r,
|
|
2017
|
+
0,
|
|
2018
|
+
0,
|
|
2019
|
+
0,
|
|
2020
|
+
bgColor.g,
|
|
2021
|
+
0,
|
|
2022
|
+
0,
|
|
2023
|
+
0,
|
|
2024
|
+
bgColor.b,
|
|
2025
|
+
0,
|
|
2026
|
+
0,
|
|
2027
|
+
0,
|
|
2028
|
+
1
|
|
2029
|
+
]);
|
|
2030
|
+
buffer.colorMatrixUniform(fgMatrix, 1, 1);
|
|
2031
|
+
buffer.colorMatrixUniform(bgMatrix, 1, 2);
|
|
2032
|
+
}
|
|
2033
|
+
function applyBrightness(buffer, brightness = 0, cellMask) {
|
|
2034
|
+
if (brightness === 0)
|
|
2035
|
+
return;
|
|
2036
|
+
const b = brightness;
|
|
2037
|
+
const matrix = new Float32Array([
|
|
2038
|
+
1,
|
|
2039
|
+
0,
|
|
2040
|
+
0,
|
|
2041
|
+
b,
|
|
2042
|
+
0,
|
|
2043
|
+
1,
|
|
2044
|
+
0,
|
|
2045
|
+
b,
|
|
2046
|
+
0,
|
|
2047
|
+
0,
|
|
2048
|
+
1,
|
|
2049
|
+
b,
|
|
2050
|
+
0,
|
|
2051
|
+
0,
|
|
2052
|
+
0,
|
|
2053
|
+
1
|
|
2054
|
+
]);
|
|
2055
|
+
if (!cellMask || cellMask.length === 0) {
|
|
2056
|
+
buffer.colorMatrixUniform(matrix, 1, 3);
|
|
2057
|
+
} else {
|
|
2058
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
function applyGain(buffer, gain = 1, cellMask) {
|
|
2062
|
+
if (gain === 1)
|
|
2063
|
+
return;
|
|
2064
|
+
const g = Math.max(0, gain);
|
|
2065
|
+
const matrix = new Float32Array([
|
|
2066
|
+
g,
|
|
2067
|
+
0,
|
|
2068
|
+
0,
|
|
2069
|
+
0,
|
|
2070
|
+
0,
|
|
2071
|
+
g,
|
|
2072
|
+
0,
|
|
2073
|
+
0,
|
|
2074
|
+
0,
|
|
2075
|
+
0,
|
|
2076
|
+
g,
|
|
2077
|
+
0,
|
|
2078
|
+
0,
|
|
2079
|
+
0,
|
|
2080
|
+
0,
|
|
2081
|
+
1
|
|
2082
|
+
]);
|
|
2083
|
+
if (!cellMask || cellMask.length === 0) {
|
|
2084
|
+
buffer.colorMatrixUniform(matrix, 1, 3);
|
|
2085
|
+
} else {
|
|
2086
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
function createSaturationMatrix(saturation) {
|
|
2090
|
+
const s = Math.max(0, saturation);
|
|
2091
|
+
const sr = 0.299 * (1 - s);
|
|
2092
|
+
const sg = 0.587 * (1 - s);
|
|
2093
|
+
const sb = 0.114 * (1 - s);
|
|
2094
|
+
const m00 = sr + s;
|
|
2095
|
+
const m01 = sg;
|
|
2096
|
+
const m02 = sb;
|
|
2097
|
+
const m10 = sr;
|
|
2098
|
+
const m11 = sg + s;
|
|
2099
|
+
const m12 = sb;
|
|
2100
|
+
const m20 = sr;
|
|
2101
|
+
const m21 = sg;
|
|
2102
|
+
const m22 = sb + s;
|
|
2103
|
+
return new Float32Array([
|
|
2104
|
+
m00,
|
|
2105
|
+
m01,
|
|
2106
|
+
m02,
|
|
2107
|
+
0,
|
|
2108
|
+
m10,
|
|
2109
|
+
m11,
|
|
2110
|
+
m12,
|
|
2111
|
+
0,
|
|
2112
|
+
m20,
|
|
2113
|
+
m21,
|
|
2114
|
+
m22,
|
|
2115
|
+
0,
|
|
2116
|
+
0,
|
|
2117
|
+
0,
|
|
2118
|
+
0,
|
|
2119
|
+
1
|
|
2120
|
+
]);
|
|
2121
|
+
}
|
|
2122
|
+
function applySaturation(buffer, cellMask, strength = 1) {
|
|
2123
|
+
if (strength === 1 || strength === 0) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2126
|
+
const matrix = createSaturationMatrix(strength);
|
|
2127
|
+
if (!cellMask || cellMask.length === 0) {
|
|
2128
|
+
buffer.colorMatrixUniform(matrix, 1, 3);
|
|
2129
|
+
} else {
|
|
2130
|
+
buffer.colorMatrix(matrix, cellMask, 1, 3);
|
|
2131
|
+
}
|
|
1765
2132
|
}
|
|
1766
2133
|
|
|
1767
2134
|
class BloomEffect {
|
|
@@ -1847,6 +2214,259 @@ class BloomEffect {
|
|
|
1847
2214
|
}
|
|
1848
2215
|
}
|
|
1849
2216
|
}
|
|
2217
|
+
// src/post/matrices.ts
|
|
2218
|
+
var SEPIA_MATRIX = new Float32Array([
|
|
2219
|
+
0.393,
|
|
2220
|
+
0.769,
|
|
2221
|
+
0.189,
|
|
2222
|
+
0,
|
|
2223
|
+
0.349,
|
|
2224
|
+
0.686,
|
|
2225
|
+
0.168,
|
|
2226
|
+
0,
|
|
2227
|
+
0.272,
|
|
2228
|
+
0.534,
|
|
2229
|
+
0.131,
|
|
2230
|
+
0,
|
|
2231
|
+
0,
|
|
2232
|
+
0,
|
|
2233
|
+
0,
|
|
2234
|
+
1
|
|
2235
|
+
]);
|
|
2236
|
+
var PROTANOPIA_SIM_MATRIX = new Float32Array([
|
|
2237
|
+
0.567,
|
|
2238
|
+
0.433,
|
|
2239
|
+
0,
|
|
2240
|
+
0,
|
|
2241
|
+
0.558,
|
|
2242
|
+
0.442,
|
|
2243
|
+
0,
|
|
2244
|
+
0,
|
|
2245
|
+
0,
|
|
2246
|
+
0.242,
|
|
2247
|
+
0.758,
|
|
2248
|
+
0,
|
|
2249
|
+
0,
|
|
2250
|
+
0,
|
|
2251
|
+
0,
|
|
2252
|
+
1
|
|
2253
|
+
]);
|
|
2254
|
+
var DEUTERANOPIA_SIM_MATRIX = new Float32Array([
|
|
2255
|
+
0.625,
|
|
2256
|
+
0.375,
|
|
2257
|
+
0,
|
|
2258
|
+
0,
|
|
2259
|
+
0.7,
|
|
2260
|
+
0.3,
|
|
2261
|
+
0,
|
|
2262
|
+
0,
|
|
2263
|
+
0,
|
|
2264
|
+
0.3,
|
|
2265
|
+
0.7,
|
|
2266
|
+
0,
|
|
2267
|
+
0,
|
|
2268
|
+
0,
|
|
2269
|
+
0,
|
|
2270
|
+
1
|
|
2271
|
+
]);
|
|
2272
|
+
var TRITANOPIA_SIM_MATRIX = new Float32Array([
|
|
2273
|
+
0.95,
|
|
2274
|
+
0.05,
|
|
2275
|
+
0,
|
|
2276
|
+
0,
|
|
2277
|
+
0,
|
|
2278
|
+
0.433,
|
|
2279
|
+
0.567,
|
|
2280
|
+
0,
|
|
2281
|
+
0,
|
|
2282
|
+
0.475,
|
|
2283
|
+
0.525,
|
|
2284
|
+
0,
|
|
2285
|
+
0,
|
|
2286
|
+
0,
|
|
2287
|
+
0,
|
|
2288
|
+
1
|
|
2289
|
+
]);
|
|
2290
|
+
var ACHROMATOPSIA_MATRIX = new Float32Array([
|
|
2291
|
+
0.299,
|
|
2292
|
+
0.587,
|
|
2293
|
+
0.114,
|
|
2294
|
+
0,
|
|
2295
|
+
0.299,
|
|
2296
|
+
0.587,
|
|
2297
|
+
0.114,
|
|
2298
|
+
0,
|
|
2299
|
+
0.299,
|
|
2300
|
+
0.587,
|
|
2301
|
+
0.114,
|
|
2302
|
+
0,
|
|
2303
|
+
0,
|
|
2304
|
+
0,
|
|
2305
|
+
0,
|
|
2306
|
+
1
|
|
2307
|
+
]);
|
|
2308
|
+
var PROTANOPIA_COMP_MATRIX = new Float32Array([
|
|
2309
|
+
1,
|
|
2310
|
+
0.2,
|
|
2311
|
+
0,
|
|
2312
|
+
0,
|
|
2313
|
+
0,
|
|
2314
|
+
0.9,
|
|
2315
|
+
0.1,
|
|
2316
|
+
0,
|
|
2317
|
+
0,
|
|
2318
|
+
0.1,
|
|
2319
|
+
0.9,
|
|
2320
|
+
0,
|
|
2321
|
+
0,
|
|
2322
|
+
0,
|
|
2323
|
+
0,
|
|
2324
|
+
1
|
|
2325
|
+
]);
|
|
2326
|
+
var DEUTERANOPIA_COMP_MATRIX = new Float32Array([
|
|
2327
|
+
0.9,
|
|
2328
|
+
0.1,
|
|
2329
|
+
0,
|
|
2330
|
+
0,
|
|
2331
|
+
0.2,
|
|
2332
|
+
0.8,
|
|
2333
|
+
0,
|
|
2334
|
+
0,
|
|
2335
|
+
0,
|
|
2336
|
+
0,
|
|
2337
|
+
1,
|
|
2338
|
+
0,
|
|
2339
|
+
0,
|
|
2340
|
+
0,
|
|
2341
|
+
0,
|
|
2342
|
+
1
|
|
2343
|
+
]);
|
|
2344
|
+
var TRITANOPIA_COMP_MATRIX = new Float32Array([
|
|
2345
|
+
1,
|
|
2346
|
+
0,
|
|
2347
|
+
0,
|
|
2348
|
+
0,
|
|
2349
|
+
0,
|
|
2350
|
+
0.9,
|
|
2351
|
+
0.1,
|
|
2352
|
+
0,
|
|
2353
|
+
0.1,
|
|
2354
|
+
0,
|
|
2355
|
+
0.9,
|
|
2356
|
+
0,
|
|
2357
|
+
0,
|
|
2358
|
+
0,
|
|
2359
|
+
0,
|
|
2360
|
+
1
|
|
2361
|
+
]);
|
|
2362
|
+
var TECHNICOLOR_MATRIX = new Float32Array([
|
|
2363
|
+
1.5,
|
|
2364
|
+
-0.2,
|
|
2365
|
+
-0.3,
|
|
2366
|
+
0,
|
|
2367
|
+
-0.3,
|
|
2368
|
+
1.4,
|
|
2369
|
+
-0.1,
|
|
2370
|
+
0,
|
|
2371
|
+
-0.2,
|
|
2372
|
+
-0.2,
|
|
2373
|
+
1.4,
|
|
2374
|
+
0,
|
|
2375
|
+
0,
|
|
2376
|
+
0,
|
|
2377
|
+
0,
|
|
2378
|
+
1
|
|
2379
|
+
]);
|
|
2380
|
+
var SOLARIZATION_MATRIX = new Float32Array([
|
|
2381
|
+
-0.5,
|
|
2382
|
+
0.5,
|
|
2383
|
+
0.5,
|
|
2384
|
+
0,
|
|
2385
|
+
0.5,
|
|
2386
|
+
-0.5,
|
|
2387
|
+
0.5,
|
|
2388
|
+
0,
|
|
2389
|
+
0.5,
|
|
2390
|
+
0.5,
|
|
2391
|
+
-0.5,
|
|
2392
|
+
0,
|
|
2393
|
+
0,
|
|
2394
|
+
0,
|
|
2395
|
+
0,
|
|
2396
|
+
1
|
|
2397
|
+
]);
|
|
2398
|
+
var SYNTHWAVE_MATRIX = new Float32Array([
|
|
2399
|
+
1,
|
|
2400
|
+
0,
|
|
2401
|
+
0.25,
|
|
2402
|
+
0,
|
|
2403
|
+
0.1,
|
|
2404
|
+
0.1,
|
|
2405
|
+
0.1,
|
|
2406
|
+
0,
|
|
2407
|
+
0.25,
|
|
2408
|
+
0,
|
|
2409
|
+
1,
|
|
2410
|
+
0,
|
|
2411
|
+
0,
|
|
2412
|
+
0,
|
|
2413
|
+
0,
|
|
2414
|
+
1
|
|
2415
|
+
]);
|
|
2416
|
+
var GREENSCALE_MATRIX = new Float32Array([
|
|
2417
|
+
0,
|
|
2418
|
+
0,
|
|
2419
|
+
0,
|
|
2420
|
+
0,
|
|
2421
|
+
0.299,
|
|
2422
|
+
0.587,
|
|
2423
|
+
0.114,
|
|
2424
|
+
0,
|
|
2425
|
+
0,
|
|
2426
|
+
0,
|
|
2427
|
+
0,
|
|
2428
|
+
0,
|
|
2429
|
+
0,
|
|
2430
|
+
0,
|
|
2431
|
+
0,
|
|
2432
|
+
1
|
|
2433
|
+
]);
|
|
2434
|
+
var GRAYSCALE_MATRIX = new Float32Array([
|
|
2435
|
+
0.299,
|
|
2436
|
+
0.587,
|
|
2437
|
+
0.114,
|
|
2438
|
+
0,
|
|
2439
|
+
0.299,
|
|
2440
|
+
0.587,
|
|
2441
|
+
0.114,
|
|
2442
|
+
0,
|
|
2443
|
+
0.299,
|
|
2444
|
+
0.587,
|
|
2445
|
+
0.114,
|
|
2446
|
+
0,
|
|
2447
|
+
0,
|
|
2448
|
+
0,
|
|
2449
|
+
0,
|
|
2450
|
+
1
|
|
2451
|
+
]);
|
|
2452
|
+
var INVERT_MATRIX = new Float32Array([
|
|
2453
|
+
-1,
|
|
2454
|
+
0,
|
|
2455
|
+
0,
|
|
2456
|
+
1,
|
|
2457
|
+
0,
|
|
2458
|
+
-1,
|
|
2459
|
+
0,
|
|
2460
|
+
1,
|
|
2461
|
+
0,
|
|
2462
|
+
0,
|
|
2463
|
+
-1,
|
|
2464
|
+
1,
|
|
2465
|
+
0,
|
|
2466
|
+
0,
|
|
2467
|
+
0,
|
|
2468
|
+
1
|
|
2469
|
+
]);
|
|
1850
2470
|
// src/animation/Timeline.ts
|
|
1851
2471
|
var easingFunctions = {
|
|
1852
2472
|
linear: (t2) => t2,
|
|
@@ -9780,10 +10400,17 @@ function parseMarkdownIncremental(newContent, prevState, trailingUnstable = 2) {
|
|
|
9780
10400
|
|
|
9781
10401
|
// src/renderables/Markdown.ts
|
|
9782
10402
|
var TRAILING_MARKDOWN_BLOCK_BREAKS_RE = /(?:\r?\n){2,}$/;
|
|
10403
|
+
function colorsEqual(left, right) {
|
|
10404
|
+
if (!left || !right)
|
|
10405
|
+
return left === right;
|
|
10406
|
+
return left.equals(right);
|
|
10407
|
+
}
|
|
9783
10408
|
|
|
9784
10409
|
class MarkdownRenderable extends Renderable {
|
|
9785
10410
|
_content = "";
|
|
9786
10411
|
_syntaxStyle;
|
|
10412
|
+
_fg;
|
|
10413
|
+
_bg;
|
|
9787
10414
|
_conceal;
|
|
9788
10415
|
_concealCode;
|
|
9789
10416
|
_treeSitterClient;
|
|
@@ -9810,6 +10437,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
9810
10437
|
flexShrink: options.flexShrink ?? 0
|
|
9811
10438
|
});
|
|
9812
10439
|
this._syntaxStyle = options.syntaxStyle;
|
|
10440
|
+
this._fg = options.fg ? parseColor(options.fg) : undefined;
|
|
10441
|
+
this._bg = options.bg ? parseColor(options.bg) : undefined;
|
|
9813
10442
|
this._conceal = options.conceal ?? this._contentDefaultOptions.conceal;
|
|
9814
10443
|
this._concealCode = options.concealCode ?? this._contentDefaultOptions.concealCode;
|
|
9815
10444
|
this._content = options.content ?? this._contentDefaultOptions.content;
|
|
@@ -9840,6 +10469,26 @@ class MarkdownRenderable extends Renderable {
|
|
|
9840
10469
|
this._styleDirty = true;
|
|
9841
10470
|
}
|
|
9842
10471
|
}
|
|
10472
|
+
get fg() {
|
|
10473
|
+
return this._fg;
|
|
10474
|
+
}
|
|
10475
|
+
set fg(value) {
|
|
10476
|
+
const next = value ? parseColor(value) : undefined;
|
|
10477
|
+
if (!colorsEqual(this._fg, next)) {
|
|
10478
|
+
this._fg = next;
|
|
10479
|
+
this._styleDirty = true;
|
|
10480
|
+
}
|
|
10481
|
+
}
|
|
10482
|
+
get bg() {
|
|
10483
|
+
return this._bg;
|
|
10484
|
+
}
|
|
10485
|
+
set bg(value) {
|
|
10486
|
+
const next = value ? parseColor(value) : undefined;
|
|
10487
|
+
if (!colorsEqual(this._bg, next)) {
|
|
10488
|
+
this._bg = next;
|
|
10489
|
+
this._styleDirty = true;
|
|
10490
|
+
}
|
|
10491
|
+
}
|
|
9843
10492
|
get conceal() {
|
|
9844
10493
|
return this._conceal;
|
|
9845
10494
|
}
|
|
@@ -10034,6 +10683,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
10034
10683
|
content,
|
|
10035
10684
|
filetype: "markdown",
|
|
10036
10685
|
syntaxStyle: this._syntaxStyle,
|
|
10686
|
+
fg: this._fg,
|
|
10687
|
+
bg: this._bg,
|
|
10037
10688
|
conceal: this._conceal,
|
|
10038
10689
|
drawUnstyledText: false,
|
|
10039
10690
|
streaming: true,
|
|
@@ -10047,8 +10698,10 @@ class MarkdownRenderable extends Renderable {
|
|
|
10047
10698
|
return new CodeRenderable(this.ctx, {
|
|
10048
10699
|
id,
|
|
10049
10700
|
content: token.text,
|
|
10050
|
-
filetype: token.lang
|
|
10701
|
+
filetype: infoStringToFiletype(token.lang ?? ""),
|
|
10051
10702
|
syntaxStyle: this._syntaxStyle,
|
|
10703
|
+
fg: this._fg,
|
|
10704
|
+
bg: this._bg,
|
|
10052
10705
|
conceal: this._concealCode,
|
|
10053
10706
|
drawUnstyledText: !(this._streaming && this._concealCode),
|
|
10054
10707
|
streaming: this._streaming,
|
|
@@ -10061,6 +10714,8 @@ class MarkdownRenderable extends Renderable {
|
|
|
10061
10714
|
renderable.content = content;
|
|
10062
10715
|
renderable.filetype = "markdown";
|
|
10063
10716
|
renderable.syntaxStyle = this._syntaxStyle;
|
|
10717
|
+
renderable.fg = this._fg;
|
|
10718
|
+
renderable.bg = this._bg;
|
|
10064
10719
|
renderable.conceal = this._conceal;
|
|
10065
10720
|
renderable.drawUnstyledText = false;
|
|
10066
10721
|
renderable.streaming = true;
|
|
@@ -10068,8 +10723,10 @@ class MarkdownRenderable extends Renderable {
|
|
|
10068
10723
|
}
|
|
10069
10724
|
applyCodeBlockRenderable(renderable, token, marginBottom) {
|
|
10070
10725
|
renderable.content = token.text;
|
|
10071
|
-
renderable.filetype = token.lang
|
|
10726
|
+
renderable.filetype = infoStringToFiletype(token.lang ?? "");
|
|
10072
10727
|
renderable.syntaxStyle = this._syntaxStyle;
|
|
10728
|
+
renderable.fg = this._fg;
|
|
10729
|
+
renderable.bg = this._bg;
|
|
10073
10730
|
renderable.conceal = this._concealCode;
|
|
10074
10731
|
renderable.drawUnstyledText = !(this._streaming && this._concealCode);
|
|
10075
10732
|
renderable.streaming = this._streaming;
|
|
@@ -12613,7 +13270,7 @@ class TimeToFirstDrawRenderable extends Renderable {
|
|
|
12613
13270
|
return Math.max(0, Math.floor(value));
|
|
12614
13271
|
}
|
|
12615
13272
|
}
|
|
12616
|
-
export { TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle,
|
|
13273
|
+
export { TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, DistortionEffect, VignetteEffect, CloudsEffect, FlamesEffect, CRTRollingBarEffect, RainbowTextEffect, applyScanlines, applyInvert, applyNoise, applyChromaticAberration, applyAsciiArt, applyBrightness, applyGain, applySaturation, BloomEffect, SEPIA_MATRIX, PROTANOPIA_SIM_MATRIX, DEUTERANOPIA_SIM_MATRIX, TRITANOPIA_SIM_MATRIX, ACHROMATOPSIA_MATRIX, PROTANOPIA_COMP_MATRIX, DEUTERANOPIA_COMP_MATRIX, TRITANOPIA_COMP_MATRIX, TECHNICOLOR_MATRIX, SOLARIZATION_MATRIX, SYNTHWAVE_MATRIX, GREENSCALE_MATRIX, GRAYSCALE_MATRIX, INVERT_MATRIX, Timeline, engine, createTimeline, SlotRegistry, createSlotRegistry, createCoreSlotRegistry, registerCorePlugin, resolveCoreSlot, SlotRenderable, NativeSpanFeed, FrameBufferRenderable, ASCIIFontRenderable, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, Generic, Box, Text, ASCIIFont, Input, Select, TabSelect, FrameBuffer, Code, ScrollBox, vstyles, VRenderable, LineNumberRenderable, TextRenderable, DiffRenderable, TextareaRenderable, InputRenderableEvents, InputRenderable, TextTableRenderable, MarkdownRenderable, SliderRenderable, ScrollBarRenderable, ArrowRenderable, ScrollBoxRenderable, SelectRenderableEvents, SelectRenderable, TabSelectRenderableEvents, TabSelectRenderable, TimeToFirstDrawRenderable, exports_src2 as exports_src };
|
|
12617
13274
|
|
|
12618
|
-
//# debugId=
|
|
12619
|
-
//# sourceMappingURL=index-
|
|
13275
|
+
//# debugId=22B8DF0D4AE1971464756E2164756E21
|
|
13276
|
+
//# sourceMappingURL=index-k03avn41.js.map
|