Draw Order Matters

We are almost done here. One last thing to call out is the order with which things get rendered on the canvas. The canvas follows what is known as the “painters model” of rendering. All of your draw operations are added to the canvas in the order they were specified in. This means the first shape you define in your code will be added to the canvas first. The second shape you define will be added next and drawn over the top of the first shape (if they overlap). The third shape will…you see the pattern:

Get hands-on with 1200+ tech skills courses.