const canvas=document.querySelector('#film'),ctx=canvas.getContext('2d'); const clamp=x=>Math.max(0,Math.min(1,x)),ease=x=>1-Math.pow(1-clamp(x),3); function text(s,x,y,size=30,color='#edf1e9',align='left',weight=400){ctx.fillStyle=color;ctx.font=`${weight} ${size}px Arial, Microsoft YaHei`;ctx.textAlign=align;ctx.fillText(s,x,y)} function box(x,y,w,h,r=16,fill='#1a241e',stroke='#374734'){ctx.beginPath();ctx.roundRect(x,y,w,h,r);ctx.fillStyle=fill;ctx.fill();if(stroke){ctx.strokeStyle=stroke;ctx.stroke()}} function line(x,y,x2,y2,color='#d5f883',width=2){ctx.beginPath();ctx.moveTo(x,y);ctx.lineTo(x2,y2);ctx.strokeStyle=color;ctx.lineWidth=width;ctx.stroke()} function orbit(t,cx,cy,r){ctx.strokeStyle='#596b45';ctx.lineWidth=1;for(let j=0;j<3;j++){ctx.save();ctx.translate(cx,cy);ctx.rotate(j*1.04+t*.16);ctx.beginPath();ctx.ellipse(0,0,r,r*.36,0,0,Math.PI*2);ctx.stroke();ctx.restore()}for(let j=0;j<6;j++){let a=t*.3+j*1.047;ctx.fillStyle=j%2?'#d5f883':'#73c9b7';ctx.beginPath();ctx.arc(cx+Math.cos(a)*r,cy+Math.sin(a)*r*.65,5,0,7);ctx.fill()}} function draw(t){ctx.clearRect(0,0,1280,720);let g=ctx.createLinearGradient(0,0,1280,720);g.addColorStop(0,'#111911');g.addColorStop(1,'#080e16');ctx.fillStyle=g;ctx.fillRect(0,0,1280,720);ctx.globalAlpha=.2;for(let x=0;x<1280;x+=64)line(x,0,x,720,'#405142',1);for(let y=0;y<720;y+=64)line(0,y,1280,y,'#405142',1);ctx.globalAlpha=1; text('◈ VISUAL ATLAS',70,64,19,'#d5f883','left',700);text('LOCAL PRODUCTION / 006',1210,64,13,'#9ba99b','right');let chapter=Math.min(4,Math.floor(t/5));let local=t-chapter*5;let enter=ease(local/.8);ctx.save();ctx.globalAlpha=enter;ctx.translate(0,24*(1-enter)); if(chapter===0){text('想法有了,',75,255,68,'#edf1e9','left',700);text('效果在哪里?',75,347,68,'#d5f883','left',700);text('从一句描述,到可以看见的作品。',78,420,26,'#a6b6a5');orbit(t,990,350,180);text('IDEA',990,338,23,'#a6b6a5','center');text('→ EFFECT',990,383,35,'#d5f883','center',700)} else if(chapter===1){text('10 个项目,4 个创作方向。',70,175,48,'#edf1e9','left',700);const labels=['视频与动画','3D 游戏','创作工具','灵感与资料'];labels.forEach((s,i)=>{let k=ease((local-i*.18)/.65);ctx.globalAlpha=k;box(70+i*300,265+(1-k)*30,276,250);text(String(i+1).padStart(2,'0'),95+i*300,310,16,'#d5f883');text(s,95+i*300,381,28,'#edf1e9','left',700);text(['叙事 · 角色 · 风格','实时图形 · 可玩互动','音乐 · 产品 · 动效','案例 · 来源 · 提示词'][i],95+i*300,439,15,'#a6b6a5')})} else if(chapter===2){text('先看效果,再选择工具。',70,175,48,'#edf1e9','left',700);box(75,240,710,330,18,'#0d1613');for(let i=0;i<24;i++){let x=100+i*27,y=450-Math.sin(i*.35+t*1.7)*65;line(x,500,x,y,'#73c9b7',9)}text('LOCAL EFFECT SHOWROOM',110,291,17,'#d5f883');text('视频 · 动图 · 实时游戏',110,550,21,'#a6b6a5');['本地播放','切换风格','观察实际画面'].forEach((s,i)=>{box(830,250+i*103,370,80);text('0'+(i+1),853,298+i*103,16,'#d5f883');text(s,905,298+i*103,25)})} else if(chapter===3){text('不止看见,还要看懂。',70,175,48,'#edf1e9','left',700);['输入内容','生成代码','绘制画面','导出视频'].forEach((s,i)=>{let x=75+i*300;box(x,285,245,150);text('0'+(i+1),x+25,324,14,'#d5f883');text(s,x+25,380,30);if(i<3)text('→',x+265,374,35,'#d5f883')});text('每个项目:能力、原理、依赖与边界。',75,517,27,'#a6b6a5')} else {orbit(t,1040,360,155);text('让创作能力,',75,278,66,'#edf1e9','left',700);text('变成可见的效果。',75,370,66,'#d5f883','left',700);box(78,430,360,62,9,'#d5f883',null);text('打开视觉创作能力图谱 →',100,469,22,'#18220e','left',700);text('研究入口 · 效果展厅 · 制作原理',80,560,21,'#a6b6a5')} ctx.restore();ctx.globalAlpha=1;ctx.fillStyle='#d5f883';ctx.fillRect(0,712,1280*clamp(t/24),8);text(String(chapter+1).padStart(2,'0')+' / 05',1210,670,14,'#9ba99b','right');window.__currentTime=t;} window.__seek=t=>draw(t);window.__duration=24;draw(0);let running=false,start=0,base=0;const seek=document.querySelector('#seek'),play=document.querySelector('#play');function tick(now){if(running){let t=Math.min(24,base+(now-start)/1000);draw(t);seek.value=t;document.querySelector('#time').textContent=t.toFixed(1)+' / 24s';if(t>=24){running=false;play.textContent='重新播放'}else requestAnimationFrame(tick)}}play.onclick=()=>{running=!running;play.textContent=running?'暂停动画':'播放动画';if(running){base=Number(seek.value);if(base>=24)base=0;start=performance.now();requestAnimationFrame(tick)}};seek.oninput=()=>{base=Number(seek.value);start=performance.now();draw(base);document.querySelector('#time').textContent=base.toFixed(1)+' / 24s'}; // Local research-page bridge: only the same-origin parent may seek the film. window.addEventListener('message',event=>{ if(event.origin!==window.location.origin||event.source!==window.parent)return; if(event.data?.type!=='atlas-film-seek'||!Number.isFinite(event.data.seconds))return; running=false;play.textContent='播放动画'; base=Math.max(0,Math.min(24,event.data.seconds));seek.value=base; draw(base);document.querySelector('#time').textContent=base.toFixed(1)+' / 24s'; });