mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-28 22:14:21 -04:00
🔧 Dynamic Pixel Diff Rate
matcher for every animated cursors
This commit is contained in:
parent
43d7979f6e
commit
0a4a05a720
1 changed files with 13 additions and 2 deletions
|
@ -8,7 +8,16 @@ import { matchImages } from "./utils/matchImages";
|
||||||
import { saveFrames } from "./utils/saveFrames";
|
import { saveFrames } from "./utils/saveFrames";
|
||||||
import { getKeyName } from "./utils/getKeyName";
|
import { getKeyName } from "./utils/getKeyName";
|
||||||
import { spinner } from "./utils/spinner";
|
import { spinner } from "./utils/spinner";
|
||||||
import { Config, Frames } from "./types";
|
import { Config, Frames, PixelDiffRate } from "./types";
|
||||||
|
|
||||||
|
const pixelDiffRate: PixelDiffRate = {
|
||||||
|
"left_ptr_watch.svg": {
|
||||||
|
rate: 100
|
||||||
|
},
|
||||||
|
"wait.svg": {
|
||||||
|
rate: 990
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const renderCursors = async (configs: Record<string, Config>) => {
|
const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
|
@ -71,6 +80,7 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
const svgElement = await page.$("#container svg");
|
const svgElement = await page.$("#container svg");
|
||||||
if (!svgElement) throw new Error("svg element not found");
|
if (!svgElement) throw new Error("svg element not found");
|
||||||
|
|
||||||
|
console.log(path.basename(svgPath));
|
||||||
// Render Config
|
// Render Config
|
||||||
let index = 1;
|
let index = 1;
|
||||||
let breakRendering = false;
|
let breakRendering = false;
|
||||||
|
@ -102,7 +112,8 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
img2Buff: newFrame
|
img2Buff: newFrame
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(diff < 700)) {
|
const { rate } = pixelDiffRate[path.basename(svgPath)];
|
||||||
|
if (!(diff < rate)) {
|
||||||
frames[key] = { buffer: newFrame };
|
frames[key] = { buffer: newFrame };
|
||||||
} else {
|
} else {
|
||||||
breakRendering = true;
|
breakRendering = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue