![]() |
VOOZH | about |
HTML Canvas Shapes facilitate different shapes, i.e., rectangles, triangles, lines, arcs, and curves to draw on the HTML Canvas.
For instance, to draw the line in the Canvas, the path will be used that implements the beginPath() method. Setting the path's starting point is achieved with moveTo(), while lineTo() establishes the endpoint. To render the line, we use the stroke() method, with the default stroke color being black.
context.beginPath(); context.moveTo(); context.lineTo(); context.stroke();
Example: In this example, we will implement a code to draw canvas shapes with default property.
Output:
Example: In this example, we will implement a code to draw canvas shapes with the strokeStyle property.
Output: