mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-07 23:05:04 +02:00
Square image properly in ygogen
This commit is contained in:
@@ -99,8 +99,7 @@ module.exports = class YuGiOhGenCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillRect(0, 0, base.width, base.height);
|
||||
const height = 617 / data.width;
|
||||
ctx.drawImage(data, 98, 217, 617, data.height * height);
|
||||
ctx.drawImage(this.squareImage(data), 98, 217, 617, 617);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.drawImage(atr, 686, 55 + (monsterType === 'link' ? 4 : 0), 70, 70);
|
||||
if (level > 0) {
|
||||
@@ -154,6 +153,14 @@ module.exports = class YuGiOhGenCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
squareImage(image) {
|
||||
const dimensions = image.width <= image.height ? image.width : image.height;
|
||||
const canvas = createCanvas(dimensions, dimensions);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(image, (canvas.width / 2) - (image.width / 2), 0);
|
||||
return canvas;
|
||||
}
|
||||
|
||||
async determineMonsterType(msg, type) {
|
||||
if (type !== 'monster') return type;
|
||||
await msg.reply(stripIndents`
|
||||
|
||||
Reference in New Issue
Block a user