Wrap text in be like bill

This commit is contained in:
Daniel Odendahl Jr
2018-09-12 17:07:55 +00:00
parent 506e1e2b79
commit a1c6d8d155
4 changed files with 34 additions and 33 deletions
+5 -2
View File
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
const { createCanvas, loadImage, registerFont } = require('canvas');
const { stripIndents } = require('common-tags');
const path = require('path');
const { wrapText } = require('../../util/Canvas');
const texts = require('../../assets/json/be-like-bill');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
@@ -25,7 +26,8 @@ module.exports = class BeLikeBillCommand extends Command {
key: 'name',
prompt: 'What should the name on the meme be?',
type: 'string',
default: 'Bill'
default: 'Bill',
max: 20
}
]
});
@@ -37,10 +39,11 @@ module.exports = class BeLikeBillCommand extends Command {
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.font = '23px Noto';
const text = wrapText(ctx, texts[Math.floor(Math.random() * texts.length)].replace(/{{name}}/gi, name), 600 - 31);
ctx.fillText(stripIndents`
This is ${name}.
${texts[Math.floor(Math.random() * texts.length)].replace(/{{name}}/gi, name)}
${text.join('\n')}
${name} is smart.
Be like ${name}.
+2 -4
View File
@@ -25,15 +25,13 @@ module.exports = class NikeAdCommand extends Command {
key: 'something',
prompt: 'What should the something to believe in be?',
type: 'string',
max: 50,
parse: something => something.toLowerCase()
max: 50
},
{
key: 'sacrifice',
prompt: 'What should believing result in (e.g. sacrificing everything)?',
type: 'string',
max: 50,
parse: sacrifice => sacrifice.toLowerCase()
max: 50
},
{
key: 'image',