asciify-engine 1.0.26 → 1.0.28
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 +51 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -2
- package/dist/index.d.ts +121 -2
- package/dist/index.js +50 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,8 @@ var CHARSETS = {
|
|
|
25
25
|
braille: " \u2801\u2802\u2803\u2804\u2805\u2806\u2807\u2808\u2809\u280A\u280B\u280C\u280D\u280E\u280F\u2810\u2811\u2812\u2813\u2814\u2815\u2816\u2817\u2818\u2819\u281A\u281B\u281C\u281D\u281E\u281F\u2820\u2821\u2822\u2823\u2824\u2825\u2826\u2827\u2828\u2829\u282A\u282B\u282C\u282D\u282E\u282F\u2830\u2831\u2832\u2833\u2834\u2835\u2836\u2837\u2838\u2839\u283A\u283B\u283C\u283D\u283E\u283F\u2840\u2841\u2842\u2843\u2844\u2845\u2846\u2847\u28C0\u28C1\u28C2\u28C3\u28C4\u28C5\u28C6\u28C7\u28C8\u28C9\u28CA\u28CB\u28CC\u28CD\u28CE\u28CF\u28D0\u28D1\u28D2\u28D3\u28D4\u28D5\u28D6\u28D7\u28D8\u28D9\u28DA\u28DB\u28DC\u28DD\u28DE\u28DF\u28E0\u28E1\u28E2\u28E3\u28E4\u28E5\u28E6\u28E7\u28E8\u28E9\u28EA\u28EB\u28EC\u28ED\u28EE\u28EF\u28F0\u28F1\u28F2\u28F3\u28F4\u28F5\u28F6\u28F7\u28F8\u28F9\u28FA\u28FB\u28FC\u28FD\u28FE\u28FF",
|
|
26
26
|
katakana: " \uFF66\uFF67\uFF68\uFF69\uFF6A\uFF6B\uFF6C\uFF6D\uFF6E\uFF6F\uFF71\uFF72\uFF73\uFF74\uFF75\uFF76\uFF77\uFF78\uFF79\uFF7A\uFF7B\uFF7C\uFF7D\uFF7E\uFF7F\uFF80\uFF81\uFF82\uFF83\uFF84\uFF85\uFF86\uFF87\uFF88\uFF89\uFF8A\uFF8B\uFF8C\uFF8D\uFF8E\uFF8F\uFF90\uFF91\uFF92\uFF93\uFF94\uFF95\uFF96\uFF97\uFF98\uFF99\uFF9A\uFF9B\uFF9C\uFF9D",
|
|
27
27
|
musical: " \u2669\u266A\u266B\u266C\u266D\u266E\u266F",
|
|
28
|
-
emoji: " \u2B1B\u{1F7EB}\u{1F7E5}\u{1F7E7}\u{1F7E8}\u{1F7E9}\u{1F7E6}\u{1F7EA}\u2B1C"
|
|
28
|
+
emoji: " \u2B1B\u{1F7EB}\u{1F7E5}\u{1F7E7}\u{1F7E8}\u{1F7E9}\u{1F7E6}\u{1F7EA}\u2B1C",
|
|
29
|
+
circles: " .\xB7:\u2218\u25CB\u25E6\xB0\u2022\u2219"
|
|
29
30
|
};
|
|
30
31
|
var ART_STYLE_PRESETS = {
|
|
31
32
|
classic: {
|
|
@@ -89,6 +90,12 @@ var ART_STYLE_PRESETS = {
|
|
|
89
90
|
renderMode: "ascii",
|
|
90
91
|
charset: CHARSETS.emoji,
|
|
91
92
|
colorMode: "fullcolor"
|
|
93
|
+
},
|
|
94
|
+
circles: {
|
|
95
|
+
renderMode: "ascii",
|
|
96
|
+
charset: CHARSETS.circles,
|
|
97
|
+
colorMode: "accent",
|
|
98
|
+
accentColor: "#d4ff00"
|
|
92
99
|
}
|
|
93
100
|
};
|
|
94
101
|
var DEFAULT_OPTIONS = {
|
|
@@ -2236,6 +2243,47 @@ function asciiTextAnsi(source, options = {}, targetWidth, targetHeight) {
|
|
|
2236
2243
|
return lines.join("\n");
|
|
2237
2244
|
}
|
|
2238
2245
|
|
|
2246
|
+
// src/core/text-frame.ts
|
|
2247
|
+
function buildTextFrame(text, cols, rows, color = "#505050", opacity = 100) {
|
|
2248
|
+
if (!text || cols <= 0 || rows <= 0) return [];
|
|
2249
|
+
const parsed = parseColor(color) ?? { r: 80, g: 80, b: 80 };
|
|
2250
|
+
const pattern = text;
|
|
2251
|
+
const len = pattern.length;
|
|
2252
|
+
return Array.from(
|
|
2253
|
+
{ length: rows },
|
|
2254
|
+
(_, row) => Array.from({ length: cols }, (_2, col) => ({
|
|
2255
|
+
char: pattern[(row * cols + col) % len],
|
|
2256
|
+
r: parsed.r,
|
|
2257
|
+
g: parsed.g,
|
|
2258
|
+
b: parsed.b,
|
|
2259
|
+
a: opacity
|
|
2260
|
+
}))
|
|
2261
|
+
);
|
|
2262
|
+
}
|
|
2263
|
+
function renderTextBackground(ctx, width, height, text, options = {}, hoverPos) {
|
|
2264
|
+
const {
|
|
2265
|
+
fontSize = 10,
|
|
2266
|
+
lineHeight = 1.6,
|
|
2267
|
+
color = "#505050",
|
|
2268
|
+
opacity = 100,
|
|
2269
|
+
hoverEffect = "spotlight",
|
|
2270
|
+
hoverStrength = 0.85,
|
|
2271
|
+
hoverRadius = 0.18,
|
|
2272
|
+
hoverColor = "#d4ff00"
|
|
2273
|
+
} = options;
|
|
2274
|
+
const cols = Math.max(1, Math.floor(width / fontSize));
|
|
2275
|
+
const rows = Math.max(1, Math.floor(height / (fontSize * lineHeight)));
|
|
2276
|
+
const frame = buildTextFrame(text, cols, rows, color, opacity);
|
|
2277
|
+
const renderOpts = {
|
|
2278
|
+
...DEFAULT_OPTIONS,
|
|
2279
|
+
hoverEffect,
|
|
2280
|
+
hoverStrength,
|
|
2281
|
+
hoverRadius,
|
|
2282
|
+
hoverColor
|
|
2283
|
+
};
|
|
2284
|
+
renderFrameToCanvas(ctx, frame, renderOpts, width, height, 0, hoverPos ?? null);
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2239
2287
|
// src/core/record.ts
|
|
2240
2288
|
function createRecorder(canvas, options = {}) {
|
|
2241
2289
|
const {
|
|
@@ -2836,6 +2884,7 @@ exports.asciiTextAnsi = asciiTextAnsi;
|
|
|
2836
2884
|
exports.asciify = asciify;
|
|
2837
2885
|
exports.asciifyGif = asciifyGif;
|
|
2838
2886
|
exports.asciifyVideo = asciifyVideo;
|
|
2887
|
+
exports.buildTextFrame = buildTextFrame;
|
|
2839
2888
|
exports.createRecorder = createRecorder;
|
|
2840
2889
|
exports.gifToAsciiFrames = gifToAsciiFrames;
|
|
2841
2890
|
exports.imageToAsciiFrame = imageToAsciiFrame;
|
|
@@ -2854,6 +2903,7 @@ exports.renderRainBackground = renderRainBackground;
|
|
|
2854
2903
|
exports.renderSilkBackground = renderSilkBackground;
|
|
2855
2904
|
exports.renderStarsBackground = renderStarsBackground;
|
|
2856
2905
|
exports.renderTerrainBackground = renderTerrainBackground;
|
|
2906
|
+
exports.renderTextBackground = renderTextBackground;
|
|
2857
2907
|
exports.renderVoidBackground = renderVoidBackground;
|
|
2858
2908
|
exports.renderWaveBackground = renderWaveBackground;
|
|
2859
2909
|
exports.tryCreateWebGLRenderer = tryCreateWebGLRenderer;
|