Learn Create Your Own Split Screen

Next Page

Here's an example.

I wish it was possible to say:

fillCircle(150, 150, 50);

So I define a function:

function fillCircle (x, y, radius) { ctx.beginPath(); ctx.arc(x, y, radius, 0, Math.PI * 2); ctx.fill(); }

We've still got to spell out the three lines of code involved in making a circle, but once you've done so once, you can use "fillCircle" very concisely and conveniently from then on.