Writing a function is fine but your drawQuad function always draw a quad with a pink color with the provided coordinates. This is the same as calling quad directly after setting the fill color.
You want to do something multiple times. You guessed right: you have to use a loop.
The thing is that in your for loop, you are only calling your drawQuad function and therefore the x1, x2… coordinates never change, they are the same as the first time you assigned them to a random value.
You want a random quad each time so how about you try to move the variables initialization in the for loop?
You are right, in other post about positions they gave me a solution for shapes, but actually I am talking about another thing. Maybe I should open another chat to explain It better.
The reason they cross is because of the order of vertices its expecting. When you look up quad() or beginShape() you’ll see that they are expecting the points (vertex/vertices) of the polygon to come in a certain order, namely clockwise or anticlockwise:
It was the reason for example to use the trigonometry approach in the other thread, increasing the angle to find the x and y coordinates of the 4 corners using cos/sin. If you do it that way, the four corner vertices will always be in the right (counter) clockwise order.