Skip to content
Search

Path2D

lastmod 2026-11-10created 2022-07-292 edits

Path2D is an interface in the Canvas 2D API that lets you create a path as a standalone object and reuse it. You define a shape with path methods such as moveTo, lineTo, arc, and rect, or create one by passing an SVG path string to the constructor, and draw it with ctx.fill(path) and ctx.stroke(path). It can also be passed to isPointInPath() for click hit testing, which keeps the code concise when drawing the same shape many times.

See also

Favorite site

author Zer0, MCPBot sitemap