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 { getOutPath } from "./getOutPath";
|
||||
import path from "path";
|
||||
import { bitmapsDir } from "../config";
|
||||
|
||||
export interface Frames {
|
||||
[fileName: string]: {
|
||||
buffer: Buffer;
|
||||
};
|
||||
}
|
||||
|
||||
interface SaveFramesArguments {
|
||||
fileName: string;
|
||||
frames: Buffer[];
|
||||
frames: Frames;
|
||||
}
|
||||
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++;
|
||||
|
||||
export const saveFrames = (frames: SaveFramesArguments) => {
|
||||
for (let [fileName, { buffer }] of Object.entries(frames.frames)) {
|
||||
const out_path = path.resolve(bitmapsDir, fileName);
|
||||
fs.writeFileSync(out_path, buffer, { encoding: "binary" });
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue