asciify-engine 1.0.66 → 1.0.67
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 +4 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1177,8 +1177,6 @@ function sizeCanvasToContainer(canvas, container, aspect) {
|
|
|
1177
1177
|
canvas.height = Math.round(cssH * dpr);
|
|
1178
1178
|
canvas.style.width = cssW + "px";
|
|
1179
1179
|
canvas.style.height = cssH + "px";
|
|
1180
|
-
canvas.__cssW = cssW;
|
|
1181
|
-
canvas.__cssH = cssH;
|
|
1182
1180
|
}
|
|
1183
1181
|
async function asciify(source, canvas, { fontSize = 10, artStyle = "classic", options = {} } = {}) {
|
|
1184
1182
|
let el;
|
|
@@ -1256,21 +1254,15 @@ async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic
|
|
|
1256
1254
|
video2 = source;
|
|
1257
1255
|
}
|
|
1258
1256
|
if (container) sizeCanvasToContainer(canvas, container, video2.videoWidth / video2.videoHeight);
|
|
1259
|
-
const srcW = video2.videoWidth;
|
|
1260
|
-
const srcH = video2.videoHeight;
|
|
1261
1257
|
const maxDur = trimEnd !== void 0 ? trimEnd - trimStart : 10;
|
|
1262
|
-
const { frames, fps } = await videoToAsciiFrames(video2, merged,
|
|
1258
|
+
const { frames, fps } = await videoToAsciiFrames(video2, merged, canvas.width, canvas.height, void 0, maxDur, void 0, trimStart);
|
|
1263
1259
|
let cancelled2 = false, animId2, i = 0, last = performance.now();
|
|
1264
1260
|
let firstFrame2 = true;
|
|
1265
1261
|
const interval = 1e3 / fps;
|
|
1266
1262
|
const tick2 = (now) => {
|
|
1267
1263
|
if (cancelled2) return;
|
|
1268
|
-
const cssW = canvas.__cssW || canvas.width;
|
|
1269
|
-
const cssH = canvas.__cssH || canvas.height;
|
|
1270
1264
|
if (now - last >= interval) {
|
|
1271
|
-
|
|
1272
|
-
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1273
|
-
renderFrameToCanvas(ctx, frames[i], merged, cssW, cssH);
|
|
1265
|
+
renderFrameToCanvas(ctx, frames[i], merged, canvas.width, canvas.height);
|
|
1274
1266
|
i = (i + 1) % frames.length;
|
|
1275
1267
|
last = now;
|
|
1276
1268
|
if (firstFrame2) {
|
|
@@ -1356,15 +1348,9 @@ async function asciifyVideo(source, canvas, { fontSize = 10, artStyle = "classic
|
|
|
1356
1348
|
if (video.readyState < 2 || canvas.width === 0 || canvas.height === 0) return;
|
|
1357
1349
|
if (trimStart > 0 && video.currentTime < trimStart) return;
|
|
1358
1350
|
if (trimEnd !== void 0 && video.currentTime >= trimEnd) return;
|
|
1359
|
-
const
|
|
1360
|
-
const srcH = video.videoHeight;
|
|
1361
|
-
const { frame } = imageToAsciiFrame(video, merged, srcW, srcH);
|
|
1351
|
+
const { frame } = imageToAsciiFrame(video, merged, canvas.width, canvas.height);
|
|
1362
1352
|
if (frame.length > 0) {
|
|
1363
|
-
|
|
1364
|
-
const cssH = canvas.__cssH || canvas.height;
|
|
1365
|
-
const dpr = window.devicePixelRatio || 1;
|
|
1366
|
-
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
1367
|
-
renderFrameToCanvas(ctx, frame, merged, cssW, cssH, 0, null);
|
|
1353
|
+
renderFrameToCanvas(ctx, frame, merged, canvas.width, canvas.height, 0, null);
|
|
1368
1354
|
if (firstFrame) {
|
|
1369
1355
|
firstFrame = false;
|
|
1370
1356
|
onReady?.(video);
|