asciify-engine 1.0.24 → 1.0.26
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 +28 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -15
- package/dist/index.d.ts +1 -15
- package/dist/index.js +29 -107
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/embed.js +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -121,20 +121,6 @@ declare function renderFrameToCanvas(ctx: CanvasRenderingContext2D, frame: Ascii
|
|
|
121
121
|
intensity?: number;
|
|
122
122
|
} | null): void;
|
|
123
123
|
|
|
124
|
-
/**
|
|
125
|
-
* Embed code generation — serializes ASCII frames into self-contained
|
|
126
|
-
* HTML snippets that replay via the CDN embed runtime.
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Generate a static single-frame embed snippet.
|
|
131
|
-
*/
|
|
132
|
-
declare function generateEmbedCode(frame: AsciiFrame, options: AsciiOptions, width: number, height: number): string;
|
|
133
|
-
/**
|
|
134
|
-
* Generate an animated multi-frame embed snippet (GIF / video).
|
|
135
|
-
*/
|
|
136
|
-
declare function generateAnimatedEmbedCode(frames: AsciiFrame[], options: AsciiOptions, fps: number, width: number, height: number): string;
|
|
137
|
-
|
|
138
124
|
/**
|
|
139
125
|
* Simple one-call asciify API.
|
|
140
126
|
* Wraps imageToAsciiFrame + renderFrameToCanvas behind easy-to-use helpers.
|
|
@@ -685,4 +671,4 @@ interface WebGLRenderer {
|
|
|
685
671
|
*/
|
|
686
672
|
declare function tryCreateWebGLRenderer(canvas: HTMLCanvasElement): WebGLRenderer | null;
|
|
687
673
|
|
|
688
|
-
export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, type AuroraBackgroundOptions, CHARSETS, type CharsetKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type Recorder, type RecorderOptions, type RenderMode, type SilkBackgroundOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebGLRenderer, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyVideo, createRecorder,
|
|
674
|
+
export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, type AuroraBackgroundOptions, CHARSETS, type CharsetKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type Recorder, type RecorderOptions, type RenderMode, type SilkBackgroundOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebGLRenderer, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyVideo, createRecorder, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, recordAndDownload, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderVoidBackground, renderWaveBackground, tryCreateWebGLRenderer, videoToAsciiFrames };
|
package/dist/index.d.ts
CHANGED
|
@@ -121,20 +121,6 @@ declare function renderFrameToCanvas(ctx: CanvasRenderingContext2D, frame: Ascii
|
|
|
121
121
|
intensity?: number;
|
|
122
122
|
} | null): void;
|
|
123
123
|
|
|
124
|
-
/**
|
|
125
|
-
* Embed code generation — serializes ASCII frames into self-contained
|
|
126
|
-
* HTML snippets that replay via the CDN embed runtime.
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Generate a static single-frame embed snippet.
|
|
131
|
-
*/
|
|
132
|
-
declare function generateEmbedCode(frame: AsciiFrame, options: AsciiOptions, width: number, height: number): string;
|
|
133
|
-
/**
|
|
134
|
-
* Generate an animated multi-frame embed snippet (GIF / video).
|
|
135
|
-
*/
|
|
136
|
-
declare function generateAnimatedEmbedCode(frames: AsciiFrame[], options: AsciiOptions, fps: number, width: number, height: number): string;
|
|
137
|
-
|
|
138
124
|
/**
|
|
139
125
|
* Simple one-call asciify API.
|
|
140
126
|
* Wraps imageToAsciiFrame + renderFrameToCanvas behind easy-to-use helpers.
|
|
@@ -685,4 +671,4 @@ interface WebGLRenderer {
|
|
|
685
671
|
*/
|
|
686
672
|
declare function tryCreateWebGLRenderer(canvas: HTMLCanvasElement): WebGLRenderer | null;
|
|
687
673
|
|
|
688
|
-
export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, type AuroraBackgroundOptions, CHARSETS, type CharsetKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type Recorder, type RecorderOptions, type RenderMode, type SilkBackgroundOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebGLRenderer, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyVideo, createRecorder,
|
|
674
|
+
export { ART_STYLE_PRESETS, type AnimationStyle, type ArtStyle, type AsciiBackgroundOptions, type AsciiCell, type AsciiFrame, type AsciiOptions, type AsciiResult, type AsciifySimpleOptions, type AuroraBackgroundOptions, CHARSETS, type CharsetKey, type CircuitBackgroundOptions, type ColorMode, DEFAULT_OPTIONS, type DnaBackgroundOptions, type FireBackgroundOptions, type GridBackgroundOptions, HOVER_PRESETS, type HoverEffect, type HoverPreset, type MorphBackgroundOptions, type MountWaveOptions, type NoiseBackgroundOptions, PALETTE_THEMES, type PaletteTheme, type PulseBackgroundOptions, type RainBackgroundOptions, type Recorder, type RecorderOptions, type RenderMode, type SilkBackgroundOptions, type SourceType, type StarsBackgroundOptions, type TerrainBackgroundOptions, type VoidBackgroundOptions, type WaveBackgroundOptions, type WebGLRenderer, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyVideo, createRecorder, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, recordAndDownload, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderVoidBackground, renderWaveBackground, tryCreateWebGLRenderer, videoToAsciiFrames };
|
package/dist/index.js
CHANGED
|
@@ -581,7 +581,7 @@ function renderWaveBackground(ctx, width, height, time, mousePos = { x: 0.5, y:
|
|
|
581
581
|
} else if (baseColor) {
|
|
582
582
|
ctx.fillStyle = baseColor.replace("{a}", String(alpha));
|
|
583
583
|
} else if (lightMode) {
|
|
584
|
-
ctx.fillStyle = `rgba(
|
|
584
|
+
ctx.fillStyle = `rgba(55,55,55,${alpha * 7})`;
|
|
585
585
|
} else {
|
|
586
586
|
ctx.fillStyle = `rgba(255,255,255,${alpha})`;
|
|
587
587
|
}
|
|
@@ -960,84 +960,6 @@ function renderFrameToCanvas(ctx, frame, options, canvasWidth, canvasHeight, tim
|
|
|
960
960
|
ctx.globalAlpha = 1;
|
|
961
961
|
}
|
|
962
962
|
|
|
963
|
-
// src/core/embed-gen.ts
|
|
964
|
-
var EMBED_CDN_VERSION = "1.0.17";
|
|
965
|
-
function serializeFrame(frame, fullColor) {
|
|
966
|
-
const rows = frame.length;
|
|
967
|
-
const cols = rows > 0 ? frame[0].length : 0;
|
|
968
|
-
const stride = fullColor ? 3 : 1;
|
|
969
|
-
const buf = new Uint8Array(1 + rows * cols * stride);
|
|
970
|
-
buf[0] = stride;
|
|
971
|
-
let i = 1;
|
|
972
|
-
for (let y = 0; y < rows; y++) {
|
|
973
|
-
for (let x = 0; x < cols; x++) {
|
|
974
|
-
const cell = frame[y][x];
|
|
975
|
-
if (fullColor) {
|
|
976
|
-
buf[i++] = cell.r;
|
|
977
|
-
buf[i++] = cell.g;
|
|
978
|
-
buf[i++] = cell.b;
|
|
979
|
-
} else {
|
|
980
|
-
buf[i++] = Math.round(0.299 * cell.r + 0.587 * cell.g + 0.114 * cell.b);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
let binary = "";
|
|
985
|
-
for (let j = 0; j < buf.length; j++) binary += String.fromCharCode(buf[j]);
|
|
986
|
-
return btoa(binary);
|
|
987
|
-
}
|
|
988
|
-
function buildEmbedOpts(options, rows, cols, width, height, fps, animated) {
|
|
989
|
-
const o = {
|
|
990
|
-
r: rows,
|
|
991
|
-
c: cols,
|
|
992
|
-
w: width,
|
|
993
|
-
h: height,
|
|
994
|
-
cs: options.charset,
|
|
995
|
-
cm: options.colorMode,
|
|
996
|
-
as: options.animationStyle,
|
|
997
|
-
sp: options.animationSpeed,
|
|
998
|
-
inv: options.invert,
|
|
999
|
-
hs: options.hoverStrength,
|
|
1000
|
-
hr: options.hoverRadius,
|
|
1001
|
-
he: options.hoverEffect,
|
|
1002
|
-
hc: options.hoverColor,
|
|
1003
|
-
dr: options.dotSizeRatio,
|
|
1004
|
-
dots: options.renderMode === "dots"
|
|
1005
|
-
};
|
|
1006
|
-
if (options.colorMode === "accent") o.ac = options.accentColor;
|
|
1007
|
-
if (fps !== void 0) o.fps = fps;
|
|
1008
|
-
if (animated) o.anim = true;
|
|
1009
|
-
return JSON.stringify(o);
|
|
1010
|
-
}
|
|
1011
|
-
var CDN_SCRIPT = `<script src="https://cdn.jsdelivr.net/npm/asciify-engine@${EMBED_CDN_VERSION}/dist/embed.js" async></script>`;
|
|
1012
|
-
function generateEmbedCode(frame, options, width, height) {
|
|
1013
|
-
const rows = frame.length;
|
|
1014
|
-
if (rows === 0) return "";
|
|
1015
|
-
const cols = frame[0].length;
|
|
1016
|
-
const isFullColor = options.colorMode === "fullcolor";
|
|
1017
|
-
const data = serializeFrame(frame, isFullColor);
|
|
1018
|
-
const id = `ar-${Math.random().toString(36).slice(2, 9)}`;
|
|
1019
|
-
const opts = buildEmbedOpts(options, rows, cols, width, height);
|
|
1020
|
-
return `<!-- Asciify Embed -->
|
|
1021
|
-
<canvas id="${id}" data-asciify-opts='${opts}' width="${width}" height="${height}"></canvas>
|
|
1022
|
-
<script type="application/json" id="${id}-d">"${data}"</script>
|
|
1023
|
-
${CDN_SCRIPT}
|
|
1024
|
-
<!-- /Asciify Embed -->`;
|
|
1025
|
-
}
|
|
1026
|
-
function generateAnimatedEmbedCode(frames, options, fps, width, height) {
|
|
1027
|
-
if (frames.length === 0) return "";
|
|
1028
|
-
const rows = frames[0].length;
|
|
1029
|
-
const cols = frames[0][0].length;
|
|
1030
|
-
const isFullColor = options.colorMode === "fullcolor";
|
|
1031
|
-
const allData = frames.map((f) => serializeFrame(f, isFullColor));
|
|
1032
|
-
const id = `ar-${Math.random().toString(36).slice(2, 9)}`;
|
|
1033
|
-
const opts = buildEmbedOpts(options, rows, cols, width, height, fps, true);
|
|
1034
|
-
return `<!-- Asciify Animated Embed -->
|
|
1035
|
-
<canvas id="${id}" data-asciify-opts='${opts}' width="${width}" height="${height}"></canvas>
|
|
1036
|
-
<script type="application/json" id="${id}-d">${JSON.stringify(allData)}</script>
|
|
1037
|
-
${CDN_SCRIPT}
|
|
1038
|
-
<!-- /Asciify Animated Embed -->`;
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
963
|
// src/core/simple-api.ts
|
|
1042
964
|
async function asciify(source, canvas, { fontSize = 10, style = "classic", options = {} } = {}) {
|
|
1043
965
|
let el;
|
|
@@ -1152,9 +1074,9 @@ function renderRainBackground(ctx, width, height, time, options = {}) {
|
|
|
1152
1074
|
ctx.textBaseline = "top";
|
|
1153
1075
|
let br = 255, bg = 255, bb = 255;
|
|
1154
1076
|
if (lightMode) {
|
|
1155
|
-
br =
|
|
1156
|
-
bg =
|
|
1157
|
-
bb =
|
|
1077
|
+
br = 55;
|
|
1078
|
+
bg = 55;
|
|
1079
|
+
bb = 55;
|
|
1158
1080
|
}
|
|
1159
1081
|
if (color) {
|
|
1160
1082
|
const p = parseColor(color);
|
|
@@ -1216,9 +1138,9 @@ function renderStarsBackground(ctx, width, height, time, mousePos = { x: 0.5, y:
|
|
|
1216
1138
|
const maxR = Math.sqrt(width * width + height * height) * 0.65;
|
|
1217
1139
|
let br = 255, bg = 255, bb = 255;
|
|
1218
1140
|
if (lightMode) {
|
|
1219
|
-
br =
|
|
1220
|
-
bg =
|
|
1221
|
-
bb =
|
|
1141
|
+
br = 55;
|
|
1142
|
+
bg = 55;
|
|
1143
|
+
bb = 55;
|
|
1222
1144
|
}
|
|
1223
1145
|
if (color) {
|
|
1224
1146
|
const p = parseColor(color);
|
|
@@ -1278,9 +1200,9 @@ function renderPulseBackground(ctx, width, height, time, mousePos = { x: 0.5, y:
|
|
|
1278
1200
|
const maxDist = Math.sqrt(cx * cx + cy * cy) * 1.6 + Math.sqrt(width * width + height * height) * 0.2;
|
|
1279
1201
|
let br = 255, bg = 255, bb = 255;
|
|
1280
1202
|
if (lightMode) {
|
|
1281
|
-
br =
|
|
1282
|
-
bg =
|
|
1283
|
-
bb =
|
|
1203
|
+
br = 55;
|
|
1204
|
+
bg = 55;
|
|
1205
|
+
bb = 55;
|
|
1284
1206
|
}
|
|
1285
1207
|
if (color) {
|
|
1286
1208
|
const p = parseColor(color);
|
|
@@ -1355,9 +1277,9 @@ function renderNoiseBackground(ctx, width, height, time, mousePos = { x: 0.5, y:
|
|
|
1355
1277
|
ctx.textBaseline = "top";
|
|
1356
1278
|
let br = 255, bgc = 255, bb = 255;
|
|
1357
1279
|
if (lightMode) {
|
|
1358
|
-
br =
|
|
1359
|
-
bgc =
|
|
1360
|
-
bb =
|
|
1280
|
+
br = 55;
|
|
1281
|
+
bgc = 55;
|
|
1282
|
+
bb = 55;
|
|
1361
1283
|
}
|
|
1362
1284
|
if (color) {
|
|
1363
1285
|
const p = parseColor(color);
|
|
@@ -1434,9 +1356,9 @@ function renderGridBackground(ctx, width, height, time, mousePos = { x: 0.5, y:
|
|
|
1434
1356
|
ctx.textBaseline = "top";
|
|
1435
1357
|
let br = 255, bgv = 255, bb = 255;
|
|
1436
1358
|
if (lightMode) {
|
|
1437
|
-
br =
|
|
1438
|
-
bgv =
|
|
1439
|
-
bb =
|
|
1359
|
+
br = 55;
|
|
1360
|
+
bgv = 55;
|
|
1361
|
+
bb = 55;
|
|
1440
1362
|
}
|
|
1441
1363
|
if (color) {
|
|
1442
1364
|
const p = parseColor(color);
|
|
@@ -1506,9 +1428,9 @@ function renderAuroraBackground(ctx, width, height, time, mousePos = { x: 0.5, y
|
|
|
1506
1428
|
ctx.textBaseline = "top";
|
|
1507
1429
|
let cr = 255, cg = 255, cb = 255;
|
|
1508
1430
|
if (lightMode) {
|
|
1509
|
-
cr =
|
|
1510
|
-
cg =
|
|
1511
|
-
cb =
|
|
1431
|
+
cr = 55;
|
|
1432
|
+
cg = 55;
|
|
1433
|
+
cb = 55;
|
|
1512
1434
|
}
|
|
1513
1435
|
if (color) {
|
|
1514
1436
|
const p = parseColor(color);
|
|
@@ -1591,9 +1513,9 @@ function renderSilkBackground(ctx, width, height, time, options = {}) {
|
|
|
1591
1513
|
ctx.textBaseline = "top";
|
|
1592
1514
|
let cr = 255, cg = 255, cb = 255;
|
|
1593
1515
|
if (lightMode) {
|
|
1594
|
-
cr =
|
|
1595
|
-
cg =
|
|
1596
|
-
cb =
|
|
1516
|
+
cr = 55;
|
|
1517
|
+
cg = 55;
|
|
1518
|
+
cb = 55;
|
|
1597
1519
|
}
|
|
1598
1520
|
if (color) {
|
|
1599
1521
|
const p = parseColor(color);
|
|
@@ -1668,9 +1590,9 @@ function renderVoidBackground(ctx, width, height, time, mousePos = { x: 0.5, y:
|
|
|
1668
1590
|
ctx.textBaseline = "top";
|
|
1669
1591
|
let cr = 255, cg = 255, cb = 255;
|
|
1670
1592
|
if (lightMode) {
|
|
1671
|
-
cr =
|
|
1672
|
-
cg =
|
|
1673
|
-
cb =
|
|
1593
|
+
cr = 55;
|
|
1594
|
+
cg = 55;
|
|
1595
|
+
cb = 55;
|
|
1674
1596
|
}
|
|
1675
1597
|
if (color) {
|
|
1676
1598
|
const p = parseColor(color);
|
|
@@ -1740,9 +1662,9 @@ function renderMorphBackground(ctx, width, height, time, options = {}) {
|
|
|
1740
1662
|
ctx.textBaseline = "top";
|
|
1741
1663
|
let cr = 255, cg = 255, cb = 255;
|
|
1742
1664
|
if (lightMode) {
|
|
1743
|
-
cr =
|
|
1744
|
-
cg =
|
|
1745
|
-
cb =
|
|
1665
|
+
cr = 55;
|
|
1666
|
+
cg = 55;
|
|
1667
|
+
cb = 55;
|
|
1746
1668
|
}
|
|
1747
1669
|
if (color) {
|
|
1748
1670
|
const p = parseColor(color);
|
|
@@ -2901,6 +2823,6 @@ function tryCreateWebGLRenderer(canvas) {
|
|
|
2901
2823
|
}
|
|
2902
2824
|
}
|
|
2903
2825
|
|
|
2904
|
-
export { ART_STYLE_PRESETS, CHARSETS, DEFAULT_OPTIONS, HOVER_PRESETS, PALETTE_THEMES, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyVideo, createRecorder,
|
|
2826
|
+
export { ART_STYLE_PRESETS, CHARSETS, DEFAULT_OPTIONS, HOVER_PRESETS, PALETTE_THEMES, asciiBackground, asciiText, asciiTextAnsi, asciify, asciifyGif, asciifyVideo, createRecorder, gifToAsciiFrames, imageToAsciiFrame, mountWaveBackground, recordAndDownload, renderAuroraBackground, renderCircuitBackground, renderDnaBackground, renderFireBackground, renderFrameToCanvas, renderGridBackground, renderMorphBackground, renderNoiseBackground, renderPulseBackground, renderRainBackground, renderSilkBackground, renderStarsBackground, renderTerrainBackground, renderVoidBackground, renderWaveBackground, tryCreateWebGLRenderer, videoToAsciiFrames };
|
|
2905
2827
|
//# sourceMappingURL=index.js.map
|
|
2906
2828
|
//# sourceMappingURL=index.js.map
|