Added .thomas(), added option to .wanted()

main
Killian' Dal-Cin 5 years ago
parent 78a57d0bec
commit c8b375923c

@ -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")
![Invert](https://cdn.discordapp.com/attachments/692101136802643989/714970523469217832/invert.png) ![Invert](https://cdn.discordapp.com/attachments/692101136802643989/714970523469217832/invert.png)
- .wanted(`<Avatar>`); - .wanted(`<Avatar>`, `<Currency>`);
![Wanted](https://cdn.discordapp.com/attachments/692101136802643989/714970791174996038/wanted.png) > Currency ($, €, ...)
![Wanted](https://cdn.discordapp.com/attachments/720225919523881041/720538669412253757/wanted.png)
- .beautiful(`<Avatar>`); - .beautiful(`<Avatar>`);
@ -156,3 +169,7 @@ bot.login("super_secret_token")
- .delete(`<Avatar>`); - .delete(`<Avatar>`);
![Delete](https://cdn.discordapp.com/attachments/692101136802643989/714971728849141901/delete.png) ![Delete](https://cdn.discordapp.com/attachments/692101136802643989/714971728849141901/delete.png)
- .thomas(`<Avatar>`);
![Thomas](https://cdn.discordapp.com/attachments/720225919523881041/720543470850146345/thomas.png)

@ -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;

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

Loading…
Cancel
Save