mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-14 07:04:47 -04:00
⚡ Utils renamed
This commit is contained in:
parent
9fff98b5f6
commit
2213fa761a
3 changed files with 2 additions and 37 deletions
|
@ -1,19 +0,0 @@
|
|||
import { PNG } from "pngjs";
|
||||
import pixelmatch from "pixelmatch";
|
||||
|
||||
interface MatchImagesArgs {
|
||||
img1Buff: Buffer;
|
||||
img2Buff: Buffer;
|
||||
}
|
||||
|
||||
export const matchImages = ({ img1Buff, img2Buff }: MatchImagesArgs) => {
|
||||
const img1 = PNG.sync.read(img1Buff);
|
||||
const img2 = PNG.sync.read(img2Buff);
|
||||
const { width, height } = img1;
|
||||
|
||||
const diff = new PNG({ width, height });
|
||||
|
||||
return pixelmatch(img1.data, img2.data, diff.data, width, height, {
|
||||
threshold: 0.1,
|
||||
});
|
||||
};
|
|
@ -1,16 +0,0 @@
|
|||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { bitmapsDir } from "../config";
|
||||
|
||||
export interface Frames {
|
||||
[fileName: string]: {
|
||||
buffer: Buffer;
|
||||
};
|
||||
}
|
||||
|
||||
export const saveFrames = (frames: Frames) => {
|
||||
for (let [fileName, { buffer }] of Object.entries(frames)) {
|
||||
const out_path = path.resolve(bitmapsDir, fileName);
|
||||
fs.writeFileSync(out_path, buffer, { encoding: "binary" });
|
||||
}
|
||||
};
|
|
@ -15,5 +15,5 @@ export const template = `
|
|||
</html>
|
||||
`;
|
||||
|
||||
export const htmlTemplate = (svg: string) =>
|
||||
template.replace("<svginjection>", svg);
|
||||
export const toHTML = (svgData: string): string =>
|
||||
template.replace("<svginjection>", svgData);
|
Loading…
Add table
Add a link
Reference in a new issue