JSFiddle - React, Tailwind, and code Playground
JavaScript
function newColor()
{
var color = '#'+Math.floor(Math.random()*16777215).toString(16);
ctx.strokeStyle = color;
}
function drawCircle()
{
t += 0.05;
if (changeColor)
{
changeColor = false;
newColor();
}
ctx.beginPath();
ctx.moveTo(x,y);
getPosition(t);
newColor();
ctx.lineTo(x,y);
ctx.stroke();
ctx.endPath();
}