(
ctx: CanvasRenderingContext2D,
rect: RoundedRect & { radius: TRBLCorners }
)
| 496 | * @param rect - Bounding rect |
| 497 | */ |
| 498 | export function addRoundedRectPath( |
| 499 | ctx: CanvasRenderingContext2D, |
| 500 | rect: RoundedRect & { radius: TRBLCorners } |
| 501 | ) { |
| 502 | const {x, y, w, h, radius} = rect; |
| 503 | |
| 504 | // top left arc |
| 505 | ctx.arc(x + radius.topLeft, y + radius.topLeft, radius.topLeft, 1.5 * PI, PI, true); |
| 506 | |
| 507 | // line from top left to bottom left |
| 508 | ctx.lineTo(x, y + h - radius.bottomLeft); |
| 509 | |
| 510 | // bottom left arc |
| 511 | ctx.arc(x + radius.bottomLeft, y + h - radius.bottomLeft, radius.bottomLeft, PI, HALF_PI, true); |
| 512 | |
| 513 | // line from bottom left to bottom right |
| 514 | ctx.lineTo(x + w - radius.bottomRight, y + h); |
| 515 | |
| 516 | // bottom right arc |
| 517 | ctx.arc(x + w - radius.bottomRight, y + h - radius.bottomRight, radius.bottomRight, HALF_PI, 0, true); |
| 518 | |
| 519 | // line from bottom right to top right |
| 520 | ctx.lineTo(x + w, y + radius.topRight); |
| 521 | |
| 522 | // top right arc |
| 523 | ctx.arc(x + w - radius.topRight, y + radius.topRight, radius.topRight, 0, -HALF_PI, true); |
| 524 | |
| 525 | // line from top right to top left |
| 526 | ctx.lineTo(x + radius.topLeft, y); |
| 527 | } |
no outgoing calls
no test coverage detected