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 // Rocketeer generator
// /////////////////////////////// // ///////////////////////////////
async function generateRocketeer(id) { async function generateRocketeer(id) {
// The base object of a new Rocketeer // The base object of a new Rocketeer
const rocketeer = { const rocketeer = {
name: `${name.first()} ${name.middle()} ${name.last()} of ${ name: `${name.first()} ${name.middle()} ${name.last()} of ${
@ -81,13 +80,11 @@ async function generateRocketeer(id) {
const { NODE_ENV: mode } = process.env; const { NODE_ENV: mode } = process.env;
let path; let path;
if (mode == "production") { if (mode == "production") {
path = '/var/www/avatars/' + id path = "/var/www/avatars/" + id;
} else { } else {
path = './output/' + id path = "./output/" + id;
} }
rocketeer.image = await svgFromAttributes( rocketeer.image = await svgFromAttributes(rocketeer.attributes, path);
rocketeer.attributes, path
);
// Namify the attributes // Namify the attributes
rocketeer.attributes = rocketeer.attributes.map((attribute) => { rocketeer.attributes = rocketeer.attributes.map((attribute) => {

View File

@ -75,9 +75,16 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
(p) => p !== helmet (p) => p !== helmet
); );
for (let i = obsoleteHelmets.length - 1; i >= 0; i--) { for (let i = obsoleteHelmets.length - 1; i >= 0; i--) {
const element = document.querySelector(`#${obsoleteHelmets[i]}`); {
let element = document.querySelector(`#${obsoleteHelmets[i]}` + "_front");
if (element) element.remove(); if (element) element.remove();
else console.log(`Could not find #${obsoleteHelmets[i]}`); 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 // Remove panel if need be
@ -161,7 +168,6 @@ module.exports = async function svgFromAttributes(attributes = [], path = "") {
console.log("Writing to `" + path + ".svg`..."); console.log("Writing to `" + path + ".svg`...");
await fs.writeFile(`${path}.svg`, bakedSvg); await fs.writeFile(`${path}.svg`, bakedSvg);
// Return public url // Return public url
return "Paths: '" + `${path}.svg` + "'"; return "Paths: '" + `${path}.svg` + "'";
}; };