diff --git a/README.md b/README.md index 305cdf0..aff3d9d 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,17 @@ A correct and understandable issue contains : You can also join me on my discord server. +# 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 You can download it from npmjs. @@ -137,9 +148,11 @@ bot.login("super_secret_token") ![Invert](https://cdn.discordapp.com/attachments/692101136802643989/714970523469217832/invert.png) -- .wanted(``); +- .wanted(``, ``); -![Wanted](https://cdn.discordapp.com/attachments/692101136802643989/714970791174996038/wanted.png) +> Currency ($, €, ...) + +![Wanted](https://cdn.discordapp.com/attachments/720225919523881041/720538669412253757/wanted.png) - .beautiful(``); @@ -156,3 +169,7 @@ bot.login("super_secret_token") - .delete(``); ![Delete](https://cdn.discordapp.com/attachments/692101136802643989/714971728849141901/delete.png) + +- .thomas(``); + +![Thomas](https://cdn.discordapp.com/attachments/720225919523881041/720543470850146345/thomas.png) \ No newline at end of file diff --git a/package.json b/package.json index b21017e..81dd2cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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.", "main": "src/index.js", "scripts": { diff --git a/src/module/DIG.js b/src/module/DIG.js index 68732c7..c5bac13 100644 --- a/src/module/DIG.js +++ b/src/module/DIG.js @@ -330,17 +330,22 @@ class DIG { * Wanted * @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."); - let base = await jimp.read(__dirname + "/assets/wanted.png"); - let img = await jimp.read(image); - img.resize(447, 447); - base.composite(img, 145, 282); - let raw; - base.getBuffer("image/png", (err, buffer) => { - raw = buffer; - }); - return raw; + 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(); } /** @@ -416,6 +421,22 @@ class DIG { 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."); + 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; diff --git a/src/module/assets/thomas.png b/src/module/assets/thomas.png new file mode 100644 index 0000000..551a49b Binary files /dev/null and b/src/module/assets/thomas.png differ diff --git a/src/module/assets/wanted.png b/src/module/assets/wanted.png index 0697b35..7d487d3 100644 Binary files a/src/module/assets/wanted.png and b/src/module/assets/wanted.png differ