Illegal GIF

This commit is contained in:
Dragon Fire
2020-07-14 09:41:17 -04:00
parent f72b883ffe
commit 72d1d9d777
54 changed files with 276 additions and 30 deletions
-3
View File
@@ -13,6 +13,3 @@ config.json
command-leaderboard.json
# In-Development Commands
assets/images/illegal/
assets/json/illegal.json
commands/edit-meme/illegal.js
+1 -1
View File
@@ -1110,7 +1110,6 @@ here.
* google-feud (Autofill API)
* gru-plan ([Noto Font](https://www.google.com/get/noto/))
* if-those-kids-could-read ([Noto Font](https://www.google.com/get/noto/))
* illegal ([Noto Font](https://www.google.com/get/noto/))
* lisa-presentation ([Noto Font](https://www.google.com/get/noto/))
* map ([Maps Static API](https://developers.google.com/maps/documentation/maps-static/intro))
* mario-bros-views ([Noto Font](https://www.google.com/get/noto/))
@@ -1544,6 +1543,7 @@ here.
* pokedex (Images)
* whos-that-pokemon (Images)
- [ShareFonts.net](https://www.wfonts.com/)
* illegal ([Impact Font](https://www.wfonts.com/font/impact))
* meme-gen-classic ([Impact Font](https://www.wfonts.com/font/impact))
- [shibe.online](https://shibe.online/)
* bird (API)
Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

+237
View File
@@ -0,0 +1,237 @@
[
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_00.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_02.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_03.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_05.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_06.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_07.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_08.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_09.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_11.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_12.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_14.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_15.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_16.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_17.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_18.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_21.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_22.png",
"show": false
},
{
"corners": [[0, 0], [0, 0], [0, 0]],
"file": "Trump_24.png",
"show": false
},
{
"corners": [[245, 168], [206, 190], [173, 190]],
"file": "Trump_25.png",
"show": true
},
{
"corners": [[241.0, 144], [216, 177], [166, 177.5]],
"file": "Trump_26.png",
"show": true
},
{
"corners": [[224.5, 112.0], [253, 152], [160, 168]],
"file": "Trump_28.png",
"show": true
},
{
"corners": [[213, 102], [268, 141], [161, 169]],
"file": "Trump_29.png",
"show": true
},
{
"corners": [[200, 95], [272, 129], [164, 169]],
"file": "Trump_30.png",
"show": true
},
{
"corners": [[170.5, 95.5], [238, 110], [160, 175]],
"file": "Trump_32.png",
"show": true
},
{
"corners": [[157.0, 97.5], [219, 106], [157.0, 178.0]],
"file": "Trump_33.png",
"show": true
},
{
"corners": [[144, 101], [199, 103], [151, 180]],
"file": "Trump_35.png",
"show": true
},
{
"corners": [[147, 101], [202, 104], [153, 180]],
"file": "Trump_37.png",
"show": true
},
{
"corners": [[145, 100], [202, 103], [151, 179]],
"file": "Trump_38.png",
"show": true
},
{
"corners": [[140, 101], [202, 105], [143, 180]],
"file": "Trump_39.png",
"show": true
},
{
"corners": [[107, 104], [182, 108], [104, 185]],
"file": "Trump_41.png",
"show": true
},
{
"corners": [[84, 102], [163, 107], [80, 185]],
"file": "Trump_42.png",
"show": true
},
{
"corners": [[69.5, 101], [148, 107], [62.5, 185]],
"file": "Trump_43.png",
"show": true
},
{
"corners": [[60, 102], [137, 108], [53, 185]],
"file": "Trump_44.png",
"show": true
},
{
"corners": [[58.0, 104], [134, 110], [49.0, 186.0]],
"file": "Trump_45.png",
"show": true
},
{
"corners": [[62.0, 102], [137, 109], [53.0, 184]],
"file": "Trump_46.png",
"show": true
},
{
"corners": [[83.5, 98], [138, 111], [66, 178]],
"file": "Trump_47.png",
"show": true
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_48.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_49.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_50.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_51.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_52.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_54.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_55.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_57.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_59.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_60.png",
"show": false
},
{
"corners": [[11, 23], [39, 18], [22, 53]],
"file": "Trump_62.png",
"show": false
}
]
+1 -1
View File
@@ -17,7 +17,7 @@ module.exports = class FireCommand extends Command {
description: 'Burns a user\'s avatar.',
throttling: {
usages: 1,
duration: 10
duration: 30
},
clientPermissions: ['ATTACH_FILES'],
credit: [
+1 -1
View File
@@ -18,7 +18,7 @@ module.exports = class TriggeredCommand extends Command {
description: 'Draws a user\'s avatar over the "Triggered" meme.',
throttling: {
usages: 1,
duration: 10
duration: 30
},
clientPermissions: ['ATTACH_FILES'],
credit: [
+35 -23
View File
@@ -1,10 +1,10 @@
const Command = require('../../structures/Command');
const { createCanvas, loadImage, registerFont } = require('canvas');
const GIFEncoder = require('gifencoder');
const path = require('path');
const { wrapText } = require('../../util/Canvas');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' });
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' });
const { streamToArray } = require('../../util/Util');
const frames = require('../../assets/json/illegal');
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Impact.ttf'), { family: 'Impact' });
module.exports = class IllegalCommand extends Command {
constructor(client) {
@@ -16,7 +16,7 @@ module.exports = class IllegalCommand extends Command {
description: 'Makes President Trump make your text illegal.',
throttling: {
usages: 1,
duration: 10
duration: 30
},
clientPermissions: ['ATTACH_FILES'],
credit: [
@@ -26,10 +26,10 @@ module.exports = class IllegalCommand extends Command {
reason: 'Himself, Image'
},
{
name: 'Google',
url: 'https://www.google.com/',
reason: 'Noto Font',
reasonURL: 'https://www.google.com/get/noto/'
name: 'ShareFonts.net',
url: 'https://www.wfonts.com/',
reason: 'Impact Font',
reasonURL: 'https://www.wfonts.com/font/impact'
}
],
args: [
@@ -53,21 +53,33 @@ module.exports = class IllegalCommand extends Command {
}
async run(msg, { text, verb }) {
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png'));
const canvas = createCanvas(base.width, base.height);
const encoder = new GIFEncoder(262, 264);
const stream = encoder.createReadStream();
encoder.start();
encoder.setRepeat(0);
encoder.setDelay(100);
encoder.setQuality(200);
const canvas = createCanvas(262, 264);
const ctx = canvas.getContext('2d');
ctx.drawImage(base, 0, 0);
ctx.rotate(7 * (Math.PI / 180));
const illegalText = `${text} ${verb} NOW ILLEGAL.`;
let fontSize = 45;
ctx.font = `${fontSize}px Noto`;
while (ctx.measureText(illegalText).width > 550) {
fontSize--;
ctx.font = `${fontSize}px Noto`;
for (const frame of frames) {
const img = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal', frame.file));
ctx.drawImage(img, 0, 0);
if (!frame.show) {
encoder.addFrame(ctx);
ctx.clearRect(0, 0, canvas.width, canvas.height);
continue;
}
ctx.textBaseline = 'top';
ctx.font = '20px Impact';
const widthMid = frame.corners[2][0] - frame.corners[0][0];
const heightMid = frame.corners[2][1] - frame.corners[0][1];
const maxLen = frame.corners[0][0] - frame.corners[2][0];
ctx.fillText(`${text}\n${verb} NOW\nILLEGAL`, widthMid, heightMid, maxLen);
encoder.addFrame(Ctx);
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
const lines = await wrapText(ctx, illegalText, 200);
ctx.fillText(lines.join('\n'), 750, 290);
ctx.rotate(-7 * (Math.PI / 180));
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] });
encoder.finish();
const buffer = await streamToArray(stream);
return msg.say({ files: [{ attachment: Buffer.concat(buffer), name: 'illegal.gif' }] });
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "119.17.4",
"version": "119.17.5",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {