MCPcopy
hub / github.com/chartjs/Chart.js / addRoundedRectPath

Function addRoundedRectPath

src/helpers/helpers.canvas.ts:498–527  ·  view source on GitHub ↗
(
  ctx: CanvasRenderingContext2D,
  rect: RoundedRect & { radius: TRBLCorners }
)

Source from the content-addressed store, hash-verified

496 * @param rect - Bounding rect
497 */
498export 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}

Callers 3

drawLegendBoxMethod · 0.85
_drawColorBoxMethod · 0.85
drawPointLabelBoxFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected