Learn by Building Workshop Skills GitHub Türkçe Workshop › Tic-tac-toe › Step 2 of 33
Paint the board What we are doing Our first drawing: the whole canvas gets a dark navy background. Drawing is always two moves: pick a color, then
fill a shape with it.
```js
ctx.fillStyle = '#1e1e2e'
ctx.fillRect(0, 0, canvas.width, canvas.height)
```What it means
ctx.fillStyle = '#1e1e2e' picks the fill color, a dark navy.
ctx.fillRect(x, y, width, height) fills a rectangle. 0, 0 is the top-left corner, and canvas.width and
canvas.height (300 and 300) make it cover everything.
Your turn Leave an empty line under const ctx = ..., write the two lines, then press Run .
Skills: Drawing on a canvas
← Get the canvas and the pen The first grid line →
All steps Get the canvas and the pen Paint the board The first grid line Repeat with a loop Finish the grid The board as a list A function that draws Write an X From cell number to position Draw what the board holds A color for each mark Make a move No playing on a taken cell Listen for clicks Which cell was clicked? Clicks on any screen size The eight winning lines Find three in a row Win, draw or go on The round ends Show who won Light up the winning line A function for a fresh round Click to play again A computer that picks a cell The computer answers Rule one: take the center Rule two: win when you can Rule three: block the opponent Score a finished game Look ahead: minimax A computer that never loses Build it yourself: keep score