画像データ引用元
国土地理院 地球地図全球版
引用元の地球地図全球版 標高をworld.pngで保存して下の画像をhi.pngで保存が必要です。
hi.png
PImage img; PImage himg; int wx=373; int wy=186; int ws=373*186; int[] cp = new int[40]; int[] cr = new int[40]; int[] cg = new int[40]; int[] cb = new int[40]; int cn; //int hi[] = {-1500,-1000,-500,-300,-100,-80,-60,-40,-20,-10,0,20,40,60,80,100,125,150,175,200,225,250,275,300,350,400,450,500,600,700,800,900,1000,1500,2000,3000,4000,5000,6000,7000}; int hi[] = {-20,-20,-20,-20,-20,-20,-20,-20,-20,-10,0,20,40,60,80,100,125,150,175,200,225,250,275,300,350,400,450,500,600,700,800,900,1000,1500,2000,3000,4000,5000,6000,7000}; int[] hland = new int[ws]; float ty; float t=0; int px=180; int py=150; int pt;//muki int ph=2000;//height int sc=1000; void theWorld2(){ int tm=millis(); int el=1400; int eh=10000; float ez; float ex; int ep; int hwix=700; int hwiy=200; int mx; int my; float cot=cos(t); float sit=sin(t); for (int y=3;y<500;y=y+2){ ez=el*eh/y; for (int x=0;x<1400;x=x+2){ ex=(x-hwix)*ez/el; int tx=(int)(ex*cot-ez*sit)/sc; int ty=(int)(ex*sit+ez*cot)/sc; mx=px+tx; if (mx<-wx*0.5 || mx>=wx*1.5) continue; my=py-ty; ep=mx+my*wx; if (ep<0 || ep>=ws) continue; int h=(int)(hland[ep]*5/(sqrt(tx*tx+ty*ty))); fill(img.pixels[ep]); rect(x,y+hwiy-h,2,h); } } text(millis()-tm,10,10); } void setup() { size(1400, 700); img = loadImage("world.png"); himg = loadImage("hi.png"); noStroke(); cn=0; for (int i=20;i<420;i=i+10){ int c=himg.pixels [i+40*421]; int r=(int)red(c); int g=(int)green(c);//& 0xf0; int b=(int)blue(c);// & 0xf0; c=color(r,g,b); int sw=0; for (int j=0;j<cn;j=j+1){ if (c==cp[j]){ sw=1; break; } } if (sw==0){ cp[cn]=c; cr[cn]=r; cg[cn]=g; cb[cn]=b; println(c); cn=cn+1; } } cn=cn-1; for (int i=0;i<ws-1;i=i+1){ int c=img.pixels [i]; int r=(int)red(c); int g=(int)green(c); int b=(int)blue(c); int bs=10000; int bh=0; for (int j=0;j<cn;j=j+1){ int s=abs(r-cr[j])+abs(g-cg[j])+abs(b-cb[j]); if (s<bs){ bs=s; hland[i]=hi[j]+160; } } } } void draw() { background(0); ty=sin(t)*3+1; t=t+0.01; theWorld2(); px=px+1; if (px>wx){ px=0; py=(int)random(wy-40)+20; } }