| Path2D Class | |
|---|---|
| Constructors | Description |
| Path2D() Path2D(path) Path2D(svg) | This creates a new empty Path2D object that empty, clone of an existing Path2D as path, or a translation of an svg path given as a string. |
| Methods | Description |
| addPath(path) addPath(path, mtx) | This adds the Path2D path to the current path. If a DOMMatrix mtx is passed in, its transformation is applied to path. |
| closePath() | If this path has not been closed, this adds a straight line from the current point to start of the currently open part of the path. If the path has been closed already, this does nothing. |
| moveTo(x, y) | This sets the current drawing position to the point (x, y) without drawing anything. |
| lineTo(x, y) | This sets the current drawing position to the point (x, y) and sets a corresponding command to make a line segment from the current postion to (x, y) when a drawing cammand is called, like fill() or stroke(). |
| bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) | This draws a bezier curve from the current point in the path to the point (x, y), using the control points (cp1x, cp1y) and (cp2x, cp2y). |
| quadraticCurveTo(cpx, cpy, x, y) | This draws a quadratic bezier curve from the current point in the path to the point (x, y), using the control point (cpx, cpy). |
| arc(x, y, r, sa, ea) arc(x, y, r, sa, ea, cc) | This draw a circular arc from the current point to the point (x, y) with a radius of r and starting and ending angles sa and ea. If the boolean cc is true, the counterclockwise arc is drawn. Otherwise, the default clockwise arc is drawn. |
| arcTo(cp1x, cp1y, cp2x, cp2y, r) | This draws an arc with radius r and control points (cp1x, cp1y) and (cp2x, cp2y) from the current point. |
| ellipse(x, y, rx, ry, rot, sa, ea) ellipse(x, y, rx, ry, rot, sa, ea, cc) | Much like the arc() function, this draws the arc of the ellipse centered at (x, y) with rx and ry defining the "radius" along each axis. The arc is drawn from the angle sa to ea in the clockwise direction, unless the counterclockwise boolean value, cc, is set to true. A rotation of rot radians in the clockwise direction is applied to the ellipse after it is drawn. |
| rect(x, y, w, h) | This draws a rectangle with the point (x, y) as the upper-left corner and width and height given by w and h, if they are both positive. If the value of w or h is negative the direction is flipped. |
| roundRect(x, y, w, h, r) | This draws a rounded rectangle with the point (x, y) as the upper-left corner and width and height given by w and h, if they are both positive. If the value of w or h is negative the direction is flipped. The radii can be specified as a single value for all corners or as an array of values to specify each corner individually. If an array of values is used, the values correspond to the corners as follows: [all], [tl & br, tr & bl], [tl, tr & bl, br], [tl, tr, br, bl]. |
© 20072025 XoaX.net LLC. All rights reserved.