From 364ce4bdf918602d87321bef9bd760a0d71fabb1 Mon Sep 17 00:00:00 2001 From: Mr-KayJayDee Date: Wed, 27 May 2020 00:50:34 +0200 Subject: [PATCH] :bookmark_tabs: Added docs and examples. --- README.md | 125 +++++++++++++++++++++++++++++++++++++++++++++- src/module/DIG.js | 41 ++++++++++----- 2 files changed, 152 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 61e3944..972925c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,126 @@ + + +Discord server + # discord-image-generation -> discord-image-generation is a powerfull module that allow you to generate awesome images. \ No newline at end of file +A powerfull module that allow you to generate awesome images. + +# Bugs and glitches + +Feel free to report all bugs and glitches by creating an issue in the issue section. + +A correct and understandable issue contains : +- Steps to reproduce +- Code that summonned the error +- The complete error + +You can also join me on my discord server. + +# Download + +You can download it from npmjs. + +```cli +npm i discord-image-generation +``` + +# Configuration + +The first step is to import the module in your code. + +```js +const DIG = require("discord-image-generation"); +``` + +# Available images + +- .blur(``, ``); + +![Blur](https://cdn.discordapp.com/attachments/692101136802643989/714952645063999548/blur.png) + +- .facepalm(``); + +![Facepalm](https://cdn.discordapp.com/attachments/692101136802643989/714952886123233331/facepalm.png) + +- .gay(``); + +![Gay](https://cdn.discordapp.com/attachments/692101136802643989/714953399308910664/gay.png) + +- .rip(``); + +![RIP](https://cdn.discordapp.com/attachments/692101136802643989/714954650121404517/rip.png) + +- .trash(``); + +![Trash](https://cdn.discordapp.com/attachments/692101136802643989/714955652216127498/trash.png) + +- .circle(``); + +![Circle](https://cdn.discordapp.com/attachments/692101136802643989/714956290270691358/circle.png) + +- .greyscale(``); + +![Greyscale](https://cdn.discordapp.com/attachments/692101136802643989/714956749521551411/greyscale.png) + +- .kiss(``, ``); + +![Kiss](https://cdn.discordapp.com/attachments/692101136802643989/714960724668973106/kiss.png) + +- .sepia(``); + +![Sepia](https://cdn.discordapp.com/attachments/692101136802643989/714961378917744700/sepia.png) + +- .mms(``); + +![MMS](https://cdn.discordapp.com/attachments/692101136802643989/714961764692787230/mms.png) + +- .spank(``, ``); + +![Spank](https://cdn.discordapp.com/attachments/692101136802643989/714962287361785906/spank.png) + +- .color(``); + +> An hex color is needed, like "#FF0000" + +![Color](https://cdn.discordapp.com/attachments/692101136802643989/714964205127598120/color.png) + +- .triggered(``); + +![Triggered](https://cdn.discordapp.com/attachments/692101136802643989/714968315214299166/triggered.gif) + +- .hitler(``); + +![Hitler](https://cdn.discordapp.com/attachments/692101136802643989/714969429598797935/hitler.png) + +- .batslap(``, ``); + +![Batslap](https://cdn.discordapp.com/attachments/692101136802643989/714969652521861160/batslap.png) + +- .bed(``, ``); + +![Bed](https://cdn.discordapp.com/attachments/692101136802643989/714970182946258974/bed.png) + +- .invert(``); + +![Invert](https://cdn.discordapp.com/attachments/692101136802643989/714970523469217832/invert.png) + +- .wanted(``); + +![Wanted](https://cdn.discordapp.com/attachments/692101136802643989/714970791174996038/wanted.png) + +- .beautiful(``); + +![Beautiful](https://cdn.discordapp.com/attachments/692101136802643989/714971024000811092/beautiful.png) + +- .jail(``); + +![Jail](https://cdn.discordapp.com/attachments/692101136802643989/714971265953300571/jail.png) + +- .affect(``); + +![Affect](https://cdn.discordapp.com/attachments/692101136802643989/714971482207289394/affect.png) + +- .delete(``); + +![Delete](https://cdn.discordapp.com/attachments/692101136802643989/714971728849141901/delete.png) diff --git a/src/module/DIG.js b/src/module/DIG.js index 5d00abc..febf77b 100644 --- a/src/module/DIG.js +++ b/src/module/DIG.js @@ -41,25 +41,31 @@ class DIG { 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(400, 400); + const canvas = Canvas.createCanvas(480, 480); const ctx = canvas.getContext("2d"); - ctx.drawImage(img, 0, 0, 400, 400); - ctx.drawImage(bg, 0, 0, 400, 400); + ctx.drawImage(img, 0, 0, 480, 480); + ctx.drawImage(bg, 0, 0, 480, 480); return canvas.toBuffer(); } 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."); - const canvas = Canvas.createCanvas(768, 574); - const ctx = canvas.getContext("2d"); - const background = await Canvas.loadImage(__dirname +"/assets/kiss.png"); - ctx.drawImage(background, 0, 0, canvas.width, canvas.height); - const avatar = await Canvas.loadImage(image1); - const avatar1 = await Canvas.loadImage(image2); - ctx.drawImage(avatar1, 370, 25, 200, 200); - ctx.drawImage(avatar, 150, 25, 200, 200); - return canvas.toBuffer(); + 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; } static async rip(image) { @@ -79,6 +85,8 @@ class DIG { 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); @@ -127,6 +135,7 @@ class DIG { 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) => { @@ -138,6 +147,7 @@ class DIG { 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) => { @@ -149,6 +159,7 @@ class DIG { 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) => { @@ -160,6 +171,7 @@ class DIG { 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) => { @@ -222,6 +234,8 @@ class DIG { 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); @@ -249,7 +263,7 @@ class DIG { return raw; } - static async trigger(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); @@ -276,6 +290,7 @@ class DIG { 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) => {