Learn by Building Workshop Skills GitHub Türkçe Workshop › Tetris-style Blocks › Step 3 of 32
Draw one cell What we are doing drawCell(col, row, color) paints the cell at a column and row. It is drawn one pixel smaller on every side, so
stacked blocks show a thin dark line between them. We try it on the bottom-left cell.
```js
function drawCell(col, row, color) {
ctx.fillStyle = color
ctx.fillRect(col * CELL + 1, row * CELL + 1, CELL - 2, CELL - 2)
}
drawCell(0, 19, '#94a3b8')
```What it means
The three parameters are the column, the row and the color.
col * CELL + 1 is 1 pixel right of the cell's left edge; CELL - 2 is 22, so there is a 1-pixel gap on each side.
The last line is a test call: column 0, row 19, grey.
Your turn
Under the let board line write drawCell.
At the very end, leave an empty line and write the test call.
Skills: Drawing on a canvas, Functions
← The board as rows of numbers Draw the whole board →
All steps The well The board as rows of numbers Draw one cell Draw the whole board The number is the color A piece is a small grid A list of shapes All seven pieces Does it fit inside the well? Blocks are in the way Try, then move Move with the arrows Turn a matrix Turn with Up Wall kicks Falling by itself A random piece at the top Land and lock One function starts a game When the pile reaches the top Game Over on screen Play again Clear full rows Points for lines The side panel Levels Faster every level A fair bag of pieces The next piece Drop it The ghost piece Build it yourself: hold a piece