blob: 019f8224a76d37292fac9278a65cd5b8ff128af5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/**
* @param {string} slug
*
* @returns {(string|MonsterSlug|TechniqueSlug)}
*/
function slugToName (slug) {
return slug.split('_').map((item) => item.charAt(0).toUpperCase() + item.slice(1)).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})`;
}
|