Added .thomas(), added option to .wanted()
This commit is contained in:
21
README.md
21
README.md
@@ -17,6 +17,17 @@ A correct and understandable issue contains :
|
|||||||
|
|
||||||
You can also join me on my <a href="https://discord.gg/qvzwqaM">discord server.</a>
|
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()
|
||||||
|
-
|
||||||
|
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
|
|
||||||
You can download it from <a href="https://www.npmjs.com/package/discord-image-generation">npmjs</a>.
|
You can download it from <a href="https://www.npmjs.com/package/discord-image-generation">npmjs</a>.
|
||||||
@@ -137,9 +148,11 @@ bot.login("super_secret_token")
|
|||||||
|
|
||||||

|

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

|
> Currency ($, €, ...)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
- .beautiful(`<Avatar>`);
|
- .beautiful(`<Avatar>`);
|
||||||
|
|
||||||
@@ -156,3 +169,7 @@ bot.login("super_secret_token")
|
|||||||
- .delete(`<Avatar>`);
|
- .delete(`<Avatar>`);
|
||||||
|
|
||||||

|

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

|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord-image-generation",
|
"name": "discord-image-generation",
|
||||||
"version": "0.1.7",
|
"version": "0.1.9",
|
||||||
"description": "discord-image-generation is a powerfull module that allow you to generate awesome images.",
|
"description": "discord-image-generation is a powerfull module that allow you to generate awesome images.",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@@ -330,17 +330,22 @@ class DIG {
|
|||||||
* Wanted
|
* Wanted
|
||||||
* @param {image} image
|
* @param {image} image
|
||||||
*/
|
*/
|
||||||
static async wanted(image) {
|
static async wanted(image, currency) {
|
||||||
if (!image) throw new Error("You must provide an image as a first argument.");
|
if (!image) throw new Error("You must provide an image as a first argument.");
|
||||||
let base = await jimp.read(__dirname + "/assets/wanted.png");
|
if (!currency) currency = "$"
|
||||||
let img = await jimp.read(image);
|
if (typeof currency != "string") throw new Error("You must provide a string for the currency.")
|
||||||
img.resize(447, 447);
|
if (currency.length > 1) throw new Error("You must provide only one character for the currency.")
|
||||||
base.composite(img, 145, 282);
|
var price = Math.floor(Math.random() * 1887088) + 329889
|
||||||
let raw;
|
const canvas = Canvas.createCanvas(257, 383);
|
||||||
base.getBuffer("image/png", (err, buffer) => {
|
const ctx = canvas.getContext("2d");
|
||||||
raw = buffer;
|
const avatar = await Canvas.loadImage(image);
|
||||||
});
|
const background = await Canvas.loadImage(__dirname +"/assets/wanted.png");
|
||||||
return raw;
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -416,6 +421,22 @@ class DIG {
|
|||||||
ctx.drawImage(bg, 0, 0, 400, 400);
|
ctx.drawImage(bg, 0, 0, 400, 400);
|
||||||
return canvas.toBuffer();
|
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.");
|
||||||
|
var price = Math.floor(Math.random() * 1887088) + 329889
|
||||||
|
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, 200, 400, 400);
|
||||||
|
ctx.drawImage(background, 0, 0, 841, 1058);
|
||||||
|
return canvas.toBuffer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = DIG;
|
module.exports = DIG;
|
||||||
|
BIN
src/module/assets/thomas.png
Normal file
BIN
src/module/assets/thomas.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 468 KiB |
Binary file not shown.
Before Width: | Height: | Size: 455 KiB After Width: | Height: | Size: 119 KiB |
Reference in New Issue
Block a user