I have to generate a rectangle inside a canvas of 600 px * 600 px, every time I reload the page it should appear in a different position, but it should always appear in locations that are multiples of 25, for example, it will never appear in (120,130) or (480,15). I had this but it's not working
function randomPosition(min, max) {
return Math.round(Math.random() * (max - min + 1)) + min;
}
I also used this but sometimes the rectangle doesn't appear inside the canvas
function randomPosition(min, max) {
return Math.round(Math.random()* 10) * 25;;
}
Aucun commentaire:
Enregistrer un commentaire