mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-10 19:04:42 +02:00
Fix?
This commit is contained in:
@@ -38,12 +38,14 @@ module.exports = class HeLivesInYouCommand extends Command {
|
||||
const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'he-lives-in-you.png'));
|
||||
const { body } = await snekfetch.get(avatarURL);
|
||||
const avatar = await loadImage(body);
|
||||
const avatarCanvas = createCanvas(avatar.width, avatar.height);
|
||||
const avatarCtx = avatarCanvas.getContext('2d');
|
||||
distort(avatarCtx, 0, 0, avatar.width, avatar.height);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.rotate(-24 * (Math.PI / 180));
|
||||
drawImageWithTint(ctx, avatar, '#00115d', 75, 160, 130, 150);
|
||||
distort(ctx, 5, 75, 160, 130, 150);
|
||||
drawImageWithTint(ctx, avatarCanvas, '#00115d', 75, 160, 130, 150);
|
||||
ctx.rotate(24 * (Math.PI / 180));
|
||||
return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'he-lives-in-you.png' }] });
|
||||
} catch (err) {
|
||||
|
||||
+3
-3
@@ -78,12 +78,12 @@ class CanvasUtil {
|
||||
}
|
||||
|
||||
static drawImageWithTint(ctx, image, color, x, y, width, height) {
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(x, y, width, height);
|
||||
ctx.drawImage(image, x, y, width, height);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillRect(x, y, width, height);
|
||||
ctx.fillStyle = '#000000';
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user