what I think the problem I am having is that when animating, the canvas is not clearing when the radius of the circle is decreasing.
The ironical part is that it works perfectly when the radius of the circle is increasing and I can see the circle is growing big on canvas but it stops animating when it starts decreasing. I did console.log and technically the numbers are decreasing fine but I can not see it animated
const canvas = document.querySelector('canvas')
const c = canvas.getContext('2d')
canvas.width = window.innerWidth
canvas.height = window.innerHeight
let radius = 50
let dx = 5
function animate(){
c.clearRect(0, 0, canvas.width, canvas.height)
c.fillStyle = "pink"
c.arc(canvas.width/2, canvas.height/2, radius, 0, Math.PI * 2,
true)
c.fill()
radius += dx
if( radius * 2 > canvas.width || radius * 2 < 10) {
dx = -dx
}
requestAnimationFrame(animate)
}
animate()