xxxxxxxxxx
50
let COLS = 20;
let ROWS;
let W, H;
let stems = [];
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
W = width*1.25 / COLS;
ROWS = height / W;
H = height*1.25 / ROWS;
console.log(W, H);
for (let col = 0; col < COLS; col++) {
let x = col * W;
for (let row = 0; row < ROWS; row++) {
let y = row * H;
stems.push(new Stem(x, y));
}
}
}
let a = 0;
function draw() {
stroke(255, a);
fill('red');
a+= 0.1;
//rotateY(PI / 2);
translate(-width/1.75, -height/1.75, -100);
for (let stem of stems) {
stem.grow();
push()
translate(stem.x, stem.y, 0);
box(W, H, stem.depth);
pop();
}
}
class Stem {
constructor(x, y) {
this.x = x;
this.y = y;
this.depth = 0;
this.rate = random(1, 5);
}
grow() {
this.depth += pow(0.1, this.rate);
}
}