HTML5 Canvas - Drawing Paths
There are following methods required to draw paths on the canvas −
|SN||Method and Description|
This method resets the current path.
This method creates a new subpath with the given point.
This method marks the current subpath as closed, and starts a new subpath with a point the same as the start and end of the newly closed subpath.
This method fills the subpaths with the current fill style.
This method strokes the subpaths with the current stroke style.
arc(x, y, radius, startAngle, endAngle, anticlockwise)
Adds points to the subpath such that the arc described by the circumference of the circle described by the arguments, starting at the given start angle and ending at the given end angle, going in the given direction, is added to the path, connected to the previous point by a straight line.
Following is a simple example which makes use of above mentioned methods to draw a shape.
The above example would draw following shape:
To learn above concept - Do Online Practice using latest version of either Safari or Opera.