Workshop › Connect Four › Step 4 of 38
Holes and discs are both circles, only in different colors. One small function, disc(x, y, color), will draw them all.
We try it on the top-left hole.
```js
function disc(x, y, color) {
ctx.fillStyle = color
ctx.beginPath()
ctx.arc(x, y, CELL / 2 - 6, 0, Math.PI * 2)
ctx.fill()
}
disc(CELL / 2, TOP + CELL / 2, '#0f172a')
```x, y and color are parameters: the values given in the call.beginPath starts a shape, arc(x, y, radius, start, end) adds a circle around (x, y), from angle 0 to a full turn
(Math.PI * 2), and fill paints it. The radius is 26, leaving a gap between holes.function draw() { write disc, followed by an empty line.draw, under the blue rectangle, write the disc(...) call.Skills: Drawing on a canvas, Functions
← The blue board A whole row →