这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
Path2D
interface of the Canvas 2D API is used to declare a path that can then be used on a
CanvasRenderingContext2D
对象。
path methods
的
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
对象。
Path2D.addPath()
Adds a path to the current path.
Path2D.closePath()
Causes the point of the pen to move back to the start of the current sub-path. It tries to draw a straight line from the current point to the start. If the shape has already been closed or has only one point, this function does nothing.
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()
Adds a quadratic Bézier curve to the current path.
Path2D.arc()
x, y
) position with radius
r
起始于
startAngle
and ending at
endAngle
going in the given direction by
anticlockwise
(defaulting to clockwise).
Path2D.arcTo()
Adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
Path2D.ellipse()
x, y
) position with the radii
radiusX
and
radiusY
起始于
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
.
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'Path2D' in that specification. |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Path2D
|
Chrome Yes | Edge ≤18 | Firefox 31 | IE ? | Opera Yes | Safari 10 | WebView Android Yes | Chrome Android Yes | Firefox Android 31 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
Path2D()
构造函数
|
Chrome Yes |
Edge
≤18
注意事项
|
Firefox 31 | IE ? | Opera Yes | Safari 10 | WebView Android 不支持 No | Chrome Android 42 | Firefox Android 31 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 4.0 |
addPath
|
Chrome Yes | Edge ≤79 | Firefox 34 | IE 不支持 No | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android 34 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
见实现注意事项。