📌 1.0.0
This commit is contained in:
47
.github/workflows/npm-publish.yaml
vendored
Normal file
47
.github/workflows/npm-publish.yaml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Node.js package
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
||||
publish-npm:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
registry-url: https://registry.npmjs.org/
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
||||
|
||||
publish-gpr:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
registry-url: https://npm.pkg.github.com/
|
||||
scope: '@your-github-username'
|
||||
- run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,4 @@
|
||||
node_modules/
|
||||
package-lock.json
|
||||
test/
|
||||
all.js
|
||||
pas fait/
|
220
README.md
220
README.md
@@ -17,30 +17,6 @@ A correct and understandable issue contains :
|
||||
|
||||
You can also join me on my <a href="https://discord.gg/qvzwqaM">discord server.</a>
|
||||
|
||||
# Changelog
|
||||
|
||||
## v0.1.9
|
||||
- Added options for the wanted.
|
||||
- The base image has been updated
|
||||
- There is now a random price diplayed
|
||||
- You can now configure a currency
|
||||
- Added .thomas()
|
||||
|
||||
## v0.1.11
|
||||
- Added .tatoo()
|
||||
- Updated JSDoc
|
||||
|
||||
## v1.1.12
|
||||
- Saved all examples to imgur
|
||||
|
||||
## v1.1.13
|
||||
- Added example for .tatoo()
|
||||
- Fixed the litle hole at the top of the users pic on .thomas()
|
||||
|
||||
## v1.1.14
|
||||
- Updated .thomas() example
|
||||
|
||||
|
||||
# Download
|
||||
|
||||
You can download it from <a href="https://www.npmjs.com/package/discord-image-generation">npmjs</a>.
|
||||
@@ -78,7 +54,7 @@ bot.on("message", async (message) => {
|
||||
// Get the avatarUrl of the user
|
||||
let avatar = message.author.displayAvatarURL({ dynamic: false, format: 'png' });
|
||||
// Make the image
|
||||
let img = await DIG.delete(avatar)
|
||||
let img = await DIG.delete().getImage(avatar)
|
||||
// Add the image as an attachement
|
||||
let attach = new Discord.MessageAttachment(img, "delete.png");;
|
||||
message.channel.send(attach)
|
||||
@@ -91,102 +67,154 @@ bot.login("super_secret_token")
|
||||
|
||||
# Available images
|
||||
|
||||
- .blur(`<Avatar>`, `<Level(Number)>`);
|
||||
|
||||
## Filters
|
||||
|
||||
- .Blur().getImage(`<Avatar>`, `<Level(Number)>`);
|
||||
|
||||

|
||||
|
||||
- .facepalm(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .gay(`<Avatar>`);
|
||||
- .Gay().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .rip(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .trash(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .circle(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .greyscale(`<Avatar>`);
|
||||
- .Greyscale().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .kiss(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .sepia(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .mms(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .spank(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .color(`<Color>`);
|
||||
|
||||
> An hex color is needed, like "#FF0000"
|
||||
|
||||

|
||||
|
||||
- .triggered(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .hitler(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .batslap(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .bed(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .invert(`<Avatar>`);
|
||||
- .Invert().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .wanted(`<Avatar>`, `<Currency>`);
|
||||
- .Sepia().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
|
||||
## Gifs
|
||||
|
||||
- .Blink().getImage()
|
||||
|
||||

|
||||
|
||||
- .Triggered().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
|
||||
## Montage
|
||||
|
||||
- .Affect().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Batslap().getImage(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .Beautiful().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Bed().getImage(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .Delete().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Facepalm().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Hitler().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Jail().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Kiss().getImage(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .Mms().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Rip().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Spank().getImage(`<Avatar>`, `<Avatar2>`);
|
||||
|
||||

|
||||
|
||||
- .Tatoo().getImage(`<Avatar>`)
|
||||
|
||||

|
||||
|
||||
- .Thomas().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Trash().getImage(`<Avatar>`);
|
||||
|
||||

|
||||
|
||||
- .Wanted().getImage(`<Avatar>`, `<Currency>`);
|
||||
|
||||
> Currency ($, €, ...)
|
||||
|
||||

|
||||
|
||||
- .beautiful(`<Avatar>`);
|
||||
|
||||

|
||||
## Utils
|
||||
|
||||
- .jail(`<Avatar>`);
|
||||
- .Circle().getImage(`<Avatar>`);
|
||||
|
||||

|
||||

|
||||
|
||||
- .affect(`<Avatar>`);
|
||||
- .Color().getImage(`<Color>`);
|
||||
|
||||

|
||||
> An hex color is needed, like "#FF0000"
|
||||
|
||||
- .delete(`<Avatar>`);
|
||||

|
||||
|
||||

|
||||
# Changelog
|
||||
|
||||
- .thomas(`<Avatar>`);
|
||||
## v1.0.0
|
||||
- Changed the full structure
|
||||
- Sorted all files in folders
|
||||
- Sorted all files in the README
|
||||
- Fixed .wanted() text bug
|
||||
- Added .blink()
|
||||
- Added a timeout options for .triggered()
|
||||
- Fixed the triggered example not animated
|
||||
- Added some keywords
|
||||
- Bumped jimp from ^0.12.1 to ^0.13.0
|
||||
- Added workflow to auto publish to npm and github packages on push
|
||||
|
||||

|
||||
|
||||
- .tatoo(`<Avatar>`)
|
||||
## v0.1.14
|
||||
- Updated .thomas() example
|
||||
|
||||

|
||||
## v0.1.13
|
||||
- Added example for .tatoo()
|
||||
- Fixed the litle hole at the top of the users pic on .thomas()
|
||||
|
||||
## v0.1.12
|
||||
- Saved all examples to imgur
|
||||
|
||||
## v0.1.11
|
||||
- Added .tatoo()
|
||||
- Updated JSDoc
|
||||
|
||||
## v0.1.9
|
||||
- Added options for the wanted.
|
||||
- The base image has been updated
|
||||
- There is now a random price diplayed
|
||||
- You can now configure a currency
|
||||
- Added .thomas()
|
13
package.json
13
package.json
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"name": "discord-image-generation",
|
||||
"version": "0.1.14",
|
||||
"version": "1.0.0",
|
||||
"description": "discord-image-generation is a powerfull module that allow you to generate awesome images.",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "node test/index.js"
|
||||
"test": "node src/index.js"
|
||||
},
|
||||
"author": "Mr¤KayJayDee <killian.dalcin@gmail.com> (https://github.com/Mr-KayJayDee)",
|
||||
"license": "MIT",
|
||||
@@ -21,11 +21,16 @@
|
||||
"images",
|
||||
"generation",
|
||||
"gif",
|
||||
"manipulation"
|
||||
"manipulation",
|
||||
"canvas",
|
||||
"jimp",
|
||||
"photo",
|
||||
"picture",
|
||||
"drawing"
|
||||
],
|
||||
"dependencies": {
|
||||
"canvas": "^2.6.1",
|
||||
"gifencoder": "^2.0.1",
|
||||
"jimp": "^0.12.1"
|
||||
"jimp": "^0.13.0"
|
||||
}
|
||||
}
|
||||
|
58
src/index.js
58
src/index.js
@@ -1,2 +1,56 @@
|
||||
const DiscordImageGeneration = require("./module/DIG")
|
||||
module.exports = Object.assign(DiscordImageGeneration)
|
||||
Blur = require('./module/filters/blur')
|
||||
Gay = require('./module/filters/gay')
|
||||
Greyscale = require('./module/filters/greyscale')
|
||||
Invert = require('./module/filters/invert')
|
||||
Sepia = require('./module/filters/sepia')
|
||||
|
||||
Triggered = require('./module/gif/triggered')
|
||||
Blink = require('./module/gif/blink')
|
||||
|
||||
Affect = require('./module/montage/affect')
|
||||
Batslap = require('./module/montage/batslap')
|
||||
Beautiful = require('./module/montage/beautiful')
|
||||
Bed = require('./module/montage/bed')
|
||||
Delete = require('./module/montage/delete')
|
||||
Facepalm = require('./module/montage/facepalm')
|
||||
Hitler = require('./module/montage/hitler')
|
||||
Jail = require('./module/montage/jail')
|
||||
Kiss = require('./module/montage/kiss')
|
||||
Mms = require('./module/montage/mms')
|
||||
Rip = require('./module/montage/rip')
|
||||
Spank = require('./module/montage/spank')
|
||||
Tatoo = require('./module/montage/tatoo')
|
||||
Thomas = require('./module/montage/thomas')
|
||||
Trash = require('./module/montage/trash')
|
||||
Wanted = require('./module/montage/wanted')
|
||||
|
||||
Circle = require('./module/utils/circle')
|
||||
Color = require('./module/utils/color')
|
||||
|
||||
module.exports = {
|
||||
Blur,
|
||||
Gay,
|
||||
Greyscale,
|
||||
Invert,
|
||||
Sepia,
|
||||
Triggered,
|
||||
Blink,
|
||||
Affect,
|
||||
Batslap,
|
||||
Beautiful,
|
||||
Bed,
|
||||
Delete,
|
||||
Facepalm,
|
||||
Hitler,
|
||||
Jail,
|
||||
Kiss,
|
||||
Mms,
|
||||
Rip,
|
||||
Spank,
|
||||
Tatoo,
|
||||
Thomas,
|
||||
Trash,
|
||||
Wanted,
|
||||
Circle,
|
||||
Color,
|
||||
}
|
@@ -1,456 +0,0 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
const jimp = require("jimp");
|
||||
|
||||
const GIFEncoder = require("gifencoder");
|
||||
|
||||
const configure = require('@jimp/custom')
|
||||
|
||||
const circle = require('@jimp/plugin-circle')
|
||||
|
||||
configure({ plugins: [circle] }, jimp);
|
||||
|
||||
class DIG {
|
||||
|
||||
/**
|
||||
* Beautiful
|
||||
* @param {image} image
|
||||
*/
|
||||
static async beautiful(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let base = await jimp.read(__dirname +"/assets/beautiful.png");
|
||||
base.resize(376, 400);
|
||||
let img = await jimp.read(image);
|
||||
img.resize(84, 95);
|
||||
base.composite(img, 258, 28);
|
||||
base.composite(img, 258, 229);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Facepalm
|
||||
* @param {image} image
|
||||
*/
|
||||
static async facepalm(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let canvas = Canvas.createCanvas(632, 357);
|
||||
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);
|
||||
let layer = await Canvas.loadImage(__dirname +"/assets/facepalm.png");
|
||||
ctx.drawImage(layer, 0, 0, 632, 357);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gay
|
||||
* @param {image} image
|
||||
*/
|
||||
static async gay(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let bg = await Canvas.loadImage(__dirname +"/assets/gay.png");
|
||||
let img = await Canvas.loadImage(image);
|
||||
const canvas = Canvas.createCanvas(480, 480);
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(img, 0, 0, 480, 480);
|
||||
ctx.drawImage(bg, 0, 0, 480, 480);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kiss
|
||||
* @param {image1} image1
|
||||
* @param {image2} image2
|
||||
*/
|
||||
static async kiss(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.");
|
||||
let base = await jimp.read(__dirname+"/assets/kiss.png");
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
base.resize(768, 574);
|
||||
image1.resize(200, 200);
|
||||
image2.resize(200, 200);
|
||||
base.composite(image1, 150, 25);
|
||||
base.composite(image2, 350, 25);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rip
|
||||
* @param {image} image
|
||||
*/
|
||||
static async rip(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
const canvas = Canvas.createCanvas(244, 253);
|
||||
const ctx = canvas.getContext("2d");
|
||||
const background = await Canvas.loadImage(__dirname +"/assets/rip.png");
|
||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
ctx.drawImage(avatar, 63, 110, 90, 90);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Spank
|
||||
* @param {image1} image1
|
||||
* @param {image2} image2
|
||||
*/
|
||||
static async spank(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.");
|
||||
let bg = await jimp.read(__dirname +"/assets/spank.png");
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
bg.resize(500, 500);
|
||||
image1.resize(140, 140);
|
||||
image2.resize(120, 120);
|
||||
bg.composite(image2, 350, 220);
|
||||
bg.composite(image1, 225, 5);
|
||||
let raw;
|
||||
bg.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batslap
|
||||
* @param {image1} image1
|
||||
* @param {image2} image2
|
||||
*/
|
||||
static async batslap(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.");
|
||||
let base = await jimp.read(__dirname+"/assets/batslap.png");
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
base.resize(1000, 500);
|
||||
image1.resize(220, 220);
|
||||
image2.resize(200, 200);
|
||||
base.composite(image2, 580, 260);
|
||||
base.composite(image1, 350, 70);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Affect
|
||||
* @param {image} image
|
||||
*/
|
||||
static async affect(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
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) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blur
|
||||
* @param {image} image
|
||||
* @param {number} level
|
||||
*/
|
||||
static async blur(image, level = 5) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.blur(isNaN(level) ? 5 : parseInt(level));
|
||||
let raw;
|
||||
image.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geryscale
|
||||
* @param {image} image
|
||||
*/
|
||||
static async greyscale(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.greyscale();
|
||||
let raw;
|
||||
image.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sepia
|
||||
* @param {image} image
|
||||
*/
|
||||
static async sepia(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.sepia();
|
||||
let raw;
|
||||
image.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invert
|
||||
* @param {image} image
|
||||
*/
|
||||
static async invert(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.invert();
|
||||
let raw;
|
||||
image.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
* @param {image} image
|
||||
*/
|
||||
static async delete(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let bg = await jimp.read(__dirname + "/assets/delete.png");
|
||||
image = await jimp.read(image);
|
||||
image.resize(195, 195);
|
||||
bg.composite(image, 120, 135);
|
||||
let raw;
|
||||
bg.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trash
|
||||
* @param {image} image
|
||||
*/
|
||||
static async trash(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let bg = await jimp.read(__dirname +"/assets/trash.png");
|
||||
image = await jimp.read(image);
|
||||
image.resize(309, 309);
|
||||
image.blur(5);
|
||||
bg.composite(image, 309, 0);
|
||||
let raw;
|
||||
bg.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Color
|
||||
* @param {color} color
|
||||
*/
|
||||
static async color(color = "#FFFFFF") {
|
||||
const canvas = Canvas.createCanvas(2048, 2048);
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Hitler
|
||||
* @param {image} image
|
||||
*/
|
||||
static async hitler(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let bg = await jimp.read(__dirname + "/assets/hitler.png");
|
||||
let img = await jimp.read(image);
|
||||
img.resize(140, 140);
|
||||
bg.composite(img, 46, 43);
|
||||
let raw;
|
||||
bg.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bed
|
||||
* @param {image1} image1
|
||||
* @param {image2} image2
|
||||
*/
|
||||
static async bed(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.");
|
||||
let bg = await jimp.read(__dirname +"/assets/bed.png");
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
image1.resize(100, 100);
|
||||
image2.resize(70, 70);
|
||||
let image3 = image1.clone().resize(70, 70);
|
||||
bg.composite(image1, 25, 100);
|
||||
bg.composite(image1, 25, 300);
|
||||
bg.composite(image3, 53, 450);
|
||||
bg.composite(image2, 53, 575);
|
||||
let raw;
|
||||
bg.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wanted
|
||||
* @param {image} image
|
||||
*/
|
||||
static async wanted(image, currency) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
if (!currency) currency = "$"
|
||||
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() * 1887088) + 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.font = 'Bold 35px Times New Roman'
|
||||
ctx.fillStyle = "#513d34"
|
||||
ctx.fillText(price.toLocaleString() + currency, 55, 310)
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered
|
||||
* @param {image} image
|
||||
*/
|
||||
static async triggered(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
const base = await Canvas.loadImage(__dirname +"/assets/triggered.png");
|
||||
const img = await Canvas.loadImage(image);
|
||||
const GIF = new GIFEncoder(256, 310)
|
||||
GIF.start();
|
||||
GIF.setRepeat(0);
|
||||
GIF.setDelay(15);
|
||||
const canvas = Canvas.createCanvas(256, 310);
|
||||
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.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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Circle
|
||||
* @param {image} image
|
||||
*/
|
||||
static async circle(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480);
|
||||
image.circle();
|
||||
let raw;
|
||||
image.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jail
|
||||
* @param {image} image
|
||||
*/
|
||||
static async jail(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let bg = await Canvas.loadImage(__dirname +"/assets/jail.png");
|
||||
let img = await Canvas.loadImage(image);
|
||||
const canvas = Canvas.createCanvas(400, 400);
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(img, 0, 0, 400, 400);
|
||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* MMS
|
||||
* @param {image} image
|
||||
*/
|
||||
static async mms(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
let bg = await Canvas.loadImage(__dirname +"/assets/mms.png");
|
||||
let img = await Canvas.loadImage(image);
|
||||
const canvas = Canvas.createCanvas(400, 400);
|
||||
const ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(img, 70, 20, 250, 250);
|
||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Thomas
|
||||
* @param {image} image
|
||||
*/
|
||||
static async thomas(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
const canvas = Canvas.createCanvas(841, 1058);
|
||||
const ctx = canvas.getContext("2d");
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
const background = await Canvas.loadImage(__dirname +"/assets/thomas.png");
|
||||
ctx.drawImage(avatar, 220, 190, 400, 400);
|
||||
ctx.drawImage(background, 0, 0, 841, 1058);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tatoo
|
||||
* @param {image} image
|
||||
*/
|
||||
static async tatoo(image) {
|
||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||
const canvas = Canvas.createCanvas(750, 1089);
|
||||
const ctx = canvas.getContext("2d");
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
const background = await Canvas.loadImage(__dirname +"/assets/tatoo.png");
|
||||
ctx.drawImage(avatar, 145, 575, 400, 400);
|
||||
ctx.drawImage(background, 0, 0, 750, 1089);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DIG;
|
20
src/module/filters/blur.js
Normal file
20
src/module/filters/blur.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Blur {
|
||||
/**
|
||||
* Blur
|
||||
* @param {image} image
|
||||
* @param {level} level
|
||||
*/
|
||||
async getImage(image, level) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.blur(isNaN(level) ? 5 : parseInt(level));
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
18
src/module/filters/gay.js
Normal file
18
src/module/filters/gay.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Gay {
|
||||
/**
|
||||
* Gay
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let bg = await Canvas.loadImage(`../src/module/assets/gay.png`);
|
||||
let img = await Canvas.loadImage(image);
|
||||
const canvas = Canvas.createCanvas(480, 480);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
ctx.drawImage(img, 0, 0, 480, 480);
|
||||
ctx.drawImage(bg, 0, 0, 480, 480);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
19
src/module/filters/greyscale.js
Normal file
19
src/module/filters/greyscale.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Geryscale {
|
||||
/**
|
||||
* Greyscale
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.greyscale();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
19
src/module/filters/invert.js
Normal file
19
src/module/filters/invert.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Invert {
|
||||
/**
|
||||
* Invert
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.invert();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
19
src/module/filters/sepia.js
Normal file
19
src/module/filters/sepia.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Sepia {
|
||||
/**
|
||||
* Sepia
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480)
|
||||
image.sepia();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
18
src/module/functions.js
Normal file
18
src/module/functions.js
Normal file
@@ -0,0 +1,18 @@
|
||||
module.exports = {
|
||||
/**
|
||||
* Crate a responsive on the text
|
||||
* Code from https://discordjs.guide/popular-topics/canvas.html#adding-in-text
|
||||
* @param {object} canvas the canvas object
|
||||
* @param {string} text the text
|
||||
* @param {number} defaultFontSize the default font size
|
||||
* @param {number} width the default width
|
||||
* @param {string} font the font
|
||||
*/
|
||||
applyText(canvas, text, defaultFontSize, width, font) {
|
||||
const ctx = canvas.getContext("2d");
|
||||
do {
|
||||
ctx.font = `${(defaultFontSize -= 1)-3}px ${font}`;
|
||||
} while (ctx.measureText(text).width > width);
|
||||
return ctx.font;
|
||||
}
|
||||
}
|
38
src/module/gif/blink.js
Normal file
38
src/module/gif/blink.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
const GIFEncoder = require(`gifencoder`);
|
||||
|
||||
module.exports = class Blink {
|
||||
/**
|
||||
* 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) {
|
||||
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.`)
|
||||
const img = await Canvas.loadImage(image1);
|
||||
const base = await Canvas.loadImage(image2);
|
||||
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');
|
||||
ctx.clearRect(0, 0, 480, 480);
|
||||
ctx.drawImage(img, 0, 0, 480, 480);
|
||||
GIF.addFrame(ctx);
|
||||
const ctx2 = canvas.getContext('2d');
|
||||
ctx2.clearRect(0, 0, 480, 480);
|
||||
ctx2.drawImage(base, 0, 0, 480, 480);
|
||||
GIF.addFrame(ctx2)
|
||||
GIF.finish();
|
||||
console.log(GIF.out.getData())
|
||||
return GIF.out.getData();
|
||||
}
|
||||
}
|
35
src/module/gif/triggered.js
Normal file
35
src/module/gif/triggered.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const Canvas = require(`canvas`);
|
||||
|
||||
const GIFEncoder = require(`gifencoder`);
|
||||
|
||||
module.exports = class Triggered {
|
||||
/**
|
||||
* Triggered
|
||||
* @param {image} image
|
||||
* @param {number} timeout
|
||||
*/
|
||||
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.`)
|
||||
const base = await Canvas.loadImage(`../src/module/assets/triggered.png`);
|
||||
const img = await Canvas.loadImage(image);
|
||||
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 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.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();
|
||||
}
|
||||
}
|
20
src/module/montage/affect.js
Normal file
20
src/module/montage/affect.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Affect {
|
||||
/**
|
||||
* Affect
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error("You must provide an image.");
|
||||
let base = await jimp.read(`../src/module/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) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
28
src/module/montage/batslap.js
Normal file
28
src/module/montage/batslap.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Batslap {
|
||||
/**
|
||||
* Batslap
|
||||
* @param {image} image1
|
||||
* @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.");
|
||||
let base = await jimp.read(`../src/module/assets/batslap.png`);
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
base.resize(1000, 500);
|
||||
image1.resize(220, 220);
|
||||
image2.resize(200, 200);
|
||||
base.composite(image2, 580, 260);
|
||||
base.composite(image1, 350, 70);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
22
src/module/montage/beautiful.js
Normal file
22
src/module/montage/beautiful.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Beautiful {
|
||||
/**
|
||||
* Beautiful
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error("You must provide an image.");
|
||||
let base = await jimp.read(`../src/module/assets/beautiful.png`);
|
||||
base.resize(376, 400);
|
||||
let img = await jimp.read(image);
|
||||
img.resize(84, 95);
|
||||
base.composite(img, 258, 28);
|
||||
base.composite(img, 258, 229);
|
||||
let raw;
|
||||
base.getBuffer("image/png", (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
30
src/module/montage/bed.js
Normal file
30
src/module/montage/bed.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Bed {
|
||||
/**
|
||||
* Bed
|
||||
* @param {image} image1
|
||||
* @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.`);
|
||||
let bg = await jimp.read(`../src/module/assets/bed.png`);
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
image1.resize(100, 100);
|
||||
image2.resize(70, 70);
|
||||
let image3 = image1.clone().resize(70, 70);
|
||||
bg.composite(image1, 25, 100);
|
||||
bg.composite(image1, 25, 300);
|
||||
bg.composite(image3, 53, 450);
|
||||
bg.composite(image2, 53, 575);
|
||||
let raw;
|
||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
20
src/module/montage/delete.js
Normal file
20
src/module/montage/delete.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Delete {
|
||||
/**
|
||||
* Delete
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let bg = await jimp.read(`../src/module/assets/delete.png`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(195, 195);
|
||||
bg.composite(image, 120, 135);
|
||||
let raw;
|
||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
20
src/module/montage/facepalm.js
Normal file
20
src/module/montage/facepalm.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Facepalm {
|
||||
/**
|
||||
* Facepalm
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(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";
|
||||
ctx.fillRect(0, 0, 632, 357);
|
||||
let avatar = await Canvas.loadImage(image);
|
||||
ctx.drawImage(avatar, 199, 112, 235, 235);
|
||||
let layer = await Canvas.loadImage(`../src/module/assets/facepalm.png`);
|
||||
ctx.drawImage(layer, 0, 0, 632, 357);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
20
src/module/montage/hitler.js
Normal file
20
src/module/montage/hitler.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Hitler {
|
||||
/**
|
||||
* Hitler
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let bg = await jimp.read(`../src/module/assets/hitler.png`);
|
||||
let img = await jimp.read(image);
|
||||
img.resize(140, 140);
|
||||
bg.composite(img, 46, 43);
|
||||
let raw;
|
||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
18
src/module/montage/jail.js
Normal file
18
src/module/montage/jail.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Jail {
|
||||
/**
|
||||
* Jail
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let bg = await Canvas.loadImage(`../src/module/assets/jail.png`);
|
||||
let img = await Canvas.loadImage(image);
|
||||
const canvas = Canvas.createCanvas(400, 400);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
ctx.drawImage(img, 0, 0, 400, 400);
|
||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
28
src/module/montage/kiss.js
Normal file
28
src/module/montage/kiss.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Kiss {
|
||||
/**
|
||||
* Kiss
|
||||
* @param {image} image1
|
||||
* @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.`);
|
||||
let base = await jimp.read(`../src/module/assets/kiss.png`);
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
base.resize(768, 574);
|
||||
image1.resize(200, 200);
|
||||
image2.resize(200, 200);
|
||||
base.composite(image1, 150, 25);
|
||||
base.composite(image2, 350, 25);
|
||||
let raw;
|
||||
base.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
18
src/module/montage/mms.js
Normal file
18
src/module/montage/mms.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Mms {
|
||||
/**
|
||||
* MMS
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let bg = await Canvas.loadImage(`../src/module/assets/mms.png`);
|
||||
let img = await Canvas.loadImage(image);
|
||||
const canvas = Canvas.createCanvas(400, 400);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
ctx.drawImage(img, 60, 10, 270, 270);
|
||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
20
src/module/montage/rip.js
Normal file
20
src/module/montage/rip.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const Canvas = require("canvas");
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Rip {
|
||||
/**
|
||||
* Rip
|
||||
* @param {image} image
|
||||
*/
|
||||
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
const canvas = Canvas.createCanvas(244, 253);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
const background = await Canvas.loadImage(`../src/module/assets/rip.png`);
|
||||
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
ctx.drawImage(avatar, 63, 110, 90, 90);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
28
src/module/montage/spank.js
Normal file
28
src/module/montage/spank.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Spank {
|
||||
/**
|
||||
*
|
||||
* @param {image} image1
|
||||
* @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.`);
|
||||
let bg = await jimp.read(`../src/module/assets/spank.png`);
|
||||
image1 = await jimp.read(image1);
|
||||
image2 = await jimp.read(image2);
|
||||
image1.circle();
|
||||
image2.circle();
|
||||
bg.resize(500, 500);
|
||||
image1.resize(140, 140);
|
||||
image2.resize(120, 120);
|
||||
bg.composite(image2, 350, 220);
|
||||
bg.composite(image1, 225, 5);
|
||||
let raw;
|
||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
18
src/module/montage/tatoo.js
Normal file
18
src/module/montage/tatoo.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Tatoo {
|
||||
/**
|
||||
* Tatoo
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
const canvas = Canvas.createCanvas(750, 1089);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
const background = await Canvas.loadImage(`../src/module/assets/tatoo.png`);
|
||||
ctx.drawImage(avatar, 145, 575, 400, 400);
|
||||
ctx.drawImage(background, 0, 0, 750, 1089);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
18
src/module/montage/thomas.js
Normal file
18
src/module/montage/thomas.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Thomas {
|
||||
/**
|
||||
* Thomas
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
const canvas = Canvas.createCanvas(841, 1058);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
const background = await Canvas.loadImage(`../src/module/assets/thomas.png`);
|
||||
ctx.drawImage(avatar, 220, 190, 400, 400);
|
||||
ctx.drawImage(background, 0, 0, 841, 1058);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
21
src/module/montage/trash.js
Normal file
21
src/module/montage/trash.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Trash {
|
||||
/**
|
||||
* Trash
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
let bg = await jimp.read(`../src/module/assets/trash.png`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(309, 309);
|
||||
image.blur(5);
|
||||
bg.composite(image, 309, 0);
|
||||
let raw;
|
||||
bg.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
27
src/module/montage/wanted.js
Normal file
27
src/module/montage/wanted.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const Canvas = require("canvas");
|
||||
const {
|
||||
applyText
|
||||
} = require(`../functions`);
|
||||
|
||||
module.exports = class Wanted {
|
||||
/**
|
||||
* Wanted
|
||||
* @param {image} image
|
||||
*/
|
||||
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
|
||||
const canvas = Canvas.createCanvas(257, 383);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
const avatar = await Canvas.loadImage(image);
|
||||
const background = await Canvas.loadImage(`../src/module/assets/wanted.png`);
|
||||
ctx.drawImage(avatar, 25, 60, 210, 210);
|
||||
ctx.drawImage(background, 0, 0, 257, 383);
|
||||
ctx.font = applyText(canvas, price.toLocaleString() + currency, 40, 200, "Times New Roman");
|
||||
ctx.fillStyle = `#513d34`
|
||||
ctx.fillText(price.toLocaleString() + currency, 54, 320)
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
19
src/module/utils/circle.js
Normal file
19
src/module/utils/circle.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const jimp = require("jimp");
|
||||
|
||||
module.exports = class Circle {
|
||||
/**
|
||||
* Circle
|
||||
* @param {image} image
|
||||
*/
|
||||
async getImage(image) {
|
||||
if (!image) throw new Error(`You must provide an image.`);
|
||||
image = await jimp.read(image);
|
||||
image.resize(480, 480);
|
||||
image.circle();
|
||||
let raw;
|
||||
image.getBuffer(`image/png`, (err, buffer) => {
|
||||
raw = buffer;
|
||||
});
|
||||
return raw;
|
||||
}
|
||||
}
|
15
src/module/utils/color.js
Normal file
15
src/module/utils/color.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const Canvas = require("canvas");
|
||||
|
||||
module.exports = class Color {
|
||||
/**
|
||||
* Color
|
||||
* @param {string} color
|
||||
*/
|
||||
async getImage(color = `#FFFFFF`) {
|
||||
const canvas = Canvas.createCanvas(2048, 2048);
|
||||
const ctx = canvas.getContext(`2d`);
|
||||
ctx.fillStyle = color;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
return canvas.toBuffer();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user