Conclusion

The thing that confused me when working with the canvas is that beginPath is the only thing you need to signal your intent to draw a new shape. For every new shape you want to draw, just call beginPath. Any stroke, fill, or draw-related properties you set earlier stay with the earlier shape. Nothing gets carried over to your new shape. This confusion was compounded every time I saw the closePath method. As we saw in the previous tutorial, all closePath does is draw a line from where you are now to your shape’s starting point. You don’t have to specify it if you are going to manually close the shape using lineTo, and you certainly don’t need to pair it with beginPath to signal the closing of your shape.

Get hands-on with 1400+ tech skills courses.