I am trying to create a slider which lets me resize the circle, by changing the radius. I can set the radius once, but it doesn't respond when the slider changes.
You can review the code here: https://codepen.io/ydunga/pen/MWbYoKB
<canvas id = "canvas1" style = "background-color: yellow" height = "200" iwdth = "500"></canvas>
radius: <input id = "radius" type = "number" min = "0" max = "50" value = "15" oninput = "draw();">
var can1 = document.getElementById("canvas1");
var ctx1 = can1.getContext("2d");
let radius = document.getElementById('radius').value
function draw() {
ctx1.clearRect(0,0,200,500);
ctx1.beginPath();
ctx1.arc(50,50, radius, 0, 2*Math.PI);
ctx1.fillStyle = "red";
ctx1.fill();
}
draw()