🖼️ Render static pngs

This commit is contained in:
ful1e5 2021-02-20 17:49:57 +05:30
parent 99dde92a8a
commit 05a7d723f6
3 changed files with 99 additions and 40 deletions

View file

@ -1,19 +1,38 @@
import path from "path";
import fs from "fs";
import { BitmapsGenerator, SVGHandler } from "bibata-core";
import { Colors } from "bibata-core/src/types";
const root = path.resolve(__dirname, "../../../../");
const svgDir = path.resolve(root, "svg", "modern");
const themeName = "Bibata-Modern";
const bitmapsDir = path.resolve(root, "bitmaps", themeName);
const color: Colors = {
base: "#000000",
outline: "#FFFFFF",
watch: {
background: "#FFFFFF",
},
};
const main = async () => {
const SVG = new SVGHandler.SvgDirectoryParser(svgDir);
SVG.getStatic().forEach((svg) => {
console.log(svg);
});
const png = new BitmapsGenerator(bitmapsDir);
const browser = await png.getBrowser();
SVG.getAnimated().forEach((svg) => {
console.log(svg);
SVG.getStatic().forEach(async (svg) => {
const key = `${path.basename(svg, ".svg")}.png`;
console.log("Saving", key, "...");
const out = path.resolve(bitmapsDir, key);
let content = fs.readFileSync(svg, "utf-8");
content = SVGHandler.colorSvg(content, color);
await png.generate(browser, content, out);
});
};