parent
9d53436cb7
commit
31372c0205
2 changed files with 22 additions and 1 deletions
|
|
@ -1366,12 +1366,16 @@ function traceModal(src,to){const pops=Object.keys(S.pops).sort((a,b)=>CITY[a].n
|
|||
<div class="btns">${btn(tr('Copy'),'traceCopy',{},'ghost sm')}</div>`);UI.trText=r.text;}
|
||||
|
||||
/* ---------- share card ---------- */
|
||||
// Straight link segments in map coordinates for flat maps. A link across the date line leaves one edge
|
||||
// and comes back in at the other, so it becomes two segments, one per edge (#42).
|
||||
function linkSegs(){const out=[];for(const l of S.links){const A=CITY[l.a],B=CITY[l.b];if(!A||!B)continue;const d=Math.abs(B.x-A.x)>W/2?(B.x<A.x?W:-W):0;
|
||||
for(const o of d?[0,-d]:[0])out.push([A.x+o,A.y,B.x+d+o,B.y]);}return out;}
|
||||
function shareCanvas(){const Wc=1200,Hc=630,cv=document.createElement('canvas');cv.width=Wc;cv.height=Hc;const g=cv.getContext&&cv.getContext('2d');if(!g)return null;
|
||||
g.fillStyle='#57C4E5';g.fillRect(0,0,Wc,Hc);
|
||||
// mini map
|
||||
const mx=40,my=150,mw=700,mh=350,sx=mw/W,sy=mh/H;g.save();g.beginPath();g.rect(mx,my,mw,mh);g.clip();g.fillStyle='#3AA6CF';g.fillRect(mx,my,mw,mh);
|
||||
g.fillStyle='#9BDA6C';g.strokeStyle='#1E2640';g.lineWidth=1.5;for(const pts of COAST){g.beginPath();pts.forEach((q,i)=>i?g.lineTo(mx+q[0]*sx,my+q[1]*sy):g.moveTo(mx+q[0]*sx,my+q[1]*sy));g.closePath();g.fill();g.stroke();}
|
||||
g.strokeStyle='#FF4F9A';g.lineWidth=2.5;for(const l of S.links){const A=CITY[l.a],B=CITY[l.b];let bx=B.x;if(Math.abs(bx-A.x)>W/2)bx+=bx<A.x?W:-W;g.beginPath();g.moveTo(mx+A.x*sx,my+A.y*sy);g.lineTo(mx+bx*sx,my+B.y*sy);g.stroke();}
|
||||
g.strokeStyle='#FF4F9A';g.lineWidth=2.5;for(const [x1,y1,x2,y2] of linkSegs()){g.beginPath();g.moveTo(mx+x1*sx,my+y1*sy);g.lineTo(mx+x2*sx,my+y2*sy);g.stroke();}
|
||||
for(const c in S.pops){const C=CITY[c];g.fillStyle='#FF4F9A';g.strokeStyle='#1E2640';g.lineWidth=2;g.beginPath();g.arc(mx+C.x*sx,my+C.y*sy,5,0,7);g.fill();g.stroke();}
|
||||
g.restore();g.strokeStyle='#1E2640';g.lineWidth=5;g.strokeRect(mx,my,mw,mh);
|
||||
// header
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue