modern-canvacord
Version:
Easy image manipulation for discord.js bots.
19 lines (17 loc) • 698 B
JavaScript
module.exports = (ctx, x, y, width, height, radius) => {
if (radius === true) radius = 5;
if (!radius || typeof radius !== "number") radius = 0;
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
ctx.fill();
return ctx;
};