mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-23 19:47:05 -04:00
💾 Save All frames utils
This commit is contained in:
parent
27113e4e7a
commit
617f218719
2 changed files with 19 additions and 0 deletions
|
@ -11,6 +11,7 @@ import {
|
||||||
animatedClip,
|
animatedClip,
|
||||||
} from "./config";
|
} from "./config";
|
||||||
import { matchImages } from "./utils/matchImages";
|
import { matchImages } from "./utils/matchImages";
|
||||||
|
import { saveFrames } from "./utils/saveFrames";
|
||||||
|
|
||||||
const main = async () => {
|
const main = async () => {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
|
@ -104,6 +105,8 @@ const main = async () => {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
saveFrames({ fileName: svg, frames });
|
||||||
|
|
||||||
await page.close();
|
await page.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
src/utils/saveFrames.ts
Normal file
16
src/utils/saveFrames.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import fs from "fs";
|
||||||
|
import { getOutPath } from "./getOutPath";
|
||||||
|
|
||||||
|
interface SaveFramesArguments {
|
||||||
|
fileName: string;
|
||||||
|
frames: Buffer[];
|
||||||
|
}
|
||||||
|
export const saveFrames = ({ fileName, frames }: SaveFramesArguments) => {
|
||||||
|
let index = 1;
|
||||||
|
const totalFrames = Buffer.length;
|
||||||
|
for (let [frameBuffer] of Object.entries(frames)) {
|
||||||
|
const out = getOutPath(index, totalFrames, fileName);
|
||||||
|
fs.writeFileSync(out, frameBuffer);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Add table
Add a link
Reference in a new issue