I am trying to make a bowl shape and its content would gradually show as we go over it from bottom to top (and vice versa). here is my code for the bowl and the static filling.
I am new to canvas and to js animation.
Does anyone have an idea and can help me? Thank you :)
const canvas = document.createElement('canvas')
document.body.appendChild(canvas)
canvas.width = 800
canvas.height = 500
const ctx = canvas.getContext('2d')
ctx.fillStyle = 'white'
ctx.fillRect(0, 0, 800, 500)
const bowl = new Path2D()
bowl.arc(400, 390, 100, 0, Math.PI)
ctx.stroke(bowl)
ctx.moveTo(300,390)
ctx.lineTo(500,390)
ctx.stroke()
const fluid = new Path2D()
fluid.arc(400, 391, 99, 0, Math.PI)
ctx.fillStyle = 'red'
ctx.fill(fluid)