I'm trying to replicate the animated icon that mapbox has here https://docs.mapbox.com/mapbox-gl-js/example/add-image-animated/
Except I want to have an image for the inner circle.
So far I can get fairly close by using a create pattern as above. But the image is repeating instead of being centered in the inner circle.
How can I have my image cropped and centered in the inner circle ?
// Copy pasta from mapbox example ...
// Draw the outer circle.
context.clearRect(0, 0, this.width, this.height)
context.beginPath()
context.arc(this.width / 2, this.height / 2, outerRadius, 0, Math.PI * 2)
context.fillStyle = `hsl(46deg 85% 67% / ${1 - t})`
context.fill()
// Draw the inner circle.
context.beginPath()
context.arc(this.width / 2, this.height / 2, radius, 0, Math.PI * 2)
// I've added this
const pattern = context.createPattern(image, 'repeat')
context.fillStyle = pattern
// I've tried this but the image isn't cropped and isn't centered.
// context.drawImage(image, this.width / 2, this.height / 2, 150, 150)
context.strokeStyle = 'white'
context.lineWidth = 2 + 4 * (1 - t)
context.fill()
context.stroke()

