This commit is contained in:
33333-33333 2026-09-29 19:10:03 +09:00
commit 01204dfa2f
34 changed files with 1498 additions and 0 deletions

3
terrain.js Normal file
View file

@ -0,0 +1,3 @@
import {GW,GH} from './engine.js';
const stops=[[0,105,89,59],[.32,103,113,61],[.68,72,108,48],[1,41,80,40]];
export function paintTerrain(tc,state,layer){const im=tc.createImageData(GW,GH);for(let i=0;i<GW*GH;i++){let r,g,b;if(layer==='moisture'){const m=state.moisture[i];r=23+m*26;g=43+m*80;b=44+m*101}else{const p=Math.min(1,state.plants[i]/.5);let k=0;while(k<2&&p>stops[k+1][0])k++;const lo=stops[k],hi=stops[k+1],f=(p-lo[0])/(hi[0]-lo[0]);r=lo[1]+(hi[1]-lo[1])*f;g=lo[2]+(hi[2]-lo[2])*f;b=lo[3]+(hi[3]-lo[3])*f}const j=i*4;im.data[j]=r;im.data[j+1]=g;im.data[j+2]=b;im.data[j+3]=255}tc.putImageData(im,0,0)}