mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Visual Center Doesn't work :(
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const request = require('node-superfetch');
|
||||
const visualCenter = require('visual-center');
|
||||
|
||||
module.exports = class SnapchatCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -56,9 +55,7 @@ module.exports = class SnapchatCommand extends Command {
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.font = this.client.fonts.get('Noto-Regular.ttf').toCanvasString(base.height / 24);
|
||||
const barHeight = (base.height / 24) * 2;
|
||||
const { visualTop } = await this.visualCenter(body);
|
||||
const moveCenter = visualTop > 0.5 ? 1 - visualTop - 0.5 : visualTop < 0.5 ? 1 + (visualTop - 0.5) : 1;
|
||||
const barPosition = base.height - (base.height * moveCenter);
|
||||
const barPosition = base.height - (base.height / 3);
|
||||
ctx.globalAlpha = 0.3;
|
||||
ctx.fillStyle = 'black';
|
||||
ctx.fillRect(0, barPosition - barHeight, base.width, barHeight);
|
||||
@@ -66,13 +63,4 @@ module.exports = class SnapchatCommand extends Command {
|
||||
ctx.fillText(text, base.width / 2, (barPosition - barHeight) * 0.4);
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'snapchat.png' }] });
|
||||
}
|
||||
|
||||
visualCenter(image) {
|
||||
return new Promise((res, rej) => {
|
||||
visualCenter(image.toString('base64'), (err, data) => {
|
||||
if (err) return rej(err);
|
||||
return res(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -79,7 +79,6 @@
|
||||
"tictactoe-minimax-ai": "^1.2.1",
|
||||
"user-agents": "^1.0.602",
|
||||
"valid-url": "^1.0.9",
|
||||
"visual-center": "^0.1.1",
|
||||
"wavefile": "^11.0.0",
|
||||
"winston": "^3.3.3",
|
||||
"ytdl-core": "^4.5.0"
|
||||
|
||||
Reference in New Issue
Block a user