For the figure to change color every time it is generated again, it is suggested to create a "var color" arrangement with at least 5 colors. Then create a variable that allows you to generate a random number between 0 and the length of the array minus 1. Also, for the figure with fill to change color, instead of using " ctx.strokeStyle
" you must use " ctx.fillStyle
". (JavaScript)
var color = ["Red", "Blue", "Orange", "Yellow", "Green"];
var randcolor = color[Math.floor(Math.random() * color.length)-1];
ctx.fillStyle = "";
I need if someone can check the syntax, and if you can tell me how I can do so that ctx.fillStyle use randcolor. Thanks