Command Palette

Search for a command to run...

Hectal
Phase 11: Canvas 2D in Depth
Data Visualization · Exercise 3 of 4 PreviousNext
Intermediate

Make it sharp at ratio 2

The canvas is 160 × 60 CSS pixels. On a screen with pixel ratio 2 it should have a 320 × 120 grid, but still draw in CSS pixels.

Finish setupCanvas(canvas, 160, 60, 2): the grid, the box, and one setTransform. The rectangle is drawn at (10, 10) 40 × 20 CSS pixels.

What Check tests

  1. The grid is 320 × 120
  2. The box is 160 CSS pixels wide
  3. The rectangle fills device pixels 20 to 100

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.