Learn Create Your Own Split Screen

Next Page

The key to this is a fancier use of drawImage.

We've used drawImage before like this:

ctx.drawImage(MyImg, x, y);
All pretty straightforward -- drawImage takes three parameters, being the image we want to draw, and the x & y position on the canvas where we want to draw it.

But there's a fancier form of drawImage that accepts seven parameters:

We don't actually need the last pair of parameters, but the rules of Javascript demand we have to provide them.