Workshop › Connect Four › Step 25 of 38
Circle the four
What we are doing
The winning discs get a white ring. To draw only the outline of a circle, use stroke instead of fill.
```js
for (const [row, col] of line) {
ctx.strokeStyle = 'white'
ctx.lineWidth = 4
ctx.beginPath()
ctx.arc(col * CELL + CELL / 2, TOP + row * CELL + CELL / 2, CELL / 2 - 10, 0, Math.PI * 2)
ctx.stroke()
}
```
What it means
for (const [row, col] of line) takes each [row, col] pair apart.
strokeStyle is the line color, lineWidth its thickness, and stroke draws the outline of the circle (radius 22).
Your turn
In draw, under the falling disc line, leave an empty line and write the loop.
Skills: Drawing on a canvas
← We have a winner Who won? →
All steps
- A dark background
- A drawing function
- The blue board
- One hole
- A whole row
- All 42 holes
- The board in memory
- Discs in their colors
- Draw every frame
- Where does the disc land?
- Play a column
- Taking turns
- Click to play
- The next disc
- Whose turn?
- Playing with the keyboard
- Keys 1 to 7
- A disc on its way
- Gravity
- Watch it fall
- Inside the board?
- Walking along a line
- Four in a row?
- We have a winner
- Circle the four
- Who won?
- A draw
- Play again
- Try a move and take it back
- Win, or block
- Don't help the player
- Prefer the middle
- The computer's turn
- Only on your turn
- You and the computer
- Counting wins
- Show the score
- Build it yourself: the loser starts