Skip to content

Instantly share code, notes, and snippets.

@n1ckfg
Forked from rors/code-toolkit-2021-welcome.py
Last active December 29, 2021 22:16
Show Gist options
  • Save n1ckfg/adbecc8f550e91bce2c7443ef6fceb11 to your computer and use it in GitHub Desktop.
Save n1ckfg/adbecc8f550e91bce2c7443ef6fceb11 to your computer and use it in GitHub Desktop.
Homepage image for "Code Toolkit: Python", Fall 2021
let heights = [];
let moving_heights = [];
let r = 0;
function setup() {
createCanvas(800, 400, WEBGL);
for (let i=0; i<17; i++) {
heights.push([]);
moving_heights.push([]);
for (let j=0; j<17; j++) {
heights[i].push(random(-150,110));
moving_heights[i].push(150);
}
}
smooth();
stroke(100);
//textMode(SHAPE);
}
function draw() {
background(55);
rotateX(-r);
rotateY(-r);
if (millis() > 1500) {
r += (PI / 16 - r) * 0.01;
}
translate(-400,-400);
for (let i=0; i<16; i++) {
for (let j=0; j<16; j++) {
//stroke(0);
push();
fill(200);
translate(i * 50, j * 50, moving_heights[i][j]);
beginShape();
vertex(0,0,0);
vertex(50,0,0);
vertex(50,50,0);
vertex(0,50,0);
endShape(CLOSE);
fill(255,220,220,50);
beginShape();
vertex(0,50,0);
vertex(50,50,0);
vertex(50,50,moving_heights[i][j+1] - moving_heights[i][j]);
vertex(0,50,moving_heights[i][j+1] - moving_heights[i][j]);
endShape(CLOSE);
fill(200,200,255,100);
beginShape();
vertex(50,0,0);
vertex(50,50,0);
vertex(50,50,moving_heights[i+1][j] - moving_heights[i][j]);
vertex(50,0,moving_heights[i+1][j] - moving_heights[i][j]);
endShape(CLOSE);
pop();
moving_heights[i][j] += (heights[i][j] - moving_heights[i][j]) * 0.005;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment