mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 10:19:11 +02:00
Batman
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -1,5 +1,5 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { createCanvas, registerFont } = require('canvas');
|
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { elements, colors } = require('../../assets/json/periodic-table');
|
const { elements, colors } = require('../../assets/json/periodic-table');
|
||||||
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' });
|
||||||
@@ -42,17 +42,22 @@ module.exports = class PeriodicTableCommand extends Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
run(msg, { element }) {
|
async run(msg, { element }) {
|
||||||
const canvas = createCanvas(500, 500);
|
const canvas = createCanvas(500, 500);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
ctx.fillStyle = 'black';
|
ctx.fillStyle = 'black';
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = 'white';
|
||||||
ctx.fillRect(10, 10, canvas.width - 20, canvas.height - 20);
|
ctx.fillRect(10, 10, canvas.width - 20, canvas.height - 20);
|
||||||
ctx.font = '210px Noto';
|
if (element.number === 0) {
|
||||||
ctx.textAlign = 'center';
|
const batman = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'batman.png'));
|
||||||
ctx.fillStyle = colors[element.phase];
|
ctx.drawImage(batman, 100, 166);
|
||||||
ctx.fillText(element.symbol, 250, 320);
|
} else {
|
||||||
|
ctx.font = '210px Noto';
|
||||||
|
ctx.textAlign = 'center';
|
||||||
|
ctx.fillStyle = colors[element.phase];
|
||||||
|
ctx.fillText(element.symbol, 250, 320);
|
||||||
|
}
|
||||||
ctx.fillStyle = 'black';
|
ctx.fillStyle = 'black';
|
||||||
ctx.font = '45px Noto';
|
ctx.font = '45px Noto';
|
||||||
ctx.fillText(element.number, 250, 100);
|
ctx.fillText(element.number, 250, 100);
|
||||||
|
|||||||
Reference in New Issue
Block a user