diff --git a/src/config.ts b/src/config.ts index 09e306d..a567e37 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,6 @@ import path from "path"; import fs from "fs"; -import { staticCursors, animatedCursors } from "./cursors.json"; +import { staticCursors, animatedCursors, animatedClip } from "./cursors.json"; // Source Directory const svgsDir = path.resolve(__dirname, "svg"); @@ -14,4 +14,4 @@ const staticSvgs = staticCursors.map((svg: string) => const bitmapsDir = path.resolve(process.cwd(), "bitmaps"); if (!fs.existsSync(bitmapsDir)) fs.mkdirSync(bitmapsDir); -export { staticSvgs, animatedCursors, svgsDir, bitmapsDir }; +export { staticSvgs, animatedCursors, svgsDir, bitmapsDir, animatedClip }; diff --git a/src/index.ts b/src/index.ts index 5e60cc0..2b53358 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,13 @@ import path from "path"; import puppeteer from "puppeteer"; import { generateRenderTemplate } from "./helpers/htmlTemplate"; -import { staticSvgs, bitmapsDir, svgsDir, animatedCursors } from "./config"; +import { + staticSvgs, + bitmapsDir, + svgsDir, + animatedCursors, + animatedClip, +} from "./config"; // --------------------------- Helpers const frameNumber = (number: number, length: number) => { @@ -86,7 +92,11 @@ const frameNumber = (number: number, length: number) => { const out = path.resolve(bitmapsDir, bitmap); // Render - await svgElement.screenshot({ omitBackground: true, path: out }); + await svgElement.screenshot({ + omitBackground: true, + path: out, + clip: animatedClip, + }); // console.log(`${svg} frame ${frame}/${frames} rendered at ${out}`); }