Leave the tiniest islands off the zoomed-out map
This commit is contained in:
parent
ac8b12ef17
commit
838ade2c8b
2 changed files with 15 additions and 2 deletions
|
|
@ -3360,7 +3360,11 @@ for(const t of [300,1000])setTimeout(()=>{resize();WL.key=null;},t);addEventList
|
|||
function rng(seed){return()=>{seed|=0;seed=seed+0x6D2B79F5|0;let t=Math.imul(seed^seed>>>15,1|seed);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};}
|
||||
function inPoly(x,y,pts){let ins=false;for(let i=0,j=pts.length-1;i<pts.length;j=i++){const [xi,yi]=pts[i],[xj,yj]=pts[j];if(((yi>y)!==(yj>y))&&(x<(xj-xi)*(y-yi)/(yj-yi)+xi))ins=!ins;}return ins;}
|
||||
function smoothPath(pts){const p=new Path2D();const n=pts.length;const mid=(a,b)=>[(a[0]+b[0])/2,(a[1]+b[1])/2];let m=mid(pts[n-1],pts[0]);p.moveTo(m[0],m[1]);for(let i=0;i<n;i++){const nx=pts[(i+1)%n];m=mid(pts[i],nx);p.quadraticCurveTo(pts[i][0],pts[i][1],m[0],m[1]);}p.closePath();return p;}
|
||||
const LANDP=COAST.map(smoothPath);
|
||||
const LANDP_ALL=COAST.map(smoothPath);
|
||||
// Zoomed out, hundreds of tiny Arctic and Pacific islets, each with a thick outline, turn into noise.
|
||||
// The far view skips islands smaller than ~600 map px² (Sardinia-sized) unless a city is on them.
|
||||
const ringArea=p=>{let a=0;for(let i=0,j=p.length-1;i<p.length;j=i++)a+=(p[j][0]+p[i][0])*(p[j][1]-p[i][1]);return Math.abs(a/2);};
|
||||
const LANDP_FAR=COAST.map((p,i)=>ringArea(p)>=600||CITIES.some(c=>inPoly(c.x,c.y,p))?LANDP_ALL[i]:null).filter(Boolean);
|
||||
const ALLPOLY=COAST;
|
||||
const onLand=(x,y)=>ALLPOLY.some(p=>inPoly(x,y,p));
|
||||
const R1=rng(7),WAVES=[],HILLS=[];
|
||||
|
|
@ -3520,7 +3524,7 @@ function draw(now){
|
|||
}
|
||||
function drawCone(x,y,now){const b=Math.sin(now/300)*1.5;ctx.save();ctx.translate(x,y-12+b);ctx.strokeStyle='#1E2640';ctx.lineWidth=2;ctx.fillStyle='#FF8A3D';ctx.beginPath();ctx.moveTo(-7,9);ctx.lineTo(0,-10);ctx.lineTo(7,9);ctx.closePath();ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.fillRect(-4,-1,8,3);ctx.fillStyle='#1E2640';rr(-10,8,20,4,2);ctx.fill();ctx.restore();}
|
||||
// Static land + cable map, rendered once per zoom bucket into an offscreen canvas.
|
||||
function paintWorld(c,z,withCables){
|
||||
function paintWorld(c,z,withCables){const LANDP=lodFar()?LANDP_FAR:LANDP_ALL;
|
||||
for(const o of [0,W,-W]){c.save();c.translate(o+5/z,7/z);c.fillStyle='rgba(20,90,130,.35)';for(const p of LANDP)c.fill(p);c.restore();}
|
||||
c.strokeStyle='#F8E6A8';c.lineWidth=10/z;c.lineJoin='round';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||||
c.fillStyle='#9BDA6C';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.fill(p);c.restore();}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue