mirror of
https://github.com/ful1e5/Bibata_Cursor.git
synced 2025-05-19 17:55:11 -04:00
🎉 function added
This commit is contained in:
parent
cca2e3334b
commit
4b46b49e40
1 changed files with 92 additions and 51 deletions
|
@ -24,62 +24,15 @@ const generateConfigs = (
|
|||
const schemaSvgsPath = path.resolve(schemesPath, schemaName);
|
||||
fs.mkdirSync(schemaSvgsPath, { recursive: true });
|
||||
|
||||
// Static .svg generation
|
||||
staticCursors.map((cursor: string) => {
|
||||
// Read file
|
||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||
let content = fs
|
||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||
.toString();
|
||||
generateStaticSchema(rawSvgsDir, customize, base, outline, schemaSvgsPath);
|
||||
|
||||
// trying to customize color if not available then main schema color
|
||||
try {
|
||||
let { base: b, outline: o } = customize![cursor];
|
||||
if (!b) b = base;
|
||||
if (!o) o = outline;
|
||||
content = content.replace("#00FF00", b).replace("#0000FF", o);
|
||||
} catch (error) {
|
||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||
}
|
||||
|
||||
// Writing new svg
|
||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||
});
|
||||
|
||||
// Out Directory
|
||||
for (let [cursor] of Object.entries(animatedCursors)) {
|
||||
// Read file
|
||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||
let content = fs
|
||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||
.toString();
|
||||
|
||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||
// trying to customize color if not available then main schema color
|
||||
try {
|
||||
if (!watch) throw new Error("");
|
||||
const {
|
||||
background: b,
|
||||
color1: c1,
|
||||
color2: c2,
|
||||
color3: c3,
|
||||
color4: c4
|
||||
} = watch;
|
||||
content = content.replace("#TODO", b); //Inter watch circle
|
||||
content = content
|
||||
.replace("#TODO", c1)
|
||||
.replace("#TODO", c2)
|
||||
.replace("#TODO", c3)
|
||||
.replace("#TODO", c4);
|
||||
} catch (error) {}
|
||||
|
||||
// Writing new svg
|
||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||
}
|
||||
generateAnimatedSchema(rawSvgsDir, base, outline, watch, schemaSvgsPath);
|
||||
|
||||
// Creating Dir for store bitmaps
|
||||
const bitmapsDir = path.resolve(process.cwd(), "bitmaps", schemaName);
|
||||
fs.mkdirSync(bitmapsDir, { recursive: true });
|
||||
|
||||
// push config to Object
|
||||
configs[schema] = {
|
||||
svgsDir: schemaSvgsPath,
|
||||
bitmapsDir,
|
||||
|
@ -93,3 +46,91 @@ const generateConfigs = (
|
|||
};
|
||||
|
||||
export { generateConfigs };
|
||||
|
||||
function generateAnimatedSchema(
|
||||
rawSvgsDir: string,
|
||||
base: string,
|
||||
outline: string,
|
||||
watch:
|
||||
| {
|
||||
background: string;
|
||||
color1: string;
|
||||
color2: string;
|
||||
color3: string;
|
||||
color4: string;
|
||||
}
|
||||
| undefined,
|
||||
schemaSvgsPath: string
|
||||
) {
|
||||
for (let [cursor] of Object.entries(animatedCursors)) {
|
||||
// Read file
|
||||
let content = fs
|
||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||
.toString();
|
||||
|
||||
// Animated Cursors have two parts:
|
||||
// 1) Cursor Color
|
||||
// 2) Watch Color
|
||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||
|
||||
// try => replace `customize` colors
|
||||
// onError => replace `schema` main colors
|
||||
try {
|
||||
if (!watch) throw new Error("");
|
||||
const {
|
||||
background: b,
|
||||
color1: c1,
|
||||
color2: c2,
|
||||
color3: c3,
|
||||
color4: c4
|
||||
} = watch;
|
||||
content = content.replace("#TODO", b); //Inter watch circle
|
||||
content = content
|
||||
.replace("#TODO", c1)
|
||||
.replace("#TODO", c2)
|
||||
.replace("#TODO", c3)
|
||||
.replace("#TODO", c4);
|
||||
} catch (error) {}
|
||||
|
||||
// Save Schema
|
||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
function generateStaticSchema(
|
||||
rawSvgsDir: string,
|
||||
customize:
|
||||
| {
|
||||
[name: string]: {
|
||||
outline?: string | undefined;
|
||||
base?: string | undefined;
|
||||
};
|
||||
}
|
||||
| undefined,
|
||||
base: string,
|
||||
outline: string,
|
||||
schemaSvgsPath: string
|
||||
) {
|
||||
staticCursors.map((cursor: string) => {
|
||||
// Read file
|
||||
let content = fs
|
||||
.readFileSync(path.resolve(rawSvgsDir, cursor), "utf-8")
|
||||
.toString();
|
||||
|
||||
// try => replace `customize` colors
|
||||
// onError => replace `schema` main colors
|
||||
try {
|
||||
let { base: b, outline: o } = customize![cursor];
|
||||
if (!b) b = base;
|
||||
if (!o) o = outline;
|
||||
content = content.replace("#00FF00", b).replace("#0000FF", o);
|
||||
} catch (error) {
|
||||
content = content.replace("#00FF00", base).replace("#0000FF", outline);
|
||||
}
|
||||
|
||||
// Save Schema
|
||||
const cursorPath = path.resolve(schemaSvgsPath, cursor);
|
||||
fs.writeFileSync(cursorPath, content, "utf-8");
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue