Nos bénévoles n'ont pas encore traduit cet article en Français. Inscrivez-vous et aidez-nous à réaliser cette tâche !
Vous pouvez également lire cet article en English (US).
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.
Path2Dconstructor. Creates a new
- Adds a path to the current path.
- 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.
- Moves the starting point of a new sub-path to the (x, y) coordinates.
- Connects the last point in the subpath to the
x, ycoordinates with a straight line.
- 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.
- Adds a quadratic Bézier curve to the current path.
- 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).
- Adds an arc to the path with the given control points and radius, connected to the previous point by a straight line.
- 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).
- Creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
|HTML Living Standard
The definition of 'Path2D' in that specification.
|Feature||Android webview||Chrome for Android||Edge mobile||Firefox for Android||Opera Android||iOS Safari||Samsung Internet|
1. The constructor for
Path2D objects in Edge does not support being invoked with a string consisting of SVG path data. See issue 8438884 for details.