Hi again,
found a few minutes to go on and re-build the example from the insta link with also the heights included.
// class representing a cell
class Cell {
PVector p;
PVector s;
float v;
public Cell() {
p = new PVector();
s = new PVector();
v = 0;
}
void updateValue(float pv) {
v = pv;
}
void updateBoxes(Cell l, Cell t, float sx, float syh) {
s.x=v*sx;
s.y=syh;
p.x = l != null ? l.p.x+l.s.x : 0;
p.y = t != null ? t.p.y+t.s.y : 0;
}
public void render() {
stroke(0);
fill(map(v, 0, 1, 0, 255));
rect(p.x, p.y, s.x, s.y);
}
}
// main sketch
float scl = 15.;
int rows;
int cols;
Cell[][] grid;
float zVal = 0;
float zShift = 0.03;
void setup() {
size(600, 600);
rows = floor(height/scl);
cols = floor(width/scl);
grid= new Cell[rows][cols];
for (int y = 0; y < rows; y++) {
for (int x = 0; x < cols; x++) {
grid[y][x] = new Cell();
}
}
}
void draw() {
background(0);
// update values
for (int y = 0; y < rows; y++) {
for (int x = 0; x < cols; x++) {
grid[y][x].updateValue(noise(x*0.05, y*0.05, zVal));
}
}
zVal+=zShift;
// determine ScalingFactor for each row height and col width
float[] xfact = new float[rows];
float[] yfacth = new float[rows];
float yfact = 0;
float vmax = 0;
for (int y = 0; y < rows; y++) {
vmax = 0;
float vmaxh = 0;
for (int x = 0; x < cols; x++) {
vmax += grid[y][x].v;
if (vmaxh < grid[y][x].v) {
vmaxh = grid[y][x].v;
}
}
xfact[y] = width/vmax;
yfacth[y] = vmaxh;
}
vmax=0;
for (int y = 0; y < rows; y++) {
vmax += yfacth[y];
}
yfact = height/vmax;
// update boxes and render
for (int y = 0; y < rows; y++) {
for (int x = 0; x < cols; x++) {
Cell l = x>0 ? grid[y][x-1] : null;
Cell t = y>0 ? grid[y-1][x] : null;
grid[y][x].updateBoxes(l, t, xfact[y], yfacth[y] * yfact);
grid[y][x].render();
}
}
}
Have fun!
— mnse
PS: short vid as demo