Vertical text center in lisa-presentation

This commit is contained in:
Dragon Fire
2020-04-21 11:10:40 -04:00
parent 7387f1c6f0
commit 509635e120
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -50,6 +50,7 @@ module.exports = class LisaPresentationCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.font = '40px Noto';
let fontSize = 40;
while (ctx.measureText(text).width > 1320) {
@@ -57,9 +58,10 @@ module.exports = class LisaPresentationCommand extends Command {
ctx.font = `${fontSize}px Noto`;
}
const lines = await wrapText(ctx, text, 330);
const topMost = 325 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const textHeight = 95 + (i * fontSize) + (i * 10);
ctx.fillText(lines[i], base.width / 2, textHeight);
const height = topMost + ((fontSize + 20) * i);
ctx.fillText(lines[i], base.width / 2, height);
}
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'lisa-presentation.png' }] });
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "113.12.0",
"version": "113.12.1",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {