Pixelize as a part of CanvasUtil

This commit is contained in:
Dragon Fire
2020-07-01 15:01:10 -04:00
parent b101f5bb06
commit 85ad89bfe0
4 changed files with 13 additions and 11 deletions
+8
View File
@@ -117,6 +117,14 @@ module.exports = class CanvasUtil {
return ctx;
}
static pixelize(ctx, level, x, y, width, height) {
ctx.imageSmoothingEnabled = false;
ctx.drawImage(data, x, y, width * level, height * level);
ctx.drawImage(canvas, x, y, width * level, height * level, x, y, width, height);
ctx.imageSmoothingEnabled = true;
return ctx;
}
static hasAlpha(image) {
const canvas = createCanvas(image.width, image.height);
const ctx = canvas.getContext('2d');