wrapText is no longer async

This commit is contained in:
Dragon Fire
2024-04-26 00:27:42 -04:00
parent fcaa13c576
commit aa78cd91c2
41 changed files with 53 additions and 53 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ module.exports = class AceAttorneyCommand extends Command {
ctx.fillStyle = 'white';
ctx.textBaseline = 'top';
ctx.fillText(firstUpperCase(character), 6, 176);
let text = await wrapText(ctx, quote, 242);
let text = wrapText(ctx, quote, 242);
text = text.length > 5 ? `${text.slice(0, 5).join('\n')}...` : text.join('\n');
ctx.fillText(text, 7, 199);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `ace-attorney-${character}.png` }] });
+1 -1
View File
@@ -54,7 +54,7 @@ module.exports = class CautionCommand extends Command {
fontSize--;
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(fontSize);
}
const lines = await wrapText(ctx, text.toUpperCase(), 895);
const lines = wrapText(ctx, text.toUpperCase(), 895);
const topMost = 470 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((fontSize + 20) * i);
@@ -49,7 +49,7 @@ module.exports = class ChineseRestaurantCommand extends Command {
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.font = this.client.fonts.get('Futura Condensed Bold.otf').toCanvasString(28);
const lines = await wrapText(ctx, text.toUpperCase(), 340);
const lines = wrapText(ctx, text.toUpperCase(), 340);
if (lines.length === 1) {
ctx.fillText(lines[0], base.width / 2, 288);
} else if (lines.length === 2) {
+1 -1
View File
@@ -54,7 +54,7 @@ module.exports = class DangerCommand extends Command {
fontSize--;
ctx.font = this.client.fonts.get('Noto-Bold.ttf').toCanvasString(fontSize);
}
const lines = await wrapText(ctx, text.toUpperCase(), 840);
const lines = wrapText(ctx, text.toUpperCase(), 840);
const topMost = 510 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((fontSize + 20) * i);
+1 -1
View File
@@ -37,7 +37,7 @@ module.exports = class FontCommand extends Command {
const ctxPre = canvasPre.getContext('2d');
ctxPre.font = this.client.fonts.get(font.filename).toCanvasString(50);
const len = ctxPre.measureText(text);
const lines = await wrapText(ctxPre, text, 950);
const lines = wrapText(ctxPre, text, 950);
const canvas = createCanvas(Math.min(len.width + 50, 1000), 50 + (50 * lines.length) + (20 * lines.length));
const ctx = canvas.getContext('2d');
ctx.font = this.client.fonts.get(font.filename).toCanvasString(50);
+1 -1
View File
@@ -49,7 +49,7 @@ module.exports = class GandhiQuoteCommand extends Command {
fontSize--;
ctx.font = this.client.fonts.get('lmroman10-italic.otf').toCanvasString(fontSize);
}
const lines = await wrapText(ctx, quote, 270);
const lines = wrapText(ctx, quote, 270);
const topMost = 180 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((fontSize + 20) * i);
+1 -1
View File
@@ -49,7 +49,7 @@ module.exports = class HighwaySignCommand extends Command {
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.font = this.client.fonts.get('EHSMB.ttf').toCanvasString(18);
const lines = await wrapText(ctx, text.toUpperCase(), 178);
const lines = wrapText(ctx, text.toUpperCase(), 178);
if (lines.length === 1) {
ctx.fillText(lines[0], 318, 109);
} else if (lines.length === 2) {
@@ -48,7 +48,7 @@ module.exports = class JeopardyQuestionCommand extends Command {
ctx.textBaseline = 'top';
ctx.fillStyle = 'white';
ctx.font = this.client.fonts.get('OPTIKorinna-Agency.otf').toCanvasString(62);
const lines = await wrapText(ctx, text.toUpperCase(), 813);
const lines = wrapText(ctx, text.toUpperCase(), 813);
const topMost = (canvas.height / 2) - (((52 * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((52 + 20) * i);
@@ -58,7 +58,7 @@ module.exports = class SpongebobTimeCardCommand extends Command {
ctx.textAlign = 'center';
ctx.textBaseline = 'top';
ctx.font = this.client.fonts.get('Spongeboytt1.ttf').toCanvasString(115);
const lines = await wrapText(ctx, text.toUpperCase(), 1800);
const lines = wrapText(ctx, text.toUpperCase(), 1800);
const topMost = (canvas.height / 2) - (((115 * lines.length) / 2) + ((60 * (lines.length - 1)) / 2));
for (let i = 0; i < lines.length; i++) {
const height = topMost + ((115 + 60) * i);
+2 -2
View File
@@ -69,7 +69,7 @@ module.exports = class TweetCommand extends Command {
const canvas = createCanvas(base1.width, base1.height + base2.height);
const ctx = canvas.getContext('2d');
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(23);
const lines = await wrapText(ctx, text, 710);
const lines = wrapText(ctx, text, 710);
const linesLen = (23 * lines.length) + (7 * (lines.length - 1)) + 15;
canvas.height += linesLen;
let imageHeight = 0;
@@ -194,7 +194,7 @@ module.exports = class TweetCommand extends Command {
}
async fillTextWithEmoji(ctx, text, x, y, maxLineLen, emojiSize) {
const wrapped = await wrapText(ctx, text, maxLineLen);
const wrapped = wrapText(ctx, text, maxLineLen);
const emoji = text.match(emojiRegex());
if (!emoji) {
ctx.fillText(wrapped.join('\n'), x, y);
+1 -1
View File
@@ -112,7 +112,7 @@ module.exports = class UndertaleCommand extends Command {
ctx.font = this.client.fonts.get(font).toCanvasString(32);
ctx.fillStyle = 'white';
ctx.textBaseline = 'top';
const text = await wrapText(ctx, quote, 385);
const text = wrapText(ctx, quote, 385);
const lines = text.length > 3 ? 3 : text.length;
for (let i = 0; i < lines; i++) {
ctx.fillText(text[i], 174, 22 + (22 * i) + (22 * i) + (space * i));
+1 -1
View File
@@ -61,7 +61,7 @@ module.exports = class ZeroDialogueCommand extends Command {
ctx.font = this.client.fonts.get('megaman_zero_dialog.ttf').toCanvasString(42);
ctx.fillStyle = 'white';
ctx.textBaseline = 'top';
let text = await wrapText(ctx, quote, 425);
let text = wrapText(ctx, quote, 425);
text = text.length > 2 ? `${text.slice(0, 2).join('\n')}...` : text.join('\n');
ctx.fillText(text, 8, 8);
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'zero-dialogue.png' }] });