I want to create a canvas element that changes the thickness of the border every 3 seconds, that has a thickness of line 5px starting, 3 seconds later has another thickness of 10px, after 3 seconds start again in thickness 5px. That is, it is in an infinite loop instead of border thickness. Any suggestions?
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.strokeStyle="red";
ctx.lineWidth=5;
ctx.strokeRect(20,20,100,100);
setTimeout(function() {
ctx.clearRect(20,20,100,100);
//ctx.strokeStyle="black";
ctx.lineWidth=10;
ctx.strokeRect(20,20,100,100);
}, 3000);