For doing anything on the canvas
, we need to get its context.
Here, we use the getContext()
method to get a context to draw stuff on it. It can create 2-dimensional or 3-dimensional drawing spaces for us. For our purposes, we will limit to creating 2-dimensional contexts. For this, remember to provide 2d as an argument to the getContext
method.