diff --git a/README.md b/README.md index 47b0dab1..96b1f837 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 525 +Total: 526 ### Utility: @@ -597,6 +597,7 @@ Total: 525 * **fire-frame:** Draws a fiery border over an image or a user's avatar. * **fish-eye:** Draws an image or a user's avatar but with a fish-eye lens. * **frame:** Draws a frame around an image or a user's avatar. +* **gandhi-quote:** Makes Mahatma Gandhi say the quote you want. * **ghost:** Draws an image or a user's avatar but with a ghost-like transparency. * **glass-shatter:** Draws an image or a user's avatar with a glass shatter in front of it. * **glitch:** Draws an image or a user's avatar but glitched. @@ -1122,6 +1123,8 @@ here. * word-chain ([Moby Word Lists](http://www.gutenberg.org/ebooks/3201)) - [Gravatar](https://en.gravatar.com/) * gravatar ([API](https://en.gravatar.com/site/implement/)) +- [GUST e-foundry](https://www.fontsquirrel.com/fonts/list/foundry/gust-e-foundry) + * gandhi-quote ([Latin Modern Roman Font](https://www.fontsquirrel.com/fonts/Latin-Modern-Roman)) - [Hackyon](http://www.hackyon.com/playground/fisheye/) * fish-eye (Fish-Eye Code) - [Hasbro](https://shop.hasbro.com/en-us) @@ -1378,6 +1381,7 @@ here. * dislike (Concept) * enslaved (Concept) * for-five-hours (Concept) + * gandhi-quote (Concept) * gun (Concept) * hands (Concept) * hentai (Original Subreddit List) diff --git a/assets/fonts/lmroman10-italic.otf b/assets/fonts/lmroman10-italic.otf new file mode 100644 index 00000000..06dd2a1f Binary files /dev/null and b/assets/fonts/lmroman10-italic.otf differ diff --git a/assets/images/gandhi-quote.png b/assets/images/gandhi-quote.png new file mode 100644 index 00000000..1dc79be3 Binary files /dev/null and b/assets/images/gandhi-quote.png differ diff --git a/commands/edit-image/gandhi-quote.js b/commands/edit-image/gandhi-quote.js new file mode 100644 index 00000000..fa38217f --- /dev/null +++ b/commands/edit-image/gandhi-quote.js @@ -0,0 +1,68 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const path = require('path'); +const { wrapText } = require('../../util/Canvas'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'lmroman10-italic.otf'), { + family: 'Latin Modern Roman', + weight: 'italic' +}); + +module.exports = class GandhiQuoteCommand extends Command { + constructor(client) { + super(client, { + name: 'gandhi-quote', + aliases: ['gandhi', 'mahatma-gandhi', 'mahatma-gandhi-quote'], + group: 'edit-meme', + memberName: 'gandhi-quote', + description: 'Makes Mahatma Gandhi say the quote you want.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'GUST e-foundry', + url: 'https://www.fontsquirrel.com/fonts/list/foundry/gust-e-foundry', + reason: 'Latin Modern Roman Font', + reasonURL: 'https://www.fontsquirrel.com/fonts/Latin-Modern-Roman' + }, + { + name: 'Overtime2005', + url: 'https://github.com/Overtime2005', + reason: 'Concept' + } + ], + args: [ + { + key: 'quote', + prompt: 'What quote should Gandhi say?', + type: 'string', + max: 500 + } + ] + }); + } + + async run(msg, { text }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'gandhi-quote.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.textAlign = 'center'; + ctx.textBaseline = 'top'; + ctx.font = 'normal italic 50px Latin Modern Roman'; + let fontSize = 50; + while (ctx.measureText(text).width > 1485) { + fontSize--; + ctx.font = `${fontSize}px Noto`; + } + const lines = await wrapText(ctx, text, 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); + ctx.fillText(lines[i], 395, height); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'gandhi-quote.png' }] }); + } +}; diff --git a/commands/edit-meme/mario-bros-views.js b/commands/edit-meme/mario-bros-views.js index 3700e0b8..38d56d91 100644 --- a/commands/edit-meme/mario-bros-views.js +++ b/commands/edit-meme/mario-bros-views.js @@ -73,7 +73,7 @@ module.exports = class MarioBrosViewsCommand extends Command { ctx.fillStyle = 'white'; ctx.font = '36px Noto'; let fontSize = 36; - while (ctx.measureText(mario).width > 900) { + while (ctx.measureText(mario).width > 800) { fontSize--; ctx.font = `${fontSize}px Noto`; } @@ -88,7 +88,7 @@ module.exports = class MarioBrosViewsCommand extends Command { } ctx.font = '36px Noto'; fontSize = 36; - while (ctx.measureText(luigi).width > 900) { + while (ctx.measureText(luigi).width > 800) { fontSize--; ctx.font = `${fontSize}px Noto`; } diff --git a/package.json b/package.json index e87e612d..b65aeffb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.7.4", + "version": "119.8.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {