From 33d5f503120e2de18afd3407976e1b1101d8f219 Mon Sep 17 00:00:00 2001 From: "adam :)" <48551808+Pyrojs@users.noreply.github.com> Date: Fri, 17 Jul 2020 12:56:51 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=96=20Bobross?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/module/montage/bobross.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/module/montage/bobross.js diff --git a/src/module/montage/bobross.js b/src/module/montage/bobross.js new file mode 100644 index 0000000..bc33393 --- /dev/null +++ b/src/module/montage/bobross.js @@ -0,0 +1,22 @@ +const { createCanvas, loadImage } = require("canvas"); + +class Bobross { + /** + * Bobross + * @param {image} image1 + */ + async getImage(image1){ + if (!image1) throw new Error(`You must provide an image as argument.`); + const base = await loadImage(`${__dirname}/../../assets/bobross.png`); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext("2d"); + image1 = await loadImage(image1); + ctx.fillStyle = "white"; + ctx.fillRect(0, 0, base.width, base.height); + ctx.drawImage(image1, 15, 20, 440, 440); + ctx.drawImage(base, 0, 0); + return canvas.toBuffer() + } +} + +// -N²O Pyro ;)