Path2D - Web APIs 编辑

Experimental

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.

Constructors

Path2D()
Path2D constructor. Creates a new Path2D object.

Methods

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()
Moves the starting point of a new sub-path to the (x, y) coordinates.
Path2D.lineTo()
Connects the last point in the subpath to the (x, y) coordinates with a straight line.
Path2D.bezierCurveTo()
Adds a cubic Bézier curve to the path. It requires three points. The first two points are control points and the third one is the end point. The starting point is the last point in the current path, which can be changed using moveTo() before creating the Bézier curve.
Path2D.quadraticCurveTo()
Adds a quadratic Bézier curve to the current path.
Path2D.arc()
Adds an arc to the path which is centered at (x, y) position with radius r starting at 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()
Adds an elliptical arc to the path which is centered at (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()
Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of 'Path2D' in that specification.
Living Standard

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:98 次

字数:5010

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文