T
T
Triborg-3332019-08-30 00:48:39
JavaScript
Triborg-333, 2019-08-30 00:48:39

How on ctx.fillStyle to make random colors on push?

Hello =) how to make random colors on push on ctx.fillStyle?

for(let i = 0; i < this.eat.length; i++){
  ctx.beginPath();
  ctx.arc(this.eat[i].x, this.eat[i].y, 10, 0, 2*Math.PI, false); 
  ctx.fillStyle = '#89E604' ; <----- Поставить рандомный цвет.
  ctx.fill();
  ctx.lineWidth = 3;
  ctx.strokeStyle = '#89E604';
  ctx.stroke();
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RAX7, 2019-08-30
@Triborg-333

ctx.fillStyle = '#' + (Math.random() * Math.pow(256, 3) | 0).toString(16).padStart(6, '0');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question