From 3d1e245331d590962bbbdb29e646087b17ac62c3 Mon Sep 17 00:00:00 2001 From: SrIzan10 <66965250+SrIzan10@users.noreply.github.com> Date: Thu, 5 Jan 2023 21:02:34 +0100 Subject: [PATCH] feat: auto adapt text in megamind --- commands/fun/megamind.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/fun/megamind.ts b/commands/fun/megamind.ts index b7d7e55..0948efb 100644 --- a/commands/fun/megamind.ts +++ b/commands/fun/megamind.ts @@ -36,7 +36,11 @@ export default commandModule({ context.drawImage(background, 0, 0, canvas.width, canvas.height) const text = `No ${option}?` - context.font = '50px Impact' + let fontsize = 60 + do { + fontsize--; + context.font = fontsize + "px Impact"; + } while (context.measureText(text).width > canvas.width) context.fillStyle = 'white' context.textAlign = 'center' context.textBaseline = 'middle'