Make spongebob time cards look nicer

This commit is contained in:
Dragon Fire
2024-04-26 00:40:44 -04:00
parent b44e0ece1b
commit b2587f0c9c
@@ -57,11 +57,18 @@ module.exports = class SpongebobTimeCardCommand extends Command {
ctx.drawImage(base, 0, 0);
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.font = this.client.fonts.get('Spongeboytt1.ttf').toCanvasString(115);
const lines = wrapText(ctx, text.toUpperCase(), 1800);
const topMost = (canvas.height / 2) - (((115 * lines.length) / 2) + ((60 * (lines.length - 1)) / 2));
let fontSize = 345;
ctx.font = this.client.fonts.get('Spongeboytt1.ttf').toCanvasString(fontSize);
let metrics = ctx.measureText(lines.join('\n'));
while (metrics.width > 1800 || (metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent) > 1000) {
fontSize -= 10;
ctx.font = this.client.fonts.get('Spongeboytt1.ttf').toCanvasString(fontSize);
metrics = ctx.measureText(lines.join('\n'));
}
const topMost = (canvas.height / 2) - (((fontSize * lines.length) / 2) + ((60 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((115 + 60) * i);
const height = topMost + ((fontSize + 60) * i);
ctx.fillStyle = '#ecbd3b';
ctx.fillText(lines[i], (canvas.width / 2) + 6, height + 6);
ctx.fillStyle = 'black';