Vignette Command

This commit is contained in:
Dragon Fire
2021-03-28 13:13:35 -04:00
parent 165f0afb32
commit 818cfbcfe4
4 changed files with 57 additions and 1 deletions
+11
View File
@@ -133,6 +133,17 @@ module.exports = class CanvasUtil {
return ctx;
}
static vignette(ctx, width, height) {
const outerRadius = width * 0.5;
const innerRadius = width * 0.2;
const grd = ctx.createRadialGradient(width / 2, height / 2, innerRadius, width / 2, height / 2, outerRadius);
grd.addColorStop(0, 'rgba(0, 0, 0, 0.4)');
grd.addColorStop(1, 'rgba(0, 0, 0, 0.9)');
ctx.fillStyle = grd;
ctx.fillRect(0, 0, width, height);
return ctx;
}
static hasAlpha(image) {
const canvas = createCanvas(image.width, image.height);
const ctx = canvas.getContext('2d');