This commit is contained in:
Dragon Fire
2020-07-01 15:02:57 -04:00
parent 85ad89bfe0
commit 2208287333
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -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' }] });
+1 -1
View File
@@ -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';
+2 -2
View File
@@ -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;