@mocanvas/mocanvas · function

traceRoundedRect

declare function traceRoundedRect(ctx: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, radius: number): void

Trace a rectangle with rounded corners.

ctx.roundRect is not in jsdom and was late to Safari, so the path is built by hand — an overlay that silently stops drawing on one browser is worse than four arcs.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.