Download src/utils/canvas/shape.js from vanducdev/botzalo: direct link, hf CLI and curl.
- Browser
- Download file 830 Bytes
-
https://huggingface.co/spaces/vanducdev/botzalo/resolve/main/src/utils/canvas/shape.js
- Command line
-
hf download hf://spaces/vanducdev/botzalo/src/utils/canvas/shape.js
-
curl -L -o shape.js https://huggingface.co/spaces/vanducdev/botzalo/resolve/main/src/utils/canvas/shape.js
830 Bytes
| // Hàm vẽ hình chữ nhật với góc bo tròn | |
| function roundRect(ctx, x, y, width, height, radius, fill, stroke) { | |
| if (typeof stroke === "undefined") { | |
| stroke = true; | |
| } | |
| if (typeof radius === "undefined") { | |
| radius = 5; | |
| } | |
| 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(); | |
| if (fill) { | |
| ctx.fill(); | |
| } | |
| if (stroke) { | |
| ctx.stroke(); | |
| } | |
| } | |
| export { roundRect }; |