Engineering
How we draw 10,000 blocks without slowing your phone
A full wall holds up to 10,000 blocks, each with its own image, and people look at it on phones. Drawing every block every time would be slow. The wall is built so that the work depends on what is on screen, not on how many blocks exist. This is how.
The idea: pay for what you can see
A visitor sees a small part of the wall at once. So the renderer only touches blocks near the visible area. Zooming in on one corner costs about the same whether the wall has 20 blocks or 10,000.
Two layers, redrawn for different reasons
| Layer | What it holds | When it is redrawn |
|---|---|---|
| Static layer | The board, the grid, the held areas and every block's image | Only when the camera moves, the data changes, a filter changes or an image arrives |
| Overlay layer | The hover mark, your selection, demo marks and the highlight when you follow a link | Often, because it is small and cheap |
Moving the mouse over the wall redraws only the overlay. The blocks underneath are not touched.
How a block gets drawn
- Pick the visible blocksOnly blocks near the visible area are considered.
- Batch the cheap partsThe white backing and borders of all blocks are drawn together.
- One draw per imageEach block's image is drawn once, without clipping each one separately.
- Skip what is not readyA block whose image has not arrived yet is drawn as a placeholder and filled in when it does.
Loading images only when needed
- Images are requested only when their block is on screen.
- The browser decodes them off the main thread, so scrolling stays responsive.
- The cache is bounded: it can keep every block of a full view (a full wall has at most 10,000), and when it fills up the least recently drawn images are dropped.
Finding the block under your finger
Blocks sit on a 10-pixel grid and never overlap, so any point on the wall belongs to at most one block. The wall keeps an index by grid cell, and looking up the block under the pointer is a constant-time step: it does not search the list. The canvas also never captures ordinary page scrolling, so a swipe on a phone still scrolls the page.
Questions people ask
Why a canvas and not 10,000 page elements?
Ten thousand separate elements would be heavy for a browser to lay out and update. A canvas draws what is visible in one pass.
Does the wall load every image up front?
No. Images are requested when their block is on screen, and the cache drops the least recently drawn ones when it fills.
Does the wall block page scrolling?
No. It never captures ordinary page scrolling.