xxxxxxxxxx
43
let height = [];
let cols = 20; let rows = 20; let size = 10;
let xoff = 0; let yoff = 0; let inc = 0.05;
let zoff = 0;
function setup() {
createCanvas(400, 400, WEBGL);
angleMode(DEGREES);
}
function draw() {
background(220);
rotateX(-45);
rotateY(45);
xoff = 0;
for (let i=0; i<cols; i++){
height[i] = [];
yoff = 0;
for (let j=0; j<rows; j++){
height[i][j] = map(noise(xoff, yoff, zoff), 0, 1, 0, 300);
yoff += inc;
let r = noise(zoff) * 255;
let g = noise(zoff+15) * 255;
let b = noise(zoff+30) * 255;
fill(r, g, b);
// noStroke();
push();
let t = i*size - (cols*size)/2;
let f = j*size - (rows*size)/2;
translate(t, 0, f);
box(size, height[i][j], size);
pop();
}
xoff += inc;
zoff += 0.0003;
}
}