|
|
@ -1,5 +1,4 @@
|
|
|
|
const Canvas = require("canvas");
|
|
|
|
const Canvas = require("canvas");
|
|
|
|
const jimp = require("jimp");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = class Rip {
|
|
|
|
module.exports = class Rip {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -9,12 +8,12 @@ module.exports = class Rip {
|
|
|
|
|
|
|
|
|
|
|
|
async getImage(image) {
|
|
|
|
async getImage(image) {
|
|
|
|
if (!image) throw new Error(`You must provide an image.`);
|
|
|
|
if (!image) throw new Error(`You must provide an image.`);
|
|
|
|
const canvas = Canvas.createCanvas(244, 253);
|
|
|
|
const canvas = Canvas.createCanvas(720, 405);
|
|
|
|
const ctx = canvas.getContext(`2d`);
|
|
|
|
const ctx = canvas.getContext(`2d`);
|
|
|
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/rip.png`);
|
|
|
|
const background = await Canvas.loadImage(`${__dirname}/../../assets/rip.png`);
|
|
|
|
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
|
|
|
|
|
|
|
const avatar = await Canvas.loadImage(image);
|
|
|
|
const avatar = await Canvas.loadImage(image);
|
|
|
|
ctx.drawImage(avatar, 63, 110, 90, 90);
|
|
|
|
ctx.drawImage(avatar, 110, 47, 85, 85);
|
|
|
|
|
|
|
|
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
|
|
|
return canvas.toBuffer();
|
|
|
|
return canvas.toBuffer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|