From 1ccf71a08de9d1048269e4ec7cb1ef7daf2fc90b Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 4 May 2020 14:03:13 -0400 Subject: [PATCH] Fix --- commands/edit-meme/skyrim-skill.js | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/commands/edit-meme/skyrim-skill.js b/commands/edit-meme/skyrim-skill.js index 2bf29269..b80f02c3 100644 --- a/commands/edit-meme/skyrim-skill.js +++ b/commands/edit-meme/skyrim-skill.js @@ -54,20 +54,18 @@ module.exports = class SkyrimSkillCommand extends Command { const { body } = await request.get(image); const base = await loadImage(body); const plate = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'skyrim-skill.png')); - const ratio = base.width / base.height; - const height = Math.round(plate.width / ratio); - const canvas = createCanvas(base.width, base.height + height); + const ratio = plate.width / plate.height; + const height = Math.round(base.width / ratio); + const canvas = createCanvas(plate.width, plate.height + height); const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0); - const fontSize = Math.round(77 / ratio); - ctx.font = `normal bold ${fontSize}px Futura`; - ctx.fillStyle = 'white'; + ctx.font = 'normal bold 77px Futura'; ctx.textAlign = 'center'; ctx.textBaseline = 'top'; - ctx.strokeStyle = 'black'; - ctx.lineWidth = 10; - ctx.strokeText(skill, 189, base.height + 84); - ctx.fillText(skill, 189, base.height + 84); + ctx.fillStyle = 'black'; + ctx.fillText(skill, 189 + 5, height + 84 + 3); + ctx.fillStyle = 'white'; + ctx.fillText(skill, 189, height + 84); const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'skyrim-skill.png' }] });