From 2208287333ad2e4a4273945b78df9f1f80a1b1ea Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Wed, 1 Jul 2020 15:02:57 -0400 Subject: [PATCH] Fix --- commands/edit-image/pixelize.js | 2 +- commands/edit-image/wild-pokemon.js | 2 +- util/Canvas.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/edit-image/pixelize.js b/commands/edit-image/pixelize.js index 342d588c..25aaec28 100644 --- a/commands/edit-image/pixelize.js +++ b/commands/edit-image/pixelize.js @@ -33,7 +33,7 @@ module.exports = class PixelizeCommand extends Command { const data = await loadImage(body); const canvas = createCanvas(data.width, data.height); const ctx = canvas.getContext('2d'); - pixelize(ctx, 0.15, 0, 0, canvas.width, canvas.height); + pixelize(ctx, canvas, data, 0.15, 0, 0, canvas.width, canvas.height); const attachment = canvas.toBuffer(); if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); return msg.say({ files: [{ attachment, name: 'pixelize.png' }] }); diff --git a/commands/edit-image/wild-pokemon.js b/commands/edit-image/wild-pokemon.js index 6af41179..282ca382 100644 --- a/commands/edit-image/wild-pokemon.js +++ b/commands/edit-image/wild-pokemon.js @@ -62,7 +62,7 @@ module.exports = class WildPokemonCommand extends Command { const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0); const { x, y, width, height } = centerImagePart(data, 100, 100, 227, 11); - pixelize(ctx, 0.30, x, y, width, height); + pixelize(ctx, canvas, data, 0.30, x, y, width, height); greyscale(ctx, x, y, width, height); ctx.textBaseline = 'top'; ctx.font = '16px Pokemon GB'; diff --git a/util/Canvas.js b/util/Canvas.js index 4316bd44..1e6ddb6e 100644 --- a/util/Canvas.js +++ b/util/Canvas.js @@ -117,9 +117,9 @@ module.exports = class CanvasUtil { return ctx; } - static pixelize(ctx, level, x, y, width, height) { + static pixelize(ctx, canvas, image, level, x, y, width, height) { ctx.imageSmoothingEnabled = false; - ctx.drawImage(data, x, y, width * level, height * level); + ctx.drawImage(image, x, y, width * level, height * level); ctx.drawImage(canvas, x, y, width * level, height * level, x, y, width, height); ctx.imageSmoothingEnabled = true; return ctx;