Learn by Building Workshop Skills GitHub Türkçe Workshop › Conway's Game of Life › Step 2 of 32
Measure the grid What we are doing The world is a grid of small cells: 60 columns and 48 rows of 8-pixel cells. We name these numbers once and paint
the grid's area a little lighter, leaving a strip at the top for text.
```js
const CELL = 8
const COLS = 60
const ROWS = 48
const TOP = 36
ctx.fillStyle = '#1e293b'
ctx.fillRect(0, TOP, COLS * CELL, ROWS * CELL)
```What it means
CELL is the size of a cell in pixels, COLS and ROWS count the columns and rows, TOP is the strip above
the grid.
The grid area starts at x = 0, y = TOP and is COLS * CELL (480) wide and ROWS * CELL (384) tall. * means
multiply.
Your turn
Under const ctx = ... leave an empty line and write the four constants.
At the very end, under the background lines, write the two #1e293b lines. Press Run .
Skills: Drawing on a canvas
← The board One living cell →
All steps The board Measure the grid One living cell A function that draws The world in memory Draw every living cell A random soup Count the neighbours Four rules Draw again and again Next generation with N Count the generations Show the generation A world without edges Count the living A generation every few frames Let it live Running or not One place for the buttons Space to play, N to step Clear and shuffle Where is the pointer? Which cell? Click a cell Paint or erase? Drag to paint Patterns from text The glider gun Fire the gun Buttons on the screen Tap the buttons Build it yourself: a world at rest