@opentui/core 0.1.89 → 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.
@@ -295,6 +295,7 @@ __export(exports_src2, {
295
295
  applyAsciiArt: () => applyAsciiArt,
296
296
  addDefaultParsers: () => addDefaultParsers,
297
297
  Yoga: () => exports_src,
298
+ VignetteEffect: () => VignetteEffect,
298
299
  VRenderable: () => VRenderable,
299
300
  TreeSitterClient: () => TreeSitterClient,
300
301
  Timeline: () => Timeline,
@@ -314,6 +315,9 @@ __export(exports_src2, {
314
315
  TabSelectRenderableEvents: () => TabSelectRenderableEvents,
315
316
  TabSelectRenderable: () => TabSelectRenderable,
316
317
  TabSelect: () => TabSelect,
318
+ TRITANOPIA_SIM_MATRIX: () => TRITANOPIA_SIM_MATRIX,
319
+ TRITANOPIA_COMP_MATRIX: () => TRITANOPIA_COMP_MATRIX,
320
+ TECHNICOLOR_MATRIX: () => TECHNICOLOR_MATRIX,
317
321
  SystemClock: () => SystemClock,
318
322
  SyntaxStyle: () => SyntaxStyle,
319
323
  StyledText: () => StyledText,
@@ -328,13 +332,19 @@ __export(exports_src2, {
328
332
  ScrollBoxRenderable: () => ScrollBoxRenderable,
329
333
  ScrollBox: () => ScrollBox,
330
334
  ScrollBarRenderable: () => ScrollBarRenderable,
335
+ SYNTHWAVE_MATRIX: () => SYNTHWAVE_MATRIX,
336
+ SOLARIZATION_MATRIX: () => SOLARIZATION_MATRIX,
337
+ SEPIA_MATRIX: () => SEPIA_MATRIX,
331
338
  RootTextNodeRenderable: () => RootTextNodeRenderable,
332
339
  RootRenderable: () => RootRenderable,
333
340
  RendererControlState: () => RendererControlState,
334
341
  RenderableEvents: () => RenderableEvents,
335
342
  Renderable: () => Renderable,
343
+ RainbowTextEffect: () => RainbowTextEffect,
336
344
  RGBA: () => RGBA,
337
345
  PasteEvent: () => PasteEvent,
346
+ PROTANOPIA_SIM_MATRIX: () => PROTANOPIA_SIM_MATRIX,
347
+ PROTANOPIA_COMP_MATRIX: () => PROTANOPIA_COMP_MATRIX,
338
348
  OptimizedBuffer: () => OptimizedBuffer,
339
349
  NativeSpanFeed: () => NativeSpanFeed,
340
350
  MouseParser: () => MouseParser,
@@ -352,20 +362,29 @@ __export(exports_src2, {
352
362
  InputRenderableEvents: () => InputRenderableEvents,
353
363
  InputRenderable: () => InputRenderable,
354
364
  Input: () => Input,
365
+ INVERT_MATRIX: () => INVERT_MATRIX,
355
366
  Generic: () => Generic,
367
+ GREENSCALE_MATRIX: () => GREENSCALE_MATRIX,
368
+ GRAYSCALE_MATRIX: () => GRAYSCALE_MATRIX,
356
369
  FrameBufferRenderable: () => FrameBufferRenderable,
357
370
  FrameBuffer: () => FrameBuffer,
371
+ FlamesEffect: () => FlamesEffect,
358
372
  ExtmarksController: () => ExtmarksController,
359
373
  EditorView: () => EditorView,
360
374
  EditBuffer: () => EditBuffer,
375
+ DistortionEffect: () => DistortionEffect,
361
376
  DiffRenderable: () => DiffRenderable,
362
377
  DebugOverlayCorner: () => DebugOverlayCorner,
363
378
  DataPathsManager: () => DataPathsManager,
379
+ DEUTERANOPIA_SIM_MATRIX: () => DEUTERANOPIA_SIM_MATRIX,
380
+ DEUTERANOPIA_COMP_MATRIX: () => DEUTERANOPIA_COMP_MATRIX,
364
381
  ConsolePosition: () => ConsolePosition,
365
382
  CodeRenderable: () => CodeRenderable,
366
383
  Code: () => Code,
384
+ CloudsEffect: () => CloudsEffect,
367
385
  CliRenderer: () => CliRenderer,
368
386
  CliRenderEvents: () => CliRenderEvents,
387
+ CRTRollingBarEffect: () => CRTRollingBarEffect,
369
388
  BoxRenderable: () => BoxRenderable,
370
389
  Box: () => Box,
371
390
  BorderChars: () => BorderChars,
@@ -377,7 +396,8 @@ __export(exports_src2, {
377
396
  ATTRIBUTE_BASE_BITS: () => ATTRIBUTE_BASE_BITS,
378
397
  ASCIIFontSelectionHelper: () => ASCIIFontSelectionHelper,
379
398
  ASCIIFontRenderable: () => ASCIIFontRenderable,
380
- ASCIIFont: () => ASCIIFont
399
+ ASCIIFont: () => ASCIIFont,
400
+ ACHROMATOPSIA_MATRIX: () => ACHROMATOPSIA_MATRIX
381
401
  });
382
402
 
383
403
  // src/text-buffer-view.ts
@@ -1202,6 +1222,636 @@ class SyntaxStyle {
1202
1222
  this.lib.destroySyntaxStyle(this.stylePtr);
1203
1223
  }
1204
1224
  }
1225
+ // src/post/effects.ts
1226
+ class DistortionEffect {
1227
+ glitchChancePerSecond = 0.5;
1228
+ maxGlitchLines = 3;
1229
+ minGlitchDuration = 0.05;
1230
+ maxGlitchDuration = 0.2;
1231
+ maxShiftAmount = 10;
1232
+ shiftFlipRatio = 0.6;
1233
+ colorGlitchChance = 0.2;
1234
+ lastGlitchTime = 0;
1235
+ glitchDuration = 0;
1236
+ activeGlitches = [];
1237
+ constructor(options) {
1238
+ if (options) {
1239
+ Object.assign(this, options);
1240
+ }
1241
+ }
1242
+ apply(buffer, deltaTime) {
1243
+ const width = buffer.width;
1244
+ const height = buffer.height;
1245
+ const buf = buffer.buffers;
1246
+ this.lastGlitchTime += deltaTime;
1247
+ if (this.activeGlitches.length > 0 && this.lastGlitchTime >= this.glitchDuration) {
1248
+ this.activeGlitches = [];
1249
+ this.glitchDuration = 0;
1250
+ }
1251
+ if (this.activeGlitches.length === 0 && Math.random() < this.glitchChancePerSecond * deltaTime) {
1252
+ this.lastGlitchTime = 0;
1253
+ this.glitchDuration = this.minGlitchDuration + Math.random() * (this.maxGlitchDuration - this.minGlitchDuration);
1254
+ const numGlitches = 1 + Math.floor(Math.random() * this.maxGlitchLines);
1255
+ for (let i = 0;i < numGlitches; i++) {
1256
+ const y = Math.floor(Math.random() * height);
1257
+ let type;
1258
+ let amount = 0;
1259
+ const typeRoll = Math.random();
1260
+ if (typeRoll < this.colorGlitchChance) {
1261
+ type = "color";
1262
+ } else {
1263
+ const shiftRoll = (typeRoll - this.colorGlitchChance) / (1 - this.colorGlitchChance);
1264
+ if (shiftRoll < this.shiftFlipRatio) {
1265
+ type = "shift";
1266
+ amount = Math.floor((Math.random() - 0.5) * 2 * this.maxShiftAmount);
1267
+ } else {
1268
+ type = "flip";
1269
+ }
1270
+ }
1271
+ if (!this.activeGlitches.some((g) => g.y === y)) {
1272
+ this.activeGlitches.push({ y, type, amount });
1273
+ }
1274
+ }
1275
+ }
1276
+ if (this.activeGlitches.length > 0) {
1277
+ let tempChar = null;
1278
+ let tempFg = null;
1279
+ let tempBg = null;
1280
+ let tempAttr = null;
1281
+ for (const glitch of this.activeGlitches) {
1282
+ const y = glitch.y;
1283
+ if (y < 0 || y >= height)
1284
+ continue;
1285
+ const baseIndex = y * width;
1286
+ if (glitch.type === "shift" || glitch.type === "flip") {
1287
+ if (!tempChar) {
1288
+ tempChar = new Uint32Array(width);
1289
+ tempFg = new Float32Array(width * 4);
1290
+ tempBg = new Float32Array(width * 4);
1291
+ tempAttr = new Uint8Array(width);
1292
+ }
1293
+ try {
1294
+ tempChar.set(buf.char.subarray(baseIndex, baseIndex + width));
1295
+ tempFg.set(buf.fg.subarray(baseIndex * 4, (baseIndex + width) * 4));
1296
+ tempBg.set(buf.bg.subarray(baseIndex * 4, (baseIndex + width) * 4));
1297
+ tempAttr.set(buf.attributes.subarray(baseIndex, baseIndex + width));
1298
+ } catch (e) {
1299
+ console.error(`Error copying row ${y} for distortion:`, e);
1300
+ continue;
1301
+ }
1302
+ if (glitch.type === "shift") {
1303
+ const shift = glitch.amount;
1304
+ for (let x = 0;x < width; x++) {
1305
+ const srcX = (x - shift + width) % width;
1306
+ const destIndex = baseIndex + x;
1307
+ const srcTempIndex = srcX;
1308
+ buf.char[destIndex] = tempChar[srcTempIndex];
1309
+ buf.attributes[destIndex] = tempAttr[srcTempIndex];
1310
+ const destColorIndex = destIndex * 4;
1311
+ const srcTempColorIndex = srcTempIndex * 4;
1312
+ buf.fg.set(tempFg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
1313
+ buf.bg.set(tempBg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
1314
+ }
1315
+ } else {
1316
+ for (let x = 0;x < width; x++) {
1317
+ const srcX = width - 1 - x;
1318
+ const destIndex = baseIndex + x;
1319
+ const srcTempIndex = srcX;
1320
+ buf.char[destIndex] = tempChar[srcTempIndex];
1321
+ buf.attributes[destIndex] = tempAttr[srcTempIndex];
1322
+ const destColorIndex = destIndex * 4;
1323
+ const srcTempColorIndex = srcTempIndex * 4;
1324
+ buf.fg.set(tempFg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
1325
+ buf.bg.set(tempBg.subarray(srcTempColorIndex, srcTempColorIndex + 4), destColorIndex);
1326
+ }
1327
+ }
1328
+ } else if (glitch.type === "color") {
1329
+ const glitchStart = Math.floor(Math.random() * width);
1330
+ const maxPossibleLength = width - glitchStart;
1331
+ let glitchLength = Math.floor(Math.random() * maxPossibleLength) + 1;
1332
+ if (Math.random() < 0.2) {
1333
+ glitchLength = Math.floor(Math.random() * (width / 4)) + 1;
1334
+ }
1335
+ glitchLength = Math.min(glitchLength, maxPossibleLength);
1336
+ for (let x = glitchStart;x < glitchStart + glitchLength; x++) {
1337
+ if (x >= width)
1338
+ break;
1339
+ const destIndex = baseIndex + x;
1340
+ const destColorIndex = destIndex * 4;
1341
+ let rFg, gFg, bFg, rBg, gBg, bBg;
1342
+ const colorMode = Math.random();
1343
+ if (colorMode < 0.33) {
1344
+ rFg = Math.random();
1345
+ gFg = Math.random();
1346
+ bFg = Math.random();
1347
+ rBg = Math.random();
1348
+ gBg = Math.random();
1349
+ bBg = Math.random();
1350
+ } else if (colorMode < 0.66) {
1351
+ const emphasis = Math.random();
1352
+ if (emphasis < 0.25) {
1353
+ rFg = Math.random();
1354
+ gFg = 0;
1355
+ bFg = 0;
1356
+ } else if (emphasis < 0.5) {
1357
+ rFg = 0;
1358
+ gFg = Math.random();
1359
+ bFg = 0;
1360
+ } else if (emphasis < 0.75) {
1361
+ rFg = 0;
1362
+ gFg = 0;
1363
+ bFg = Math.random();
1364
+ } else {
1365
+ const glitchColorRoll = Math.random();
1366
+ if (glitchColorRoll < 0.33) {
1367
+ rFg = 1;
1368
+ gFg = 0;
1369
+ bFg = 1;
1370
+ } else if (glitchColorRoll < 0.66) {
1371
+ rFg = 0;
1372
+ gFg = 1;
1373
+ bFg = 1;
1374
+ } else {
1375
+ rFg = 1;
1376
+ gFg = 1;
1377
+ bFg = 0;
1378
+ }
1379
+ }
1380
+ if (Math.random() < 0.5) {
1381
+ rBg = 1 - rFg;
1382
+ gBg = 1 - gFg;
1383
+ bBg = 1 - bFg;
1384
+ } else {
1385
+ rBg = rFg * (Math.random() * 0.5 + 0.2);
1386
+ gBg = gFg * (Math.random() * 0.5 + 0.2);
1387
+ bBg = bFg * (Math.random() * 0.5 + 0.2);
1388
+ }
1389
+ } else {
1390
+ rFg = Math.random() > 0.5 ? 1 : 0;
1391
+ gFg = Math.random() > 0.5 ? 1 : 0;
1392
+ bFg = Math.random() > 0.5 ? 1 : 0;
1393
+ rBg = 1 - rFg;
1394
+ gBg = 1 - gFg;
1395
+ bBg = 1 - bFg;
1396
+ }
1397
+ buf.fg[destColorIndex] = rFg;
1398
+ buf.fg[destColorIndex + 1] = gFg;
1399
+ buf.fg[destColorIndex + 2] = bFg;
1400
+ buf.bg[destColorIndex] = rBg;
1401
+ buf.bg[destColorIndex + 1] = gBg;
1402
+ buf.bg[destColorIndex + 2] = bBg;
1403
+ }
1404
+ }
1405
+ }
1406
+ }
1407
+ }
1408
+ }
1409
+
1410
+ class VignetteEffect {
1411
+ _strength;
1412
+ precomputedAttenuationCellMask = null;
1413
+ cachedWidth = -1;
1414
+ cachedHeight = -1;
1415
+ static zeroMatrix = new Float32Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
1416
+ constructor(strength = 0.5) {
1417
+ this._strength = strength;
1418
+ }
1419
+ set strength(newStrength) {
1420
+ this._strength = Math.max(0, newStrength);
1421
+ this.cachedWidth = -1;
1422
+ this.cachedHeight = -1;
1423
+ this.precomputedAttenuationCellMask = null;
1424
+ }
1425
+ get strength() {
1426
+ return this._strength;
1427
+ }
1428
+ _computeFactors(width, height) {
1429
+ this.precomputedAttenuationCellMask = new Float32Array(width * height * 3);
1430
+ const centerX = width / 2;
1431
+ const centerY = height / 2;
1432
+ const maxDistSq = centerX * centerX + centerY * centerY;
1433
+ const safeMaxDistSq = maxDistSq === 0 ? 1 : maxDistSq;
1434
+ const strength = this._strength;
1435
+ let i = 0;
1436
+ for (let y = 0;y < height; y++) {
1437
+ const dy = y - centerY;
1438
+ const dySq = dy * dy;
1439
+ for (let x = 0;x < width; x++) {
1440
+ const dx = x - centerX;
1441
+ const distSq = dx * dx + dySq;
1442
+ const baseAttenuation = Math.min(1, distSq / safeMaxDistSq);
1443
+ const attenuation = baseAttenuation * strength;
1444
+ this.precomputedAttenuationCellMask[i++] = x;
1445
+ this.precomputedAttenuationCellMask[i++] = y;
1446
+ this.precomputedAttenuationCellMask[i++] = attenuation;
1447
+ }
1448
+ }
1449
+ this.cachedWidth = width;
1450
+ this.cachedHeight = height;
1451
+ }
1452
+ apply(buffer) {
1453
+ const width = buffer.width;
1454
+ const height = buffer.height;
1455
+ if (width !== this.cachedWidth || height !== this.cachedHeight || !this.precomputedAttenuationCellMask) {
1456
+ this._computeFactors(width, height);
1457
+ }
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;
1519
+ }
1520
+ }
1521
+
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;
1535
+ }
1536
+ set scale(newScale) {
1537
+ this._scale = Math.max(0.001, newScale);
1538
+ }
1539
+ get scale() {
1540
+ return this._scale;
1541
+ }
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;
1629
+ const bg2 = buffer.buffers.bg;
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
+ }
1672
+ }
1673
+ }
1674
+ }
1675
+
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));
1687
+ }
1688
+ set speed(newSpeed) {
1689
+ this._speed = newSpeed;
1690
+ }
1691
+ get speed() {
1692
+ return this._speed;
1693
+ }
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) {
1713
+ const width = buffer.width;
1714
+ const height = buffer.height;
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;
1724
+ for (let y = 0;y < height; y++) {
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);
1730
+ }
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
+ }
1742
+ }
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;
1836
+ for (let y = 0;y < height; y++) {
1837
+ for (let x = 0;x < width; x++) {
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
+ }
1851
+ }
1852
+ }
1853
+ }
1854
+ }
1205
1855
  // src/post/filters.ts
1206
1856
  function applyScanlines(buffer, strength = 0.8, step = 2) {
1207
1857
  if (strength === 1 || step < 1)
@@ -1564,6 +2214,259 @@ class BloomEffect {
1564
2214
  }
1565
2215
  }
1566
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
+ ]);
1567
2470
  // src/animation/Timeline.ts
1568
2471
  var easingFunctions = {
1569
2472
  linear: (t2) => t2,
@@ -12367,7 +13270,7 @@ class TimeToFirstDrawRenderable extends Renderable {
12367
13270
  return Math.max(0, Math.floor(value));
12368
13271
  }
12369
13272
  }
12370
- export { TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, applyScanlines, applyInvert, applyNoise, applyChromaticAberration, applyAsciiArt, applyBrightness, applyGain, applySaturation, BloomEffect, 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 };
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 };
12371
13274
 
12372
- //# debugId=DC05962D46EF296364756E2164756E21
12373
- //# sourceMappingURL=index-rs5zwr4j.js.map
13275
+ //# debugId=22B8DF0D4AE1971464756E2164756E21
13276
+ //# sourceMappingURL=index-k03avn41.js.map