Workshop › Pool › Step 30 of 33
While aiming, the aim line now ends at the ghost ball, and an outlined circle shows where the cue ball will touch.
```js
const g = ghost()
const length = g ? g.hit : 400
ctx.lineTo(cue.x + Math.cos(aim) * length, cue.y + Math.sin(aim) * length)
ctx.stroke()
if (g) {
ctx.beginPath()
ctx.arc(g.x, g.y, R, 0, Math.PI * 2)
ctx.stroke()
}
```length is the distance to the ghost ball, or 400 when nothing is in the way.stroke instead of fill draws only the outline of the circle.draw, at the top of if (state === 'aiming') {, write the g and length lines.lineTo line, replace both 400s with length.ctx.stroke(), write the if (g) block.Skills: Drawing on a canvas
← Predict the hit Where the hit ball goes →