From 790713331b79093dd1307bdfbdd74df703c8ec89 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 12 Jun 2020 10:42:44 -0400 Subject: [PATCH] Center image part in ygogen --- commands/edit-image/yu-gi-oh-gen.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commands/edit-image/yu-gi-oh-gen.js b/commands/edit-image/yu-gi-oh-gen.js index b052d617..a7b18238 100644 --- a/commands/edit-image/yu-gi-oh-gen.js +++ b/commands/edit-image/yu-gi-oh-gen.js @@ -2,7 +2,7 @@ const Command = require('../../structures/Command'); const { createCanvas, loadImage, registerFont } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); -const { wrapText } = require('../../util/Canvas'); +const { wrapText, centerImagePart } = require('../../util/Canvas'); registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Matrix Book.ttf'), { family: 'Matrix Book' }); registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Matrix Small Caps.ttf'), { family: 'Matrix' }); registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Stone Serif.ttf'), { family: 'Stone Serif' }); @@ -113,7 +113,8 @@ module.exports = class YuGiOhGenCommand extends Command { const ctx = canvas.getContext('2d'); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, base.width, base.height); - ctx.drawImage(data, 109, 241, 590, 590); + const { x, y, width, height } = centerImagePart(data, 109, 241, 590, 590); + ctx.drawImage(data, x, y, width, height); ctx.drawImage(base, 0, 0); ctx.drawImage(atr, 669, 61, 77, 77); for (let i = 0; i < level; i++) {