You need to give a size to your canvas.
How to draw triangle in html canvas. It does not draw anything, it just defines a new path. Working with paths is essential when drawing objects onto the canvas and we will see. The beginpath () method starts a new path.
Web by the end of this article, you will have learned how to draw rectangles, triangles, lines, arcs and curves, providing familiarity with some of the basic shapes.