feat: auto adapt text in megamind

This commit is contained in:
2023-01-05 21:02:34 +01:00
parent 6f96eec7fe
commit 3d1e245331

View File

@@ -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'