Workshop › Tic-tac-toe › Step 22 of 33
A small touch that makes a big difference: after dimming, we light up the three winning cells with a see-through yellow, so the player sees at once why the round ended.
```js
// Dim the board, then light up the winning line on top so it stands out.
ctx.fillStyle = 'rgba(0, 0, 0, 0.55)'
ctx.fillRect(0, 0, canvas.width, canvas.height)
const line = winningLine(board)
if (line) {
ctx.fillStyle = 'rgba(250, 204, 21, 0.25)'
for (const index of line) ctx.fillRect((index % 3) * CELL, Math.floor(index / 3) * CELL, CELL, CELL)
}
```winningLine(board) gives the three winning cell numbers, or undefined after a draw (then nothing is lit).for (const index of line) repeats for each of the three numbers; a one-line body needs no braces.In draw, add the comment above the dimming lines, and the line lines right under the dimming fillRect.
Skills: Drawing on a canvas, Loops
← Show who won A function for a fresh round →