mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-08 15:19:14 +02:00
Vignette Command
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user