mirror of
https://github.com/1disk/edp445.git
synced 2024-08-14 22:47:02 +00:00
19 lines
No EOL
680 B
JavaScript
19 lines
No EOL
680 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;
|
|
}; |