This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The Path2D
interface of the Canvas 2D API is used to declare a path that can then be used on a CanvasRenderingContext2D
object. The path methods of the CanvasRenderingContext2D
interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired.
Path2D()
Path2D
constructor. Creates a new Path2D
object.Path2D.addPath()
Path2D.closePath()
Path2D.moveTo()
x, y
) coordinates.Path2D.lineTo()
x, y
) coordinates with a straight line.Path2D.bezierCurveTo()
moveTo()
before creating the Bézier curve.Path2D.quadraticCurveTo()
Path2D.arc()
x, y
) position with radiusr
starting at startAngle
and ending at endAngle
going in the given direction by anticlockwise
(defaulting to clockwise).Path2D.arcTo()
Path2D.ellipse()
x, y
) position with the radii radiusX
and radiusY
starting at startAngle
and ending at endAngle
going in the given direction by anticlockwise
(defaulting to clockwise).Path2D.rect()
x, y
) with a size that is determined by width
and height
.Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'Path2D' in that specification. | Living Standard |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | 31 | ? | Yes | 10 |
Path2D() constructor
|
Yes | Yes
|
31 | ? | Yes | 10 |
addPath
|
Yes | ? | 34 | No | Yes | Yes |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | ? | 31 | Yes | No | Yes |
Path2D() constructor
|
No | 42 | ? | 31 | Yes | No | 4.0 |
addPath
|
Yes | Yes | ? | 34 | Yes | Yes | Yes |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Path2D