mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
wrapText is no longer async
This commit is contained in:
@@ -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` }] });
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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' }] });
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = class SubtitleCommand extends Command {
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
ctx.fillStyle = 'yellow';
|
||||
ctx.textAlign = 'center';
|
||||
const lines = await wrapText(ctx, text, base.width - 10);
|
||||
const lines = wrapText(ctx, text, base.width - 10);
|
||||
if (!lines) return msg.reply('There\'s not enough width to subtitle this image.');
|
||||
ctx.textBaseline = 'bottom';
|
||||
const initial = base.height - ((lines.length - 1) * fontSize) - (fontSize / 2) - ((lines.length - 1) * 10);
|
||||
|
||||
@@ -138,7 +138,7 @@ module.exports = class YuGiOhGenCommand extends Command {
|
||||
}
|
||||
const font = monsterType === 'normal' ? 'Stone Serif LT Italic.ttf' : 'Matrix Book.ttf';
|
||||
ctx.font = this.client.fonts.get(font).toCanvasString(27);
|
||||
const wrappedEffect = await wrapText(ctx, effect, 690);
|
||||
const wrappedEffect = wrapText(ctx, effect, 690);
|
||||
const trimmed = wrappedEffect.slice(0, type === 'monster' ? 4 : 6);
|
||||
ctx.fillText(trimmed.join('\n'), 63, 933 - (type === 'monster' ? 0 : 34));
|
||||
ctx.font = this.client.fonts.get('Stone Serif.ttf').toCanvasString(22);
|
||||
|
||||
@@ -49,7 +49,7 @@ module.exports = class AlertCommand extends Command {
|
||||
ctx.font = this.client.fonts.get('SF-Pro-Display-Medium.otf').toCanvasString(30);
|
||||
ctx.fillStyle = '#1f1f1f';
|
||||
ctx.textBaseline = 'top';
|
||||
let text = await wrapText(ctx, message, 540);
|
||||
let text = wrapText(ctx, message, 540);
|
||||
text = text.length > 3 ? `${text.slice(0, 3).join('\n')}...` : text.join('\n');
|
||||
ctx.fillText(text, 48, 178);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'alert.png' }] });
|
||||
|
||||
@@ -50,7 +50,7 @@ module.exports = class BeLikeBillCommand extends Command {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.font = this.client.fonts.get('arialbd.ttf').toCanvasString(23);
|
||||
const text = await wrapText(ctx, texts[Math.floor(Math.random() * texts.length)].replaceAll('{{name}}', name), 569);
|
||||
const text = wrapText(ctx, texts[Math.floor(Math.random() * texts.length)].replaceAll('{{name}}', name), 569);
|
||||
ctx.fillText(stripIndents`
|
||||
This is ${name}.
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class ChangeMyMindCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 337);
|
||||
const lines = wrapText(ctx, text, 337);
|
||||
ctx.fillText(lines.join('\n'), 142, 430, 337);
|
||||
ctx.rotate(24 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'change-my-mind.png' }] });
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class ChiIdeaCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('wildwordsroman.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 83);
|
||||
const lines = wrapText(ctx, text, 83);
|
||||
const topMost = 137 - (((fontSize * lines.length) / 2) + ((5 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 5) * i);
|
||||
|
||||
@@ -68,10 +68,10 @@ module.exports = class DearLiberalsCommand extends Command {
|
||||
ctx.rotate(-12.30 * (Math.PI / 180));
|
||||
ctx.fillStyle = '#002046';
|
||||
ctx.font = this.client.fonts.get('Oswald-SemiBold.ttf').toCanvasString(27);
|
||||
const blueLines = await wrapText(ctx, blueText, 270);
|
||||
const blueLines = wrapText(ctx, blueText, 270);
|
||||
ctx.fillText(blueLines.join('\n'), 207, 90);
|
||||
ctx.fillStyle = '#c31a41';
|
||||
const redLines = await wrapText(ctx, redText, 165);
|
||||
const redLines = wrapText(ctx, redText, 165);
|
||||
ctx.fillText(redLines.join('\n'), 326, 236);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'dear-liberals.png' }] });
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class DrakepostingCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const nahLines = await wrapText(ctx, nah, 462);
|
||||
const nahLines = wrapText(ctx, nah, 462);
|
||||
const nahTopMost = 256 - (((fontSize * nahLines.length) / 2) + ((10 * (nahLines.length - 1)) / 2));
|
||||
for (let i = 0; i < nahLines.length; i++) {
|
||||
const height = nahTopMost + ((fontSize + 10) * i);
|
||||
@@ -71,7 +71,7 @@ module.exports = class DrakepostingCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const yeahLines = await wrapText(ctx, yeah, 462);
|
||||
const yeahLines = wrapText(ctx, yeah, 462);
|
||||
const yeahTopMost = 768 - (((fontSize * yeahLines.length) / 2) + ((10 * (yeahLines.length - 1)) / 2));
|
||||
for (let i = 0; i < yeahLines.length; i++) {
|
||||
const height = yeahTopMost + ((fontSize + 10) * i);
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class EddFactsBookCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, fact, 183);
|
||||
const lines = wrapText(ctx, fact, 183);
|
||||
ctx.fillText(lines.join('\n'), 119, 306, 183);
|
||||
ctx.rotate(-15 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'edd-facts-book.png' }] });
|
||||
|
||||
@@ -55,7 +55,7 @@ module.exports = class GenieRulesCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 381);
|
||||
const lines = wrapText(ctx, text, 381);
|
||||
const topMost = 580 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 20) * i);
|
||||
|
||||
@@ -72,7 +72,7 @@ module.exports = class GruPlanCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, step, 252);
|
||||
const lines = wrapText(ctx, step, 252);
|
||||
ctx.fillText(lines.join('\n'), x, y);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ module.exports = class IfThoseKidsCouldReadCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 160);
|
||||
const lines = wrapText(ctx, text, 160);
|
||||
const topMost = 140 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 20) * i);
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class LisaPresentationCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 330);
|
||||
const lines = wrapText(ctx, text, 330);
|
||||
const topMost = 185 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 20) * i);
|
||||
|
||||
@@ -67,7 +67,7 @@ module.exports = class MarioBrosViewsCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const marioLines = await wrapText(ctx, mario, 200);
|
||||
const marioLines = wrapText(ctx, mario, 200);
|
||||
const marioTopMost = 450 - (((fontSize * marioLines.length) / 2) + ((20 * (marioLines.length - 1)) / 2));
|
||||
for (let i = 0; i < marioLines.length; i++) {
|
||||
ctx.strokeStyle = 'black';
|
||||
@@ -82,7 +82,7 @@ module.exports = class MarioBrosViewsCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const luigiLines = await wrapText(ctx, luigi, 200);
|
||||
const luigiLines = wrapText(ctx, luigi, 200);
|
||||
const luigiTopMost = 450 - (((fontSize * luigiLines.length) / 2) + ((20 * (luigiLines.length - 1)) / 2));
|
||||
for (let i = 0; i < luigiLines.length; i++) {
|
||||
ctx.strokeStyle = 'black';
|
||||
|
||||
@@ -58,7 +58,7 @@ module.exports = class MemeGenCommand extends Command {
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'top';
|
||||
const topLines = await wrapText(ctx, top, base.width - 10);
|
||||
const topLines = wrapText(ctx, top, base.width - 10);
|
||||
if (!topLines) return msg.reply('There\'s not enough width to make a meme with this image.');
|
||||
for (let i = 0; i < topLines.length; i++) {
|
||||
const textHeight = (i * fontSize) + (i * 10);
|
||||
@@ -68,7 +68,7 @@ module.exports = class MemeGenCommand extends Command {
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillText(topLines[i], base.width / 2, textHeight);
|
||||
}
|
||||
const bottomLines = await wrapText(ctx, bottom, base.width - 10);
|
||||
const bottomLines = wrapText(ctx, bottom, base.width - 10);
|
||||
if (!bottomLines) return msg.reply('There\'s not enough width to make a meme with this image.');
|
||||
ctx.textBaseline = 'bottom';
|
||||
const initial = base.height - ((bottomLines.length - 1) * fontSize) - ((bottomLines.length - 1) * 10);
|
||||
|
||||
@@ -67,7 +67,7 @@ module.exports = class NikeAdCommand extends Command {
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.textAlign = 'center';
|
||||
const lines = await wrapText(ctx, `Believe in ${something}. Even if it means ${sacrifice}.`, data.width - 20);
|
||||
const lines = wrapText(ctx, `Believe in ${something}. Even if it means ${sacrifice}.`, data.width - 20);
|
||||
if (!lines) return msg.reply('There\'s not enough width to make a Nike ad with this image.');
|
||||
const initial = data.height / 2;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class PanikKalmPanikCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const panikLines = await wrapText(ctx, panik, 284);
|
||||
const panikLines = wrapText(ctx, panik, 284);
|
||||
const panikTopMost = 130 - (((fontSize * panikLines.length) / 2) + ((10 * (panikLines.length - 1)) / 2));
|
||||
for (let i = 0; i < panikLines.length; i++) {
|
||||
const height = panikTopMost + ((fontSize + 10) * i);
|
||||
@@ -71,7 +71,7 @@ module.exports = class PanikKalmPanikCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const kalmLines = await wrapText(ctx, kalm, 284);
|
||||
const kalmLines = wrapText(ctx, kalm, 284);
|
||||
const kalmTopMost = 430 - (((fontSize * kalmLines.length) / 2) + ((10 * (kalmLines.length - 1)) / 2));
|
||||
for (let i = 0; i < kalmLines.length; i++) {
|
||||
const height = kalmTopMost + ((fontSize + 10) * i);
|
||||
@@ -83,7 +83,7 @@ module.exports = class PanikKalmPanikCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const panik2Lines = await wrapText(ctx, panik2, 284);
|
||||
const panik2Lines = wrapText(ctx, panik2, 284);
|
||||
const panik2TopMost = 730 - (((fontSize * panik2Lines.length) / 2) + ((10 * (panik2Lines.length - 1)) / 2));
|
||||
for (let i = 0; i < panik2Lines.length; i++) {
|
||||
const height = panik2TopMost + ((fontSize + 10) * i);
|
||||
|
||||
@@ -48,7 +48,7 @@ module.exports = class PillsCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 280);
|
||||
const lines = wrapText(ctx, text, 280);
|
||||
const topMost = 455 - (((fontSize * lines.length) / 2) + ((10 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
ctx.strokeStyle = 'white';
|
||||
|
||||
@@ -72,7 +72,7 @@ module.exports = class PlanktonPlanCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, step, 155);
|
||||
const lines = wrapText(ctx, step, 155);
|
||||
ctx.fillText(lines.join('\n'), x, y);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = class ReactionMemeCommand extends Command {
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(40);
|
||||
const lines = await wrapText(ctx, text, base.width - 10);
|
||||
const lines = wrapText(ctx, text, base.width - 10);
|
||||
const lineBreakLen = text.split('\n').length;
|
||||
const linesLen = (40 * lines.length)
|
||||
+ (40 * (lineBreakLen - 1))
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class ScrollOfTruthCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 217);
|
||||
const lines = wrapText(ctx, text, 217);
|
||||
const topMost = 850 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 20) * i);
|
||||
|
||||
@@ -53,7 +53,7 @@ module.exports = class SonicSaysCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 185);
|
||||
const lines = wrapText(ctx, text, 185);
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.fillText(lines.join('\n'), 92, 67, 185);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'sonic-says.png' }] });
|
||||
|
||||
@@ -60,7 +60,7 @@ module.exports = class SpidermanPointingCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, first, 290);
|
||||
const lines = wrapText(ctx, first, 290);
|
||||
const topMost = 189 - (((fontSize * lines.length) / 2) + ((10 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
ctx.strokeStyle = 'black';
|
||||
@@ -75,7 +75,7 @@ module.exports = class SpidermanPointingCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines2 = await wrapText(ctx, second, 290);
|
||||
const lines2 = wrapText(ctx, second, 290);
|
||||
const topMost2 = 190 - (((fontSize * lines2.length) / 2) + ((10 * (lines2.length - 1)) / 2));
|
||||
for (let i = 0; i < lines2.length; i++) {
|
||||
ctx.strokeStyle = 'black';
|
||||
|
||||
@@ -60,7 +60,7 @@ module.exports = class SpongebobBurnCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, burn, 180);
|
||||
const lines = wrapText(ctx, burn, 180);
|
||||
ctx.fillText(lines.join('\n'), 55, 103);
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(25);
|
||||
ctx.fillText(person, 382, 26);
|
||||
|
||||
@@ -54,7 +54,7 @@ module.exports = class ThatSignWontStopMeCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('TragicMarker.otf').toCanvasString(fontSize);
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 334);
|
||||
const lines = wrapText(ctx, text, 334);
|
||||
const topMost = 240 - (((fontSize * lines.length) / 2) + ((10 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 10) * i);
|
||||
@@ -66,7 +66,7 @@ module.exports = class ThatSignWontStopMeCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('TragicMarker.otf').toCanvasString(fontSize);
|
||||
}
|
||||
const bLines = await wrapText(ctx, text, 88);
|
||||
const bLines = wrapText(ctx, text, 88);
|
||||
const bTopMost = 645 - (((fontSize * bLines.length) / 2) + ((2 * (bLines.length - 1)) / 2));
|
||||
for (let i = 0; i < bLines.length; i++) {
|
||||
const height = bTopMost + ((fontSize + 2) * i);
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class TuxedoPoohCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const normalLines = await wrapText(ctx, normal, 440);
|
||||
const normalLines = wrapText(ctx, normal, 440);
|
||||
const normalTopMost = 145 - (((fontSize * normalLines.length) / 2) + ((10 * (normalLines.length - 1)) / 2));
|
||||
for (let i = 0; i < normalLines.length; i++) {
|
||||
const height = normalTopMost + ((fontSize + 10) * i);
|
||||
@@ -71,7 +71,7 @@ module.exports = class TuxedoPoohCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const tuxedoLines = await wrapText(ctx, tuxedo, 440);
|
||||
const tuxedoLines = wrapText(ctx, tuxedo, 440);
|
||||
const tuxedoTopMost = 436 - (((fontSize * tuxedoLines.length) / 2) + ((10 * (tuxedoLines.length - 1)) / 2));
|
||||
for (let i = 0; i < tuxedoLines.length; i++) {
|
||||
const height = tuxedoTopMost + ((fontSize + 10) * i);
|
||||
|
||||
@@ -59,7 +59,7 @@ module.exports = class TwoButtonsCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const firstLines = await wrapText(ctx, first, 183);
|
||||
const firstLines = wrapText(ctx, first, 183);
|
||||
let lineOffset = 0;
|
||||
for (let i = 0; i < firstLines.length; i++) {
|
||||
ctx.fillText(firstLines[i], 25 + lineOffset, 116 + (fontSize * i) + (10 * i), 183);
|
||||
@@ -71,7 +71,7 @@ module.exports = class TwoButtonsCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const secondLines = await wrapText(ctx, second, 118);
|
||||
const secondLines = wrapText(ctx, second, 118);
|
||||
lineOffset = 0;
|
||||
for (let i = 0; i < secondLines.length; i++) {
|
||||
ctx.fillText(secondLines[i], 254 + lineOffset, 130 + (fontSize * i) + (10 * i), 118);
|
||||
|
||||
@@ -58,7 +58,7 @@ module.exports = class WhiteboardCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const initialLines = await wrapText(ctx, initial, 405);
|
||||
const initialLines = wrapText(ctx, initial, 405);
|
||||
const initialTopMost = 111 - (((fontSize * initialLines.length) / 2) + ((10 * (initialLines.length - 1)) / 2));
|
||||
for (let i = 0; i < initialLines.length; i++) {
|
||||
const height = initialTopMost + ((fontSize + 10) * i);
|
||||
@@ -70,7 +70,7 @@ module.exports = class WhiteboardCommand extends Command {
|
||||
fontSize--;
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(fontSize);
|
||||
}
|
||||
const resolveLines = await wrapText(ctx, resolved, 367);
|
||||
const resolveLines = wrapText(ctx, resolved, 367);
|
||||
const resolveTopMost = 500 - (((fontSize * resolveLines.length) / 2) + ((10 * (resolveLines.length - 1)) / 2));
|
||||
for (let i = 0; i < resolveLines.length; i++) {
|
||||
const height = resolveTopMost + ((fontSize + 10) * i);
|
||||
|
||||
@@ -79,7 +79,7 @@ module.exports = class JeopardyCommand extends Command {
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = this.client.fonts.get('OPTIKorinna-Agency.otf').toCanvasString(62);
|
||||
const lines = await wrapText(ctx, question.toUpperCase(), 813);
|
||||
const lines = wrapText(ctx, question.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);
|
||||
|
||||
Reference in New Issue
Block a user