Version 1.4.0
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Blur {
|
||||
/**
|
||||
@@ -9,7 +9,7 @@ module.exports = class Blur {
|
||||
async getImage(image, level) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.resize(480, 480);
|
||||
image.blur(isNaN(level) ? 5 : parseInt(level));
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
@@ -17,4 +17,4 @@ module.exports = class Blur {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Gay {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Gay {
|
||||
ctx.drawImage(bg, 0, 0, 480, 480);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Geryscale {
|
||||
/**
|
||||
@@ -8,7 +8,7 @@ module.exports = class Geryscale {
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.resize(480, 480);
|
||||
image.greyscale();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
@@ -16,4 +16,4 @@ module.exports = class Geryscale {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Invert {
|
||||
/**
|
||||
@@ -8,7 +8,7 @@ module.exports = class Invert {
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.resize(480, 480);
|
||||
image.invert();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
@@ -16,4 +16,4 @@ module.exports = class Invert {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Sepia {
|
||||
/**
|
||||
@@ -8,7 +8,7 @@ module.exports = class Sepia {
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.resize(480, 480);
|
||||
image.sepia();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
@@ -16,4 +16,4 @@ module.exports = class Sepia {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -9,7 +9,7 @@ module.exports = {
|
||||
* @param {string} font the font
|
||||
*/
|
||||
applyText(canvas, text, defaultFontSize, width, font){
|
||||
const ctx = canvas.getContext("2d");
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
do {
|
||||
ctx.font = `${(defaultFontSize -= 1)}px ${font}`;
|
||||
} while (ctx.measureText(text).width > width);
|
||||
@@ -19,10 +19,10 @@ module.exports = {
|
||||
wrapText(ctx, text, maxWidth) {
|
||||
return new Promise(resolve => {
|
||||
if (ctx.measureText(text).width < maxWidth) return resolve([text]);
|
||||
if (ctx.measureText('W').width > maxWidth) return resolve(null);
|
||||
const words = text.split(' ');
|
||||
if (ctx.measureText(`W`).width > maxWidth) return resolve(null);
|
||||
const words = text.split(` `);
|
||||
const lines = [];
|
||||
let line = '';
|
||||
let line = ``;
|
||||
while (words.length > 0) {
|
||||
let split = false;
|
||||
while (ctx.measureText(words[0]).width >= maxWidth) {
|
||||
@@ -41,11 +41,11 @@ module.exports = {
|
||||
}
|
||||
else {
|
||||
lines.push(line.trim());
|
||||
line = '';
|
||||
line = ``;
|
||||
}
|
||||
if (words.length === 0) lines.push(line.trim());
|
||||
}
|
||||
return resolve(lines);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
@@ -8,30 +8,28 @@ module.exports = class Blink {
|
||||
* @param {image} image1
|
||||
* @param {image} image2
|
||||
* @param {number} timeout
|
||||
* @param {number} height For later
|
||||
* @param {number} width For later
|
||||
*/
|
||||
async getImage(image1, image2, timeout = 1000, height, width) {
|
||||
async getImage(image1, image2, timeout = 1000) {
|
||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
||||
if (isNaN(timeout)) throw new Error(`The timeout argument must be a number.`)
|
||||
if (isNaN(timeout)) throw new Error(`The timeout argument must be a number.`);
|
||||
const img = await Canvas.loadImage(image1);
|
||||
const base = await Canvas.loadImage(image2);
|
||||
const GIF = new GIFEncoder(480, 480)
|
||||
const GIF = new GIFEncoder(480, 480);
|
||||
GIF.start();
|
||||
GIF.setRepeat(0);
|
||||
GIF.setDelay(timeout);
|
||||
GIF.setTransparent();
|
||||
const canvas = Canvas.createCanvas(480, 480);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
ctx.clearRect(0, 0, 480, 480);
|
||||
ctx.drawImage(img, 0, 0, 480, 480);
|
||||
GIF.addFrame(ctx);
|
||||
const ctx2 = canvas.getContext('2d');
|
||||
const ctx2 = canvas.getContext(`2d`);
|
||||
ctx2.clearRect(0, 0, 480, 480);
|
||||
ctx2.drawImage(base, 0, 0, 480, 480);
|
||||
GIF.addFrame(ctx2)
|
||||
GIF.addFrame(ctx2);
|
||||
GIF.finish();
|
||||
return GIF.out.getData();
|
||||
}
|
||||
}
|
||||
};
|
@@ -10,26 +10,26 @@ module.exports = class Triggered {
|
||||
*/
|
||||
async getImage(image, timeout = 15) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
if (isNaN(timeout)) throw new Error(`The timeout argument must be a number.`)
|
||||
if (isNaN(timeout)) throw new Error(`The timeout argument must be a number.`);
|
||||
const base = await Canvas.loadImage(`${__dirname}/../../assets/triggered.png`);
|
||||
const img = await Canvas.loadImage(image);
|
||||
const GIF = new GIFEncoder(256, 310)
|
||||
const GIF = new GIFEncoder(256, 310);
|
||||
GIF.start();
|
||||
GIF.setRepeat(0);
|
||||
GIF.setDelay(timeout);
|
||||
const canvas = Canvas.createCanvas(256, 310);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
const BR = 20;
|
||||
const LR = 10;
|
||||
for (var i = 0; i < 9; i++) {
|
||||
ctx.clearRect(0, 0, 256, 310);
|
||||
ctx.drawImage(img, Math.floor(Math.random() * BR) - BR, Math.floor(Math.random() * BR) - BR, 256 + BR, 310 - 54 + BR);
|
||||
ctx.fillStyle = '#FF000033';
|
||||
ctx.fillStyle = `#FF000033`;
|
||||
ctx.fillRect(0, 0, 256, 310);
|
||||
ctx.drawImage(base, Math.floor(Math.random() * LR) - LR, 310 - 54 + Math.floor(Math.random() * LR) - LR, 256 + LR, 54 + LR);
|
||||
GIF.addFrame(ctx);
|
||||
};
|
||||
}
|
||||
GIF.finish();
|
||||
return GIF.out.getData();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Ad {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Ad {
|
||||
ctx.drawImage(background, 0, 0, 550, 474);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Affect {
|
||||
/**
|
||||
@@ -6,15 +6,15 @@ module.exports = class Affect {
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error("You must provide an image.");
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let base = await jimp.read(`${__dirname}/../../assets/affect.png`);
|
||||
let img = await jimp.read(image);
|
||||
img.resize(200, 157);
|
||||
base.composite(img, 180, 383);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
base.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Batslap {
|
||||
/**
|
||||
@@ -7,8 +7,8 @@ module.exports = class Batslap {
|
||||
* @param {image} image2
|
||||
*/
|
||||
async getImage(image1, image2) {
|
||||
if (!image1) throw new Error("You must provide an image as a first argument.");
|
||||
if (!image2) throw new Error("You must provide an image as a second argument.");
|
||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
||||
let base = await jimp.read(`${__dirname}/../../assets/batslap.png`);
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
@@ -20,9 +20,9 @@ module.exports = class Batslap {
|
||||
base.composite(image2, 580, 260);
|
||||
base.composite(image1, 350, 70);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
base.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Beautiful {
|
||||
/**
|
||||
@@ -6,7 +6,7 @@ module.exports = class Beautiful {
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error("You must provide an image.");
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let base = await jimp.read(`${__dirname}/../../assets/beautiful.png`);
|
||||
base.resize(376, 400);
|
||||
let img = await jimp.read(image);
|
||||
@@ -14,9 +14,9 @@ module.exports = class Beautiful {
|
||||
base.composite(img, 258, 28);
|
||||
base.composite(img, 258, 229);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
base.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Bed {
|
||||
/**
|
||||
@@ -27,4 +27,4 @@ module.exports = class Bed {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,22 +1,20 @@
|
||||
const { createCanvas, loadImage } = require("canvas");
|
||||
const { createCanvas, loadImage } = require(`canvas`);
|
||||
|
||||
module.exports = class Bobross {
|
||||
/**
|
||||
/**
|
||||
* Bobross
|
||||
* @param {image} image1
|
||||
*/
|
||||
async getImage(image1){
|
||||
if (!image1) throw new Error(`You must provide an image as argument.`);
|
||||
const base = await loadImage(`${__dirname}/../../assets/bobross.png`);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext("2d");
|
||||
image1 = await loadImage(image1);
|
||||
ctx.fillStyle = "white";
|
||||
ctx.fillRect(0, 0, base.width, base.height);
|
||||
ctx.drawImage(image1, 15, 20, 440, 440);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
return canvas.toBuffer()
|
||||
}
|
||||
}
|
||||
|
||||
// -N²O Pyro ;)
|
||||
async getImage(image1) {
|
||||
if (!image1) throw new Error(`You must provide an image as argument.`);
|
||||
const base = await loadImage(`${__dirname}/../../assets/bobross.png`);
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
image1 = await loadImage(image1);
|
||||
ctx.fillStyle = `white`;
|
||||
ctx.fillRect(0, 0, base.width, base.height);
|
||||
ctx.drawImage(image1, 15, 20, 440, 440);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
};
|
||||
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class ConfusedStonk {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class ConfusedStonk {
|
||||
ctx.drawImage(background, 0, 0, 1994, 1296);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Delete {
|
||||
/**
|
||||
@@ -17,4 +17,4 @@ module.exports = class Delete {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
18
src/module/montage/discordBlack.js
Normal file
18
src/module/montage/discordBlack.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class DiscordBlack {
|
||||
/**
|
||||
* Bobross
|
||||
* @param {image} image1
|
||||
*/
|
||||
async getImage(image1) {
|
||||
if (!image1) throw new Error(`You must provide an image as argument.`);
|
||||
const canvas = Canvas.createCanvas(610, 610);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
image1 = await Canvas.loadImage(image1);
|
||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/discordblack.png`);
|
||||
ctx.drawImage(image1, 0, 0, 610, 610);
|
||||
ctx.drawImage(background, 0, 0, 610, 610);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
};
|
18
src/module/montage/discordBlue.js
Normal file
18
src/module/montage/discordBlue.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class DiscordBlue {
|
||||
/**
|
||||
* Bobross
|
||||
* @param {image} image1
|
||||
*/
|
||||
async getImage(image1) {
|
||||
if (!image1) throw new Error(`You must provide an image as argument.`);
|
||||
const canvas = Canvas.createCanvas(610, 610);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
image1 = await Canvas.loadImage(image1);
|
||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/discordblue.png`);
|
||||
ctx.drawImage(image1, 0, 0, 610, 610);
|
||||
ctx.drawImage(background, 0, 0, 610, 610);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class DoubleStonk {
|
||||
/**
|
||||
@@ -7,8 +7,8 @@ module.exports = class DoubleStonk {
|
||||
* @param {image} image2
|
||||
*/
|
||||
async getImage(image1, image2) {
|
||||
if (!image1) throw new Error("You must provide an image as a first argument.");
|
||||
if (!image2) throw new Error("You must provide an image as a second argument.");
|
||||
if (!image1) throw new Error(`You must provide an image as a first argument.`);
|
||||
if (!image2) throw new Error(`You must provide an image as a second argument.`);
|
||||
let base = await jimp.read(`${__dirname}/../../assets/doubleStonk.png`);
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
@@ -20,9 +20,9 @@ module.exports = class DoubleStonk {
|
||||
base.composite(image2, 60, 20);
|
||||
base.composite(image1, 0, 30);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
base.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Facepalm {
|
||||
/**
|
||||
@@ -6,10 +6,10 @@ module.exports = class Facepalm {
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error("You must provide an image.");
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let canvas = Canvas.createCanvas(632, 357);
|
||||
let ctx = canvas.getContext("2d");
|
||||
ctx.fillStyle = "black";
|
||||
let ctx = canvas.getContext(`2d`);
|
||||
ctx.fillStyle = `black`;
|
||||
ctx.fillRect(0, 0, 632, 357);
|
||||
let avatar = await Canvas.loadImage(image);
|
||||
ctx.drawImage(avatar, 199, 112, 235, 235);
|
||||
@@ -17,4 +17,4 @@ module.exports = class Facepalm {
|
||||
ctx.drawImage(layer, 0, 0, 632, 357);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Hitler {
|
||||
/**
|
||||
@@ -17,4 +17,4 @@ module.exports = class Hitler {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Jail {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Jail {
|
||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Kiss {
|
||||
/**
|
||||
@@ -25,4 +25,4 @@ module.exports = class Kiss {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,66 +1,34 @@
|
||||
const { createCanvas, loadImage, registerFont } = require('canvas');
|
||||
registerFont(`${__dirname}/../../assets/fonts/Noto-Regular.ttf`, { family: 'Noto' });
|
||||
registerFont(`${__dirname}/../../assets/fonts/Noto-Emoji.ttf`, { family: 'Noto' });
|
||||
const path = require("path");
|
||||
|
||||
function wrapText(ctx, text, maxWidth) {
|
||||
return new Promise(resolve => {
|
||||
if (ctx.measureText(text).width < maxWidth) return resolve([text]);
|
||||
if (ctx.measureText('W').width > maxWidth) return resolve(null);
|
||||
const words = text.split(' ');
|
||||
const lines = [];
|
||||
let line = '';
|
||||
while (words.length > 0) {
|
||||
let split = false;
|
||||
while (ctx.measureText(words[0]).width >= maxWidth) {
|
||||
const temp = words[0];
|
||||
words[0] = temp.slice(0, -1);
|
||||
if (split) {
|
||||
words[1] = `${temp.slice(-1)}${words[1]}`;
|
||||
}
|
||||
else {
|
||||
split = true;
|
||||
words.splice(1, 0, temp.slice(-1));
|
||||
}
|
||||
}
|
||||
if (ctx.measureText(`${line}${words[0]}`).width < maxWidth) {
|
||||
line += `${words.shift()} `;
|
||||
}
|
||||
else {
|
||||
lines.push(line.trim());
|
||||
line = '';
|
||||
}
|
||||
if (words.length === 0) lines.push(line.trim());
|
||||
}
|
||||
return resolve(lines);
|
||||
});
|
||||
}
|
||||
const { createCanvas, loadImage, registerFont } = require(`canvas`);
|
||||
registerFont(`${__dirname}/../../assets/fonts/Noto-Regular.ttf`, { family: `Noto` });
|
||||
registerFont(`${__dirname}/../../assets/fonts/Noto-Emoji.ttf`, { family: `Noto` });
|
||||
const path = require(`path`);
|
||||
const { wrapText } = require(`../functions`);
|
||||
|
||||
module.exports = class LisaPresentation {
|
||||
|
||||
async getImage(text) {
|
||||
if (!text || text.length > 300) throw new Error(`You must provide a text of 300 characters or less.`)
|
||||
async getImage(text) {
|
||||
if (!text || text.length > 300) throw new Error(`You must provide a text of 300 characters or less.`);
|
||||
|
||||
const base = await loadImage(path.join(`${__dirname}/../../assets/lisa-presentation.png`));
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.textAlign = 'center';
|
||||
ctx.textBaseline = 'top';
|
||||
ctx.font = '40px Noto';
|
||||
let fontSize = 40;
|
||||
while (ctx.measureText(text).width > 1320) {
|
||||
const base = await loadImage(path.join(`${__dirname}/../../assets/lisa-presentation.png`));
|
||||
const canvas = createCanvas(base.width, base.height);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
ctx.drawImage(base, 0, 0);
|
||||
ctx.textAlign = `center`;
|
||||
ctx.textBaseline = `top`;
|
||||
ctx.font = `40px Noto`;
|
||||
let fontSize = 40;
|
||||
while (ctx.measureText(text).width > 1320) {
|
||||
fontSize -= 1;
|
||||
ctx.font = `${fontSize}px Noto`;
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 330);
|
||||
const topMost = 185 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
}
|
||||
const lines = await wrapText(ctx, text, 330);
|
||||
const topMost = 185 - (((fontSize * lines.length) / 2) + ((20 * (lines.length - 1)) / 2));
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const height = topMost + ((fontSize + 20) * i);
|
||||
ctx.fillText(lines[i], base.width / 2, height);
|
||||
}
|
||||
}
|
||||
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Mms {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Mms {
|
||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class NotStonk {
|
||||
/**
|
||||
@@ -13,6 +13,6 @@ module.exports = class NotStonk {
|
||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/notStonk.png`);
|
||||
ctx.drawImage(image1, 140, 5, 190, 190);
|
||||
ctx.drawImage(background, 0, 0, 960, 576);
|
||||
return canvas.toBuffer();
|
||||
return canvas.tofBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,7 +1,7 @@
|
||||
const Canvas = require("canvas");
|
||||
const {
|
||||
applyText
|
||||
} = require("../functions")
|
||||
const Canvas = require(`canvas`);
|
||||
const {
|
||||
applyText
|
||||
} = require(`../functions`);
|
||||
|
||||
module.exports = class Podium {
|
||||
/**
|
||||
@@ -34,26 +34,26 @@ module.exports = class Podium {
|
||||
if (name1.length > 5) maxWidth = 150;
|
||||
if (name1.length > 10) maxWidth = 250;
|
||||
if (name1.length > 20) maxWidth = 350;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.font = applyText(canvas, name1, 80, maxWidth, "Comic Sans MS");
|
||||
ctx.textAlign = `center`;
|
||||
ctx.font = applyText(canvas, name1, 80, maxWidth, `Comic Sans MS`);
|
||||
ctx.fillStyle = `#513d34`;
|
||||
ctx.fillText(name1, 580, 575);
|
||||
maxWidth = 80;
|
||||
if (name2.length > 5) maxWidth = 150;
|
||||
if (name2.length > 10) maxWidth = 180;
|
||||
if (name2.length > 20) maxWidth = 240;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.font = applyText(canvas, name2, 50, maxWidth, "Comic Sans MS");
|
||||
ctx.textAlign = `center`;
|
||||
ctx.font = applyText(canvas, name2, 50, maxWidth, `Comic Sans MS`);
|
||||
ctx.fillStyle = `#513d34`;
|
||||
ctx.fillText(name2, 210, 540);
|
||||
maxWidth = 80;
|
||||
if (name3.length > 5) maxWidth = 150;
|
||||
if (name3.length > 10) maxWidth = 180;
|
||||
if (name3.length > 20) maxWidth = 240;
|
||||
ctx.textAlign = 'center';
|
||||
ctx.font = applyText(canvas, name3, 50, maxWidth, "Comic Sans MS");
|
||||
ctx.textAlign = `center`;
|
||||
ctx.font = applyText(canvas, name3, 50, maxWidth, `Comic Sans MS`);
|
||||
ctx.fillStyle = `#513d34`;
|
||||
ctx.fillText(name3, 970, 540);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Poutine {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Poutine {
|
||||
ctx.drawImage(background, 0, 0, 600, 539);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Rip {
|
||||
/**
|
||||
@@ -16,4 +16,4 @@ module.exports = class Rip {
|
||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Spank {
|
||||
/**
|
||||
@@ -27,4 +27,4 @@ module.exports = class Spank {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Stonk {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Stonk {
|
||||
ctx.drawImage(background, 0, 0, 900, 539);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Tatoo {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Tatoo {
|
||||
ctx.drawImage(background, 0, 0, 750, 1089);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Thomas {
|
||||
/**
|
||||
@@ -15,4 +15,4 @@ module.exports = class Thomas {
|
||||
ctx.drawImage(background, 0, 0, 841, 1058);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Trash {
|
||||
/**
|
||||
@@ -18,4 +18,4 @@ module.exports = class Trash {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
const {
|
||||
applyText
|
||||
} = require(`../functions`);
|
||||
@@ -8,21 +8,21 @@ module.exports = class Wanted {
|
||||
* Wanted
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image, currency = "$") {
|
||||
async getImage(image, currency = `$`) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
if (typeof currency != `string`) throw new Error(`You must provide a string for the currency.`)
|
||||
if (currency.length > 1) throw new Error(`You must provide only one character for the currency.`)
|
||||
var price = Math.floor(Math.random() * 188708) + 329889
|
||||
if (typeof currency != `string`) throw new Error(`You must provide a string for the currency.`);
|
||||
if (currency.length > 1) throw new Error(`You must provide only one character for the currency.`);
|
||||
var price = Math.floor(Math.random() * 188708) + 329889;
|
||||
const canvas = Canvas.createCanvas(257, 383);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
const background = await Canvas.loadImage(`${__dirname}/../../assets/wanted.png`);
|
||||
ctx.drawImage(avatar, 25, 60, 210, 210);
|
||||
ctx.drawImage(background, 0, 0, 257, 383);
|
||||
ctx.textAlign = 'center';
|
||||
ctx.font = applyText(canvas, price.toLocaleString() + currency, 80, 200, "Times New Roman");
|
||||
ctx.fillStyle = `#513d34`
|
||||
ctx.fillText(price.toLocaleString() + currency, 128, 315)
|
||||
ctx.textAlign = `center`;
|
||||
ctx.font = applyText(canvas, price.toLocaleString() + currency, 80, 200, `Times New Roman`);
|
||||
ctx.fillStyle = `#513d34`;
|
||||
ctx.fillText(price.toLocaleString() + currency, 128, 315);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const jimp = require("jimp");
|
||||
const jimp = require(`jimp`);
|
||||
|
||||
module.exports = class Circle {
|
||||
/**
|
||||
@@ -16,4 +16,4 @@ module.exports = class Circle {
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
const Canvas = require("canvas");
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
module.exports = class Color {
|
||||
/**
|
||||
@@ -12,4 +12,4 @@ module.exports = class Color {
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user