mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-23 03:26:58 -04:00
🏷️ types added
This commit is contained in:
parent
d5072fafc3
commit
d0f4913369
1 changed files with 27 additions and 5 deletions
|
@ -2,7 +2,29 @@ import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import puppeteer from "puppeteer";
|
import puppeteer from "puppeteer";
|
||||||
|
|
||||||
import { generateRenderTemplate } from "@helpers/htmlTemplate";
|
import { generateRenderTemplate } from "./helpers/htmlTemplate";
|
||||||
|
|
||||||
|
// --------------------------- Types
|
||||||
|
type AnimatedCursors = {
|
||||||
|
readonly [name: string]: {
|
||||||
|
readonly frames: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
type AnimatedClip = {
|
||||||
|
readonly x: number;
|
||||||
|
readonly y: number;
|
||||||
|
readonly width: number;
|
||||||
|
readonly height: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface Config {
|
||||||
|
staticSvgs: Array<string>;
|
||||||
|
bitmapsDir: string;
|
||||||
|
svgsDir: string;
|
||||||
|
animatedCursors: AnimatedCursors;
|
||||||
|
animatedClip: AnimatedClip;
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------- Helpers
|
// --------------------------- Helpers
|
||||||
const frameNumber = (number: number, length: number) => {
|
const frameNumber = (number: number, length: number) => {
|
||||||
|
@ -19,15 +41,15 @@ export const renderCursors = async ({
|
||||||
bitmapsDir,
|
bitmapsDir,
|
||||||
svgsDir,
|
svgsDir,
|
||||||
animatedCursors,
|
animatedCursors,
|
||||||
animatedClip,
|
animatedClip
|
||||||
}: RenderConfig) => {
|
}: Config) => {
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
ignoreDefaultArgs: [" --single-process ", "--no-sandbox"],
|
ignoreDefaultArgs: [" --single-process ", "--no-sandbox"],
|
||||||
executablePath:
|
executablePath:
|
||||||
process.env.NODE_ENV == "development"
|
process.env.NODE_ENV == "development"
|
||||||
? "/usr/bin/google-chrome-stable"
|
? "/usr/bin/google-chrome-stable"
|
||||||
: "",
|
: "",
|
||||||
headless: true,
|
headless: true
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
console.log("📸 Rendering Static Cursors...");
|
console.log("📸 Rendering Static Cursors...");
|
||||||
|
@ -93,7 +115,7 @@ export const renderCursors = async ({
|
||||||
await svgElement.screenshot({
|
await svgElement.screenshot({
|
||||||
omitBackground: true,
|
omitBackground: true,
|
||||||
path: out,
|
path: out,
|
||||||
clip: animatedClip,
|
clip: animatedClip
|
||||||
});
|
});
|
||||||
// console.log(`${svg} frame ${frame}/${frames} rendered at ${out}`);
|
// console.log(`${svg} frame ${frame}/${frames} rendered at ${out}`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue