
Processing 3.5.4 java:
A code to plot the Earth
int rows, cols;
int w = 1600;
int h = 2200;
int scl;
float[][] land;
float forward = 0;
void setup(){
size(600, 800, P3D);
frameRate(30);
scl = 20;
rows = h/scl;
cols = w/scl;
}
void draw(){
forward -= 0.1;
float y_ = forward;
land = new float[cols][rows];
for (int y = 0; y < rows; y++){
float x_ = 0;
for (int x = 0; x < cols; x++){
land[x][y] = map(noise(x_,y_), 0, 1, -80, 170);
x_ += 0.1;
}
y_ += 0.1;
}
background(0);
translate(width/2, height/2 + 100);
rotateX(PI/3.2);
translate(-w/2, -h/2);
for (int y = 0; y < rows-1; y++){
beginShape(TRIANGLE_STRIP);
for (int x = 0; x < cols; x++){
if (land[x][y] > 80) {
fill(255);
}
else if (land[x][y] > 50) {
fill(#567d46);
}else if (land[x][y] > 30) {
fill(#FFFF00);
}
else{
fill(0, 0, 190);
}
vertex(x*scl, y*scl, land[x][y]);
vertex(x*scl, (y+1)*scl, land[x][y+1]);
}
endShape();
}
saveFrame();
}
