mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Fix
This commit is contained in:
@@ -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' }] });
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user