mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-23 19:47:05 -04:00
🚀 Removed unuseful helpers
This commit is contained in:
parent
57da63e13f
commit
9fff98b5f6
3 changed files with 7 additions and 21 deletions
|
@ -21,11 +21,4 @@ const animatedCursors = readdirSync(animatedCursorsDir).map((f) =>
|
||||||
resolve(animatedCursorsDir, f)
|
resolve(animatedCursorsDir, f)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Animated Config
|
export { staticCursors, animatedCursors, bitmapsDir };
|
||||||
const animatedClip = {
|
|
||||||
x: 4,
|
|
||||||
y: 4,
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
};
|
|
||||||
export { staticCursors, animatedCursors, bitmapsDir, animatedClip };
|
|
||||||
|
|
15
src/index.ts
15
src/index.ts
|
@ -2,13 +2,8 @@ import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import puppeteer from "puppeteer";
|
import puppeteer from "puppeteer";
|
||||||
|
|
||||||
import { generateRenderTemplate } from "./utils/htmlTemplate";
|
import { htmlTemplate } from "./utils/htmlTemplate";
|
||||||
import {
|
import { staticCursors, bitmapsDir, animatedCursors } from "./config";
|
||||||
staticCursors,
|
|
||||||
bitmapsDir,
|
|
||||||
animatedCursors,
|
|
||||||
animatedClip,
|
|
||||||
} from "./config";
|
|
||||||
import { matchImages } from "./utils/matchImages";
|
import { matchImages } from "./utils/matchImages";
|
||||||
import { saveFrames, Frames } from "./utils/saveFrames";
|
import { saveFrames, Frames } from "./utils/saveFrames";
|
||||||
import { getFrameName } from "./utils/getFrameName";
|
import { getFrameName } from "./utils/getFrameName";
|
||||||
|
@ -32,7 +27,7 @@ const main = async () => {
|
||||||
|
|
||||||
// Generating HTML Template
|
// Generating HTML Template
|
||||||
const data = buffer.toString();
|
const data = buffer.toString();
|
||||||
const template = generateRenderTemplate(data);
|
const template = htmlTemplate(data);
|
||||||
|
|
||||||
// config
|
// config
|
||||||
const bitmapName = `${path.basename(svgPath, ".svg")}.png`;
|
const bitmapName = `${path.basename(svgPath, ".svg")}.png`;
|
||||||
|
@ -58,7 +53,7 @@ const main = async () => {
|
||||||
|
|
||||||
// Generating HTML Template
|
// Generating HTML Template
|
||||||
const data = buffer.toString();
|
const data = buffer.toString();
|
||||||
const template = generateRenderTemplate(data);
|
const template = htmlTemplate(data);
|
||||||
|
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
await page.setContent(template, { waitUntil: "networkidle2" });
|
await page.setContent(template, { waitUntil: "networkidle2" });
|
||||||
|
@ -80,7 +75,6 @@ const main = async () => {
|
||||||
frames[firstKey] = {
|
frames[firstKey] = {
|
||||||
buffer: await svgElement.screenshot({
|
buffer: await svgElement.screenshot({
|
||||||
omitBackground: true,
|
omitBackground: true,
|
||||||
clip: animatedClip,
|
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -90,7 +84,6 @@ const main = async () => {
|
||||||
while (!breakRendering) {
|
while (!breakRendering) {
|
||||||
const newFrame = await svgElement.screenshot({
|
const newFrame = await svgElement.screenshot({
|
||||||
omitBackground: true,
|
omitBackground: true,
|
||||||
clip: animatedClip,
|
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
});
|
});
|
||||||
const key = getFrameName(index, svgPath);
|
const key = getFrameName(index, svgPath);
|
||||||
|
|
|
@ -4,7 +4,7 @@ export const template = `
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Eggy Render Template</title>
|
<title>Render Template</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -15,5 +15,5 @@ export const template = `
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const generateRenderTemplate = (svg: string) =>
|
export const htmlTemplate = (svg: string) =>
|
||||||
template.replace("<svginjection>", svg);
|
template.replace("<svginjection>", svg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue