asciify-engine 1.0.55 → 1.0.56

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/dist/index.cjs CHANGED
@@ -35,6 +35,24 @@ var CHARSETS = {
35
35
  shards: " \u2571\u2572\u2573\u25E4\u25E5\u25E3\u25E2\u25B3\u25B2\u25C6\u25FC\u2588",
36
36
  smoke: " \xB7\u02D9\u205A\u2056\u2236\u2237\u22EE\u22F0\u22F1\u2234\u2235"
37
37
  };
38
+ var CHARSET_SEQUENCES = {
39
+ /** Stars → softcircles → orbs — dreamy space feel */
40
+ cosmic: [CHARSETS.starfield, CHARSETS.circles, CHARSETS.shadows],
41
+ /** Katakana → braille dots → binary — hacker rain */
42
+ rain: [CHARSETS.katakana, CHARSETS.braille, CHARSETS.binary],
43
+ /** Box pipes → Claude glyphs → classic — terminal morph */
44
+ terminal: [CHARSETS.pipes, CHARSETS.claudeCode, CHARSETS.standard],
45
+ /** Shards → blocks → squares — shattering crystal */
46
+ crystal: [CHARSETS.shards, CHARSETS.geometric, CHARSETS.blocks],
47
+ /** Wave glyphs → smoke dots → circles — fluid / organic */
48
+ fluid: [CHARSETS.waves, CHARSETS.smoke, CHARSETS.circles],
49
+ /** Dense classic → art → blocks — maximum detail pulse */
50
+ pulse: [CHARSETS.dense, CHARSETS.standard, CHARSETS.blocks],
51
+ /** Braille → shadows → smoke — ethereal / dream-like */
52
+ dream: [CHARSETS.braille, CHARSETS.shadows, CHARSETS.smoke],
53
+ /** Geometric shapes → shards → starfield — sci-fi angular */
54
+ angular: [CHARSETS.geometric, CHARSETS.shards, CHARSETS.starfield]
55
+ };
38
56
  var ART_STYLE_PRESETS = {
39
57
  classic: {
40
58
  renderMode: "ascii",
@@ -769,7 +787,7 @@ function imageToAsciiFrame(source, options, targetWidth, targetHeight) {
769
787
  const adjustedLum = adjustLuminance(lum, options.brightness, options.contrast);
770
788
  const ditheredLum = applyDither(adjustedLum, x, y, options.ditherStrength);
771
789
  const char = options.customText ? customTextToChar(ditheredLum, options.customText, x, y, cols, invertVal) : luminanceToChar(ditheredLum, options.charset, invertVal);
772
- row.push({ char, r, g, b, a });
790
+ row.push({ char, r, g, b, a, lum: ditheredLum });
773
791
  }
774
792
  frame.push(row);
775
793
  }
@@ -1013,9 +1031,12 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
1013
1031
  ctx.textBaseline = "middle";
1014
1032
  }
1015
1033
  let charWeights = null;
1034
+ const dynFrms = options.charsetFrames;
1035
+ const hasDyn = !!dynFrms?.length;
1036
+ const dynCharset = hasDyn ? dynFrms[Math.floor(Math.max(0, time) * (options.charsetFps ?? 2)) % dynFrms.length] : options.charset;
1016
1037
  if (useFastRect) {
1017
1038
  charWeights = {};
1018
- const csChars = [...options.charset];
1039
+ const csChars = [...dynCharset];
1019
1040
  const csLen = csChars.length;
1020
1041
  for (let i = 0; i < csLen; i++) {
1021
1042
  charWeights[csChars[i]] = Math.max(0.1, (i + 0.3) / csLen);
@@ -1026,7 +1047,9 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
1026
1047
  const rowData = frame[y];
1027
1048
  for (let x = 0; x < cols; x++) {
1028
1049
  const cell = rowData[x];
1029
- if (cell.char === " " || cell.a < 10) continue;
1050
+ if (cell.a < 10) continue;
1051
+ const drawChar = hasDyn && cell.lum != null ? luminanceToChar(cell.lum, dynCharset, isInverted) : cell.char;
1052
+ if (drawChar === " ") continue;
1030
1053
  const animMul = noAnimation ? 1 : getAnimationMultiplier(x, y, cols, rows, time, animStyle, animSpeed);
1031
1054
  if (animMul < 0.05) continue;
1032
1055
  let hoverScale = 1;
@@ -1066,7 +1089,7 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
1066
1089
  color = getCellColorStr(cell, colorMode, acR, acG, acB, isInverted);
1067
1090
  }
1068
1091
  if (useFastRect) {
1069
- const weight = charWeights[cell.char] ?? 0.5;
1092
+ const weight = charWeights[drawChar] ?? 0.5;
1070
1093
  const effAlpha = Math.min(1, cell.a * 0.00392156863 * animMul * (1 + hoverGlow)) * weight;
1071
1094
  if (effAlpha < 0.02) continue;
1072
1095
  if (effAlpha !== lastAlpha) {
@@ -1093,10 +1116,10 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
1093
1116
  if (hoverScale !== 1) {
1094
1117
  ctx.translate(px, py);
1095
1118
  ctx.scale(hoverScale, hoverScale);
1096
- ctx.fillText(cell.char, 0, 0);
1119
+ ctx.fillText(drawChar, 0, 0);
1097
1120
  ctx.setTransform(baseTransform);
1098
1121
  } else {
1099
- ctx.fillText(cell.char, px, py);
1122
+ ctx.fillText(drawChar, px, py);
1100
1123
  }
1101
1124
  }
1102
1125
  }
@@ -2690,6 +2713,7 @@ async function asciifyWebcam(canvas, {
2690
2713
  exports.ART_STYLE_PRESETS = ART_STYLE_PRESETS;
2691
2714
  exports.BACKGROUND_TYPES = BACKGROUND_TYPES;
2692
2715
  exports.CHARSETS = CHARSETS;
2716
+ exports.CHARSET_SEQUENCES = CHARSET_SEQUENCES;
2693
2717
  exports.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
2694
2718
  exports.HOVER_PRESETS = HOVER_PRESETS;
2695
2719
  exports.PALETTE_THEMES = PALETTE_THEMES;