A path is a list of points, connected by segments of lines that can be of different shapes, curved or not, of different width and of different color. A path, or even a sub-path (from moveTo), can be closed.
Note that fill() and stroke() are applied to the current path only and the shapes that are not defined in any path!
To make shapes using paths execute the following steps:
Create the path.
Use drawing commands to draw into the path: moveTo, lineTo, arc, arcTo, rect, bezierCurveTo, quadraticCurveTo).
Close the path.
Once the path has been created, you can stroke or fill the path to render it.
Functions:
beginPath() - starts dots connection.
closePath() - causes the point of the pen to move back to the start of the current sub-path (created by moveTo).
stroke() - draws the current path by stroking its outline.The stroke is according to the strokeStyle property. If strokeStyle is not specified, black line is drawn.
fill() - draws a solid shape by filling the path's content area. The fill is according to the fillStyle property. If strokeStyle is not specified, black line is drawn.
Bezier path:
Bezier curves, available in both cubic and quadratic varieties. These are generally used to draw complex organic shapes.
quadraticCurveTo(cp1x, cp1y, x, y) - defines a quadratic Bezier curve from the current pen position to the end point specified by x and y, using the control point specified by cp1x and cp1y.
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) - defines a cubic Bézier curve from the current pen position to the end point specified by x and y, using the control points specified by (cp1x, cp1y) and (cp2x, cp2y).