Part 2: Path2D Drawing Functions
There are a variety of Path2d drawing functions, all of which result in paths that are constructed of the same basic segment types explained in the previous section. These are the basic drawing functions:
- moveTo: Moves the path2d to a start point. All subsequent drawing functions will continue from this point. Accepts 1 coordinate and results in a MOVETO segment.
- lineTo: Accepts 1 coordinate and draws a line from the previously specified point in the path to the given one. Results in a LINETO segment.
- quadTo: Accepts 1 central handle point and 1 end point to create a quadratic bezier curve resulting in a QUADTO segment.
- curveTo: Accepts 2 handle points and 1 end point to create a cubic bezier curve resulting in a CUBICTO segment
- arc: Accepts a center point, a radius, start angle (in radians), end angle (in radians), and optional boolean for direction of the arc (defaults to true for forward). This results in a CUBICTO segment.
- arcTo: Draws a line segment from the current point toward the first point given to draw a rounded corner. This segment terminates in an arc with the specified radius whose end is tangent to the line segment connecting the two points specified. Accepts a target point, a tangent position, and a radius. Results in a path composed of LINETO and/or CUBICTO segments.