grid of boxes with random sizes..
in
Contributed Library Questions
•
2 years ago
Hello,
I am trying to build a grid of boxes, which i can view in 3d with peasy cam.. My problem is that I would like to have random sizes, but only with a trigger every time I want and not in a loop.. To use peasy cam you need to update the boxes inside draw() but how can I use a random function outside side the loop, so the random sizes can be fixed after a random trigger? As you can see in the following code, the size is constanlty changing within a loop..
Thank you in advance!!
import processing.opengl.*;
import peasy.*;
PeasyCam cam;
void setup() {
size(800, 800, OPENGL);
noStroke();
cam = new PeasyCam(this, 1800);
cam.setMinimumDistance(10);
cam.setMaximumDistance(1800);
}
void draw() {
lights();
background(0);
translate(0, 0, 0);
for (int x = 0; x <= width; x += 120) {
for (int y = 0; y <= height; y += 120) {
pushMatrix();
translate(x, y);
box(30,30,random(0.2,50));
popMatrix();
}
}
}
1