/** * @param {string} slug * * @returns {(string|MonsterSlug|TechniqueSlug)} */ function slugToName (slug) { const ucfirst = (str) => { return str.charAt(0).toUpperCase() + str.slice(1); }; return slug .split('_').map((item) => ucfirst(item)).join(' ') .split('-').map((item) => ucfirst(item)).join(' '); } /** * @param {string} color * * @returns {string} */ function standardizeColor (color) { var ctx = document.createElement('canvas').getContext('2d'); ctx.fillStyle = color; return ctx.fillStyle; } /** * @param {...string} colors * * @returns {string} rgb */ function mixColors(...colors) { let r = 0; let g = 0; let b = 0; for (const color of colors) { const [cr, cg, cb] = color.match(/\w\w/g).map((c) => parseInt(c, 16)); r += cr; g += cg; b += cb; } r = r / colors.length; g = g / colors.length; b = b / colors.length; return `rgb(${r}, ${g}, ${b})`; } /** * @returns {string} */ function randomString () { return (Math.random() + 1).toString(36).substring(2); } /** * @param {string} msgid */ function translate (msgid) { return DB.translations[Memory.state.Settings.language][msgid]; }