mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-28 22:16:01 -04:00
💾 Save Animated Cursors Frames
This commit is contained in:
parent
70e770af72
commit
75e2babb08
1 changed files with 14 additions and 9 deletions
|
@ -1,16 +1,21 @@
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { getOutPath } from "./getOutPath";
|
import path from "path";
|
||||||
|
import { bitmapsDir } from "../config";
|
||||||
|
|
||||||
|
export interface Frames {
|
||||||
|
[fileName: string]: {
|
||||||
|
buffer: Buffer;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface SaveFramesArguments {
|
interface SaveFramesArguments {
|
||||||
fileName: string;
|
fileName: string;
|
||||||
frames: Buffer[];
|
frames: Frames;
|
||||||
}
|
}
|
||||||
export const saveFrames = ({ fileName, frames }: SaveFramesArguments) => {
|
|
||||||
let index = 1;
|
export const saveFrames = (frames: SaveFramesArguments) => {
|
||||||
const totalFrames = Buffer.length;
|
for (let [fileName, { buffer }] of Object.entries(frames.frames)) {
|
||||||
for (let [frameBuffer] of Object.entries(frames)) {
|
const out_path = path.resolve(bitmapsDir, fileName);
|
||||||
const out = getOutPath(index, totalFrames, fileName);
|
fs.writeFileSync(out_path, buffer, { encoding: "binary" });
|
||||||
fs.writeFileSync(out, frameBuffer);
|
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue