Workshop › OutRun-style Racer › Step 17 of 44
A speedometer at the top left. Our speed is in world units per frame, so we scale it to a friendlier number: top speed shows as 300 km/h.
```js
ctx.fillStyle = '#0f172a'
ctx.font = 'bold 16px sans-serif'
ctx.textAlign = 'left'
ctx.fillText(Math.round((speed / MAX_SPEED) * 300) + ' km/h', 10, 22)
```font and textAlign set the text style; fillText(text, x, y) paints it.speed / MAX_SPEED is 0 to 1; times 300 is 0 to 300. Math.round rounds to a whole number, and + ' km/h' joins it
to the text.Under the car's last wheel line, leave an empty line and write the four speedometer lines.
Skills: Drawing on a canvas
← Your car A pedal for phones →