Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Path2D

Наши волонтёры ещё не перевели данную статью на Русский. Присоединяйтесь к нам и помогите закончить эту работу!

This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the specification changes.

The Path2D interface of the Canvas 2D API is used to declare paths that are then later used on CanvasRenderingContext2D objects. The path methods of the CanvasRenderingContext2D interface are present on this interface as well and are allowing you to create paths that you can retain and replay as required on a canvas.

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 an arc to the path with the given control points and radius, connected to the previous point by a straight line.
Path2D.ellipse()
Adds an ellipse 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

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'Path2D' in that specification.
Living Standard  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 31 (31) Edge (Yes) 10
Path2D.addPath() (Yes) 34 (34) No support (Yes) 10
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) 31.0 (31) No support (Yes) No support
Path2D.addPath() (Yes) 34.0 (34) No support (Yes) No support

See also

Метки документа и участники

 Внесли вклад в эту страницу: Moyogo, fscholz, mikeg0
 Обновлялась последний раз: Moyogo,