Tengo una duda enorme

en su función draw() SOLO dibujará cuadrados si su posición esta dentro de un círculo con posición central de radio 100 pixels:

Dos métodos:

  • Generar la posición del cuadrado de forma aleatoria y luego “decidir” si pintarlo o no según la condición arriba indicada.

  • Generar la posición de forma aleatoria pero ya dentro del circulo permitido.

Mi duda es ¿como generar la posición aleatoria del cuadrado en el círculo de 100 pixels?

Hello,

and welcome to the processing forum! Great to have you here.

To find a random position use cos and sin and make a random angle and a random radius for it.

see https://www.processing.org/tutorials/trig

Chrisir


Okay chriseir hoy can write how yo put the ramdom rect un that ellipse

  rect(x,y, 
     12,12);

calculate x and y with cos and sin like explained in the link

I am sorry, we are not allowed to help with homework. It would be considered cheating you know.

We can help you but show your attempt.

Remark

At the moment I speak about : Generar la posición de forma aleatoria pero ya dentro del circulo permitido, not the first way.

For the first way: make a for loop (see reference: https://www.processing.org/reference/)
and generate x,y randomly (see random()). Check the distance to your center with the function dist() (see reference: https://www.processing.org/reference/).
If the dist is smaller than 100, draw the rect.

Chrisir