mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Make spongebob time cards look nicer
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user