Learn Create Your Own Split Screen

Next Page

Recall we used translate to move our canvas co-ordinates, and then actually drew our image half a height & width back from there, so we could rotate properly around our center.

Our drawImage looked slightly (but not exactly) like this:

ctx.drawImage(MyImg, -width/2, -height/2);
With these extra parameters, it's going to look like this:
ctx.drawImage(MyImg, 0, 0, width, height, -width/2, -height/2, width, height);
It's a bit of an eye-full, and it's going to get even moreso when we include all the "syntactic sugar" necessary to make it correct.

The complicating factor is that there are two different sets of x & y:

There's also two different sets of height and width:
This could get a little confusing, so we'll need to get it straight in our own heads. Fortunately, once it's done we can just use it without having to stress about the details.