65 lines
1.6 KiB
JavaScript
65 lines
1.6 KiB
JavaScript
const GAME_EMOJI = [
|
|
"Promote",
|
|
"Militia",
|
|
"Lance",
|
|
"Knight",
|
|
"Tower",
|
|
"Castle",
|
|
"Dragon",
|
|
"Behemoth",
|
|
"Heart",
|
|
];
|
|
const GAME_EMOJI_COLOR = [
|
|
"Promote",
|
|
"Dawn",
|
|
"Dusk",
|
|
];
|
|
|
|
class GameImage {
|
|
constructor(paths=[]) {
|
|
this.paths = paths;
|
|
}
|
|
|
|
draw(ctx, scale=1., offset=[0, 0], color=null) {
|
|
for(let path of this.paths) {
|
|
if(color === null) {
|
|
ctx.fillStyle = path[0];
|
|
} else {
|
|
ctx.fillStyle = color;
|
|
}
|
|
|
|
let origin = [0, 0];
|
|
|
|
ctx.beginPath();
|
|
for(let segment of path[1]) {
|
|
switch(segment[0]) {
|
|
case 0: {
|
|
origin = segment[1];
|
|
ctx.moveTo(
|
|
(scale * segment[1][0]) + offset[0],
|
|
(scale * segment[1][1]) + offset[1],
|
|
);
|
|
} break;
|
|
case 1: {
|
|
ctx.lineTo(
|
|
(scale * segment[1][0]) + offset[0],
|
|
(scale * segment[1][1]) + offset[1],
|
|
);
|
|
} break;
|
|
case 2: {
|
|
|
|
} break;
|
|
case 3: {
|
|
ctx.lineTo(
|
|
(scale * origin[0]) + offset[0],
|
|
(scale * origin[1]) + offset[1],
|
|
);
|
|
} break;
|
|
default: console.log(segment.mode);
|
|
}
|
|
}
|
|
ctx.fill();
|
|
}
|
|
}
|
|
}
|