mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-29 22:35:31 -04:00
💾 Saved bitmaps path in spinner text
This commit is contained in:
parent
b0611d8e78
commit
62ed021fa7
1 changed files with 12 additions and 8 deletions
|
@ -25,7 +25,6 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
headless: true
|
headless: true
|
||||||
});
|
});
|
||||||
|
|
||||||
let outDir = "";
|
|
||||||
for (let [
|
for (let [
|
||||||
schema,
|
schema,
|
||||||
{ bitmapsDir, staticCursors, animatedCursors }
|
{ bitmapsDir, staticCursors, animatedCursors }
|
||||||
|
@ -37,7 +36,7 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
|
|
||||||
// Spinner
|
// Spinner
|
||||||
const spinner = ora();
|
const spinner = ora();
|
||||||
spinner.text = ` Preparing ${schema} Schema...`;
|
spinner.text = ` Preparing ${schema} Color Schema...`;
|
||||||
spinner.start();
|
spinner.start();
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
|
@ -62,8 +61,9 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
await page.waitForSelector("#container");
|
await page.waitForSelector("#container");
|
||||||
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");
|
||||||
|
|
||||||
|
spinner.text = ` Bitmaping ${chalk.greenBright(bitmapName)}`;
|
||||||
await svgElement.screenshot({ omitBackground: true, path: out });
|
await svgElement.screenshot({ omitBackground: true, path: out });
|
||||||
spinner.text = `${chalk.greenBright(bitmapName)}`;
|
|
||||||
|
|
||||||
await page.close();
|
await page.close();
|
||||||
}
|
}
|
||||||
|
@ -90,22 +90,24 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
const firstKey = getKeyName(index, svgPath);
|
const firstKey = getKeyName(index, svgPath);
|
||||||
|
|
||||||
// 1st Frame
|
// 1st Frame
|
||||||
|
spinner.text = ` Bitmaping ${chalk.greenBright(firstKey)}`;
|
||||||
frames[firstKey] = {
|
frames[firstKey] = {
|
||||||
buffer: await svgElement.screenshot({
|
buffer: await svgElement.screenshot({
|
||||||
omitBackground: true,
|
omitBackground: true,
|
||||||
encoding: "binary"
|
encoding: "binary"
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
spinner.text = ` ${chalk.greenBright(firstKey)}`;
|
|
||||||
|
|
||||||
// Pushing frames until it match to 1st frame
|
// Pushing frames until it match to 1st frame
|
||||||
index++;
|
index++;
|
||||||
while (!breakRendering) {
|
while (!breakRendering) {
|
||||||
|
const key = getKeyName(index, svgPath);
|
||||||
|
spinner.text = ` Bitmaping ${chalk.greenBright(key)}`;
|
||||||
|
|
||||||
const newFrame = await svgElement.screenshot({
|
const newFrame = await svgElement.screenshot({
|
||||||
omitBackground: true,
|
omitBackground: true,
|
||||||
encoding: "binary"
|
encoding: "binary"
|
||||||
});
|
});
|
||||||
const key = getKeyName(index, svgPath);
|
|
||||||
|
|
||||||
const diff = matchImages({
|
const diff = matchImages({
|
||||||
img1Buff: frames[firstKey].buffer,
|
img1Buff: frames[firstKey].buffer,
|
||||||
|
@ -115,7 +117,6 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
const { rate } = pixelDiffRate[path.basename(svgPath)];
|
const { rate } = pixelDiffRate[path.basename(svgPath)];
|
||||||
if (!(diff < rate)) {
|
if (!(diff < rate)) {
|
||||||
frames[key] = { buffer: newFrame };
|
frames[key] = { buffer: newFrame };
|
||||||
spinner.text = ` ${chalk.greenBright(key)}`;
|
|
||||||
} else {
|
} else {
|
||||||
breakRendering = true;
|
breakRendering = true;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +127,11 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
|
|
||||||
await page.close();
|
await page.close();
|
||||||
}
|
}
|
||||||
spinner.text = `${schema} Bitmaps`;
|
spinner.text = ` ${chalk.blueBright(
|
||||||
|
schema
|
||||||
|
)} Bitmaps stored at ${chalk.greenBright(
|
||||||
|
`./${path.relative("../../", bitmapsDir)}`
|
||||||
|
)}`;
|
||||||
spinner.succeed();
|
spinner.succeed();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -134,7 +139,6 @@ const renderCursors = async (configs: Record<string, Config>) => {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(` 🎉 Bitmaps stored at ${chalk.greenBright(outDir)}`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export { renderCursors };
|
export { renderCursors };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue