Need to do such a thing. Suppose there is an array, in it one of the elements (int) is responsible for the color of drawing primitives on the canvas . In a javascript loop, this array is drawn:
for(var i = 0; i < obj.length; i++) { screen.fillStyle = obj[i].col;//как это сделать? scree это контекст canvas. fillStyle принимает что-то типа '#124578' или 'rgb(12,12,12)' screen.fillRect(obj[i].x, obj[i].y, obj[i].width, obj[i].height); } I have not the slightest idea how to implement it, but I really need it!
transferred from the “answer”:
let's assume in the variable i some difference between the color of the displayed objects.
screen.fillStyle = 'rgb('+i*60+', 20, '+i*45+')';