In the example given below, even though we
have begun a path with beginPath()
, told the
canvas where to start drawing from using moveTo(0, 0)
,
and finally ensured that we are creating a line
using lineTo(50, 50)
, there is still no line
visible on the canvas. The final step is to
tell the canvas whether to add a background colour
to the shape we created by using fill()
or to add a border
by using stroke()
.
Since we intend to create a line,
we need to use stroke()
. Take a look: