Chadified Assets

This commit is contained in:
Marco van Dijk 2022-10-07 14:53:40 +02:00
parent 502aa93f23
commit b2f153f897
4 changed files with 480 additions and 511 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 14 MiB

After

Width:  |  Height:  |  Size: 14 MiB

View File

@ -13,7 +13,6 @@ const svgFromAttributes = require("./svg-generator");
// Rocketeer generator
// ///////////////////////////////
async function generateRocketeer(id) {
// The base object of a new Rocketeer
const rocketeer = {
name: `${name.first()} ${name.middle()} ${name.last()} of ${
@ -80,14 +79,12 @@ async function generateRocketeer(id) {
// Generate, compile and upload image
const { NODE_ENV: mode } = process.env;
let path;
if (mode == "production"){
path = '/var/www/avatars/' + id
}else{
path = './output/' + id
if (mode == "production") {
path = "/var/www/avatars/" + id;
} else {
path = "./output/" + id;
}
rocketeer.image = await svgFromAttributes(
rocketeer.attributes, path
);
rocketeer.image = await svgFromAttributes(rocketeer.attributes, path);
// Namify the attributes
rocketeer.attributes = rocketeer.attributes.map((attribute) => {

View File

@ -54,7 +54,7 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
// ///////////////////////////////
// Attribute selection
// ///////////////////////////////
console.log("Removing unused attributes from master");
console.log("Removing unused attributes from master");
// Remove obsolete patches
const obsoletePatches = [
@ -75,9 +75,16 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
(p) => p !== helmet
);
for (let i = obsoleteHelmets.length - 1; i >= 0; i--) {
const element = document.querySelector(`#${obsoleteHelmets[i]}`);
if (element) element.remove();
else console.log(`Could not find #${obsoleteHelmets[i]}`);
{
let element = document.querySelector(`#${obsoleteHelmets[i]}` + "_front");
if (element) element.remove();
else console.log(`#${obsoleteHelmets[i]}` + "_front");
}
{
let element = document.querySelector(`#${obsoleteHelmets[i]}` + "_back");
if (element) element.remove();
else console.log(`#${obsoleteHelmets[i]}` + "_back");
}
}
// Remove panel if need be
@ -135,7 +142,7 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
// ///////////////////////////////
// Color substitutions
// ///////////////////////////////
console.log("Substituting colours from master");
console.log("Substituting colours from master");
const defaultPrimary = /rgb\( ?252 ?, ?186 ?, ?157 ?\)/gi;
const defaultVisor = /rgb\( ?71 ?, ?22 ?, ?127 ?\)/gi;
const defaultAccent = /rgb\( ?243 ?, ?99 ?, ?113 ?\)/gi;
@ -161,7 +168,6 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
console.log("Writing to `" + path + ".svg`...");
await fs.writeFile(`${path}.svg`, bakedSvg);
// Return public url
return "Paths: '" + `${path}.svg` + "'";
};