From cc4d5d44cc3c33b65d2e1b5d80fdde146143c2ab Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 4 May 2020 14:53:49 -0400 Subject: [PATCH] Better way of scaling --- commands/edit-meme/skyrim-skill.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/commands/edit-meme/skyrim-skill.js b/commands/edit-meme/skyrim-skill.js index 68bbef94..2d34af7e 100644 --- a/commands/edit-meme/skyrim-skill.js +++ b/commands/edit-meme/skyrim-skill.js @@ -61,17 +61,12 @@ module.exports = class SkyrimSkillCommand extends Command { ctx.drawImage(base, 0, 0, plate.width, height); ctx.drawImage(plate, 0, height + 1); ctx.font = '77px Futura'; - let fontSize = 77; - while (ctx.measureText(skill).width > 310) { - fontSize -= 1; - ctx.font = `${fontSize}px Futura`; - } ctx.textAlign = 'center'; ctx.textBaseline = 'top'; ctx.fillStyle = 'black'; - ctx.fillText(skill, 189 + 5, height + 75 + 3); + ctx.fillText(skill, 189 + 5, height + 75 + 3, 310); ctx.fillStyle = 'white'; - ctx.fillText(skill, 189, height + 75); + ctx.fillText(skill, 189, height + 75, 310); 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' }] });