Learn Create Your Own Split Screen

Next Page

Now we're going to change the colour of the second rectangle.

This is done by changing a property of the drawing context. Once we've done that, anything else we draw will be drawn in the new colour.

ctx.fillStyle= "red";

Challenge: Try to draw a third rectangle somewhere else on the canvas, but make it green.

Pro tip: Use copy and paste, rather than re-typing. You'll make fewer 'case' and punctuation errors. But remember to move your new rectangle to a different position, otherwise you won't see it.