-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimage_mapping.js
75 lines (67 loc) · 1.37 KB
/
image_mapping.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const coatingList = ["None", "Brown", "White"];
const topppingList = [
"None",
"StripesWhite",
"StripesBrown",
"StripesRainbow",
"StripesPretzelDAO",
"SprinklesWhite",
"SprinklesBrown",
"SprinklesRainbow",
"SprinklesPretzelDAO",
"DotsWhite",
"DotsBrown",
"DotsRainbow",
"DotsPretzelDAO",
];
function camelToUnderscore(key) {
var result = key.replace(/([A-Z])/g, " $1");
return result.split(" ").join("_").toLowerCase();
}
function buildImages(bg, half, salt, coating, topping) {
let ret = [];
ret.push({
input: `./sugar-pretzels/${bg}.png`,
top: 0,
left: 0,
});
//quick-fix to make it possible without parsing arguments
ret.push({
input: `./sugar-pretzels/classic.svg`,
top: 0,
left: 0,
});
const prefix = half ? "half" : "full";
if (salt) {
ret.push({
input: `./sugar-pretzels/salt.svg`,
top: 0,
left: 0,
});
}
if (coating > 0) {
ret.push({
input: `./sugar-pretzels/${
prefix + camelToUnderscore(coatingList[coating])
}.svg`,
top: 0,
left: 0,
});
}
if (topping > 0) {
ret.push({
input: `./sugar-pretzels/${
prefix + camelToUnderscore(topppingList[topping])
}.svg`,
top: 0,
left: 0,
});
}
console.log("making pretzel:", ret);
return ret;
}
module.exports = {
buildImages,
coatingList,
topppingList,
};