Skip to content

The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.

15.8 KB
Raw Blame
function w3Panel(x,y,w,h,dark=false){saved(()=>{ctx.shadowColor='#0002';ctx.shadowBlur=20;rect(x,y,w,h,dark?'#1c2027':'#fff',12)});rect(x,y,w,24,dark?'#2a2e35':'#eff0ed',12);[0,1,2].forEach(i=>ellipse(x+14+i*12,y+12,3,3,['#da8171','#dbb76c','#82ad84'][i]));}
function w3TextRows(x,y,w,n=5,dark=false){for(let i=0;i<n;i++)rect(x,y+i*23,w*(.62+rand(i)*.38),5,dark?'#a3a8b555':'#a5aaa755',2)}
function w3Title(t){fittedText(P.title,500,100,40,CONFIG.palette[1],900,CONFIG.brand==='Perplexity'?'Georgia':'Arial',500);}
function w3Arrow(x,y,xx,yy){line(x,y,xx,yy,P.accent,2);const a=Math.atan2(yy-y,xx-x);poly([[xx,yy],[xx-12*cos(a-.5),yy-12*sin(a-.5)],[xx-12*cos(a+.5),yy-12*sin(a+.5)]],P.accent)}
function w3Chip(v,x,y,w=150,c=P.accent,fg='#fff'){rect(x,y,w,36,c,8);text(v,x+w/2,y+18,15,fg,'center','Arial',500,w-14)}
function w3Diagram(t){const n=stageAt(t),u=stageProgress(t),m=CONFIG.mechanism,fg=CONFIG.palette[1],dark=['local','network','tilted','diff','mobile','schedule','tooltip'].includes(m)&&CONFIG.palette[0][1]==='0'||CONFIG.palette[0]==='#121511'||CONFIG.palette[0]==='#111611'||CONFIG.palette[0]==='#131213';
 if(m==='portal'){const d=CONFIG.duration;let z=t<d*.32?ease(t/(d*.32)):t>d*.67?1-ease((t-d*.67)/(d*.25)):1;let w=mix(140,1000,z),h=mix(330,600,z);saved(()=>{ctx.beginPath();ctx.roundRect(500-w/2,300-h/2,w,h,mix(70,0,z));ctx.clip();gradient('#061321',P.accent);for(let i=0;i<28;i++)glow(500+sin(i*1.9+t*.08)*410,300+cos(i*.77+t*.05)*250,65+rand(i)*100,i%2?'#997d9d66':'#6091b655');for(let i=0;i<80;i++)ellipse(rand(i+100)*1000,rand(i+500)*600,1,1,'#fff8')});text(P.title,500,38,18,z>.6?'#fff':fg);return;}
 if(m==='orbit'){bg('#050608');at(500,310,1,-.14,()=>{for(let j=0;j<3;j++){let rx=190+j*72,ry=90+j*40;ellipse(0,0,rx,ry,null,'#7b828555');for(let i=0;i<72;i++){let a=i*TAU/72;line(cos(a)*rx,sin(a)*ry,cos(a)*(rx+9),sin(a)*(ry+5),'#73808b55')}let a=t*.24+j*2;ellipse(cos(a)*rx,sin(a)*ry,4,4,'#fff');glow(cos(a)*rx,sin(a)*ry,24,'#ffffff55')};CONFIG.stages.slice(0,5).forEach((s,i)=>{let a=i*TAU/5;label(s.label,cos(a)*275-30,sin(a)*145,'#bdc3c9')})});w3Title(t);return;}
 if(m==='outline'){grid('#88888818',35);saved(()=>{ctx.translate(500,290);ctx.scale(mix(1.8,1,phase(t,0,CONFIG.duration*.55)),1);ctx.font='700 110px Arial';ctx.textAlign='center';ctx.strokeStyle='#242422';ctx.lineWidth=1;ctx.setLineDash([900*phase(t,0,CONFIG.duration*.6),1000]);ctx.strokeText(P.title,0,0);ctx.setLineDash([]);alpha(phase(t,CONFIG.duration*.52,CONFIG.duration*.63),()=>text(P.title,0,0,110,'#151515','center','Arial',700,800))});if(t>CONFIG.duration*.74)w3Chip(CONFIG.stages[n].label,400,410,200);return;}
 if(m==='pixels'){bg('#010407');const zoom=mix(1.7,.32,phase(t,0,CONFIG.duration*.48)),cell=65*zoom;for(let y=-2;y<Math.ceil(H/cell);y++)for(let x=-2;x<Math.ceil(W/cell);x++){for(let c=0;c<3;c++){let xx=x*cell+c*cell*.3,yy=y*cell;let col=['#ff183b','#20ef28','#144cff'][c];alpha(clamp(t*2-rand(x+y*22+c)*2),()=>{saved(()=>{ctx.shadowColor=col;ctx.shadowBlur=0;rect(xx,yy,cell*.23,cell*.66,col,cell*.05)})})}}if(t>CONFIG.duration*.45){alpha(phase(t,CONFIG.duration*.45,CONFIG.duration*.65),()=>{rect(80,70,840,460,'#080b0c');for(let j=0;j<3;j++)saved(()=>{ctx.translate(330+j*145,160+j*18);ctx.transform(1,-.2,.15,1,0,0);rect(0,0,260,300,'#363a3f',12);gradient(P.accent,['#d74072','#486de0','#4cba9e'][j],5,5,250,290)})})}text(P.title,500,530,28,'#fff');return;}
 if(m==='poster'){const metric=CONFIG.stages[n].label;const value=/收入/.test(metric)?(CONFIG.templateId==='V102'?'370M':'333M'):/增长|同比/.test(metric)?(CONFIG.templateId==='V102'?'48%':'46%'):/留存/.test(metric)?(CONFIG.templateId==='V102'?'136%':'139%'):/宣言/.test(metric)?'Design':P.title;for(let j=0;j<4;j++){let x=j*250+sin(t*.6+j)*10;rect(x,130+(j%2)*30,265,390,CONFIG.palette[(j+2)%CONFIG.palette.length]);}saved(()=>{ctx.translate(500,330);ctx.rotate(-.025);fittedText(value,0,0,180,'#181818',940,'Arial',800)});rect(0,520,1000,80,'#fff');text(metric,40,550,20,'#333','left');text(P.title,960,550,18,P.accent,'right');return;}
 if(m==='loading'){bg('#000');const u=t/CONFIG.duration;let appear=phase(t,0,CONFIG.duration*.4)*(1-phase(t,CONFIG.duration*.7,CONFIG.duration*.92));P.title.split('').slice(0,18).forEach((c,i)=>{let x=500+(i-(Math.min(P.title.length,18)-1)/2)*44;at(x,280+sin(i*3+t*4)*(1-appear)*50,1,(1-appear)*sin(i+t)*1.5,()=>alpha(appear,()=>text(c,0,0,40,'#fff','center','Arial',800)))});rect(330,340,340,4,'#333');rect(330,340,340*u,4,P.accent);return;}
 if(m==='dock'||m==='collab'||m==='collage'){let final=phase(t,CONFIG.duration*.7,CONFIG.duration*.87);const cnt=m==='collab'?6:9;for(let i=0;i<cnt;i++){let x=m==='dock'?500+(i-4)*110-((t*45)%110):500+cos(i*TAU/cnt)*330,y=m==='dock'?300:340+sin(i*TAU/cnt)*130; x=mix(x,500,final);y=mix(y,300,final);alpha(1-final*.8,()=>{rect(x-35,y-35,70,70,CONFIG.palette[1+i%(CONFIG.palette.length-1)],18);text(['✦','◇','●','↗','◎'][i%5],x,y,35,'#202020');if(m==='collab')w3Chip(['Let’s make','Ready','Looks good'][i%3],x-40,y+40,130,CONFIG.palette[1+i%(CONFIG.palette.length-1)],'#202020')})}alpha(final,()=>simpleMark(500,300,1.4));w3Title(t);return;}
 if(m==='branches'){bg('#08090b');for(let i=0;i<14;i++){let y=80+i*34;ctx.strokeStyle='#8b909077';ctx.lineWidth=1;ctx.beginPath();ctx.moveTo(90,y);ctx.bezierCurveTo(380,y,550,300,900,300);ctx.stroke();let a=frac(t*.08+i/14);let x=mix(90,900,a),yy=mix(y,300,ease(a));ellipse(x,yy,2,2,P.accent);label('ISSUE-'+(120+i),100,y-8,'#9d9fa2')}w3Title(t);return;}
 if(m==='fold'){let z=phase(t,0,1.9),width=mix(245,700,z);w3Panel(500-width/2,135,width,370);rect(510-width/2,165,width*.3,320,'#efefea',8);w3TextRows(525-width/2,185,width*.23,10);text(P.title,500-width/2+width*.45,190,24,'#222','left','Arial',600,width*.5);saved(()=>{ctx.beginPath();ctx.rect(500-width/2+width*.34,220,width*.64,275);ctx.clip();w3TextRows(500-width/2+width*.39,235-Math.max(0,t-3)*15,width*.51,16)});if(t>7)rect(500-width/2+width*.32,390,width*.66,105,'#c6c8cd',10);return;}
 if(m==='tooltip'){text('Status',210,220,22,'#8c8e95','left');ellipse(225,290,8,8,P.accent);text(P.title,255,290,28,fg,'left');rect(430,268,280,42,'#24262a',8);text('~3 min to merge',570,290,23,'#b9bbc1');let hover=t>1.4&&t<4.4;if(hover){rect(435,205,290,44,'#303137',10);text('In merge queue for 4 min',580,228,20,'#eee')}cursor(hover?600:750,hover?292:370);return;}
 if(m==='search'){gradient('#94cad7','#1550a9');for(let i=0;i<6;i++){ctx.strokeStyle='#8ed9dd44';ctx.lineWidth=45;ctx.beginPath();ctx.moveTo(-100,500+i*30);ctx.bezierCurveTo(360,500,500,100,1100,-100+i*40);ctx.stroke()}rect(245,150,510,48,'#d7f6f1ee',24);text(t<2.4?progressText('Send Message',t/1.1):progressText(P.title,(t-2.4)/2),270,174,23,'#304e59','left','Arial',400,460);if(t>1&&t<2.4){rect(245,203,510,175,'#d7f6f1dd',15);['Send Message','Send message for photoshoot','Contacts'].forEach((v,i)=>text(v,270,230+i*45,20,'#304e59','left'))}return;}
 if(m==='clipboard'){w3Panel(320,130,600,360);w3Panel(80,245,200,270);text(P.title,610,190,30,'#333');w3TextRows(110,280,140,7);w3TextRows(370,230,450,8);alpha(1-phase(t,1.5,2.5),()=>rect(105,295,150,60,'#f1d86c66'));if(t>3.5){rect(390,230,390,80,'#eff0e8');text('Shared content',410,268,23,P.accent,'left')}return;}
 if(m==='slider'||m==='schedule'){w3Title(t);w3Panel(180,190,640,260,dark);text(m==='slider'?'Effort':'Schedule',220,250,25,dark?'#eee':'#333','left');if(m==='slider'){let z=clamp((t-3)/4),step=Math.min(3,Math.floor(z*4));['Light','Standard','High','Ultra'].forEach((v,i)=>{ellipse(310+i*130,335,10,10,i<=step?P.accent:'#bfc5c2');text(v,310+i*130,375,18,dark?'#eee':'#333')});line(310,335,700,335,'#aab1ae',5);line(310,335,310+390*step/3,335,P.accent,5);cursor(310+390*step/3,340)}else{['M','T','W','T','F','S','S'].forEach((v,i)=>{ellipse(270+i*70,335,20,20,t>4&&(i===0||i===3)?P.accent:'#5558');text(v,270+i*70,335,18,fg)});text(t>10?'Every Monday and Thursday at 8:00 AM':'Every 1 week',500,410,18,fg)}return;}
 if(m==='kanban'){w3Title(t);const names=['Triage','Plan','Build','PR Ready','Ship'];let k=Math.min(4,Math.floor(t/CONFIG.duration*5));for(let i=0;i<5;i++){rect(35+i*195,180,185,310,['#edf0f0','#f4f0ce','#dceaf4','#eadff2','#dff1da'][i],9);text(names[i],125+i*195,215,20,'#333');}let xx=50+Math.min(4,t/CONFIG.duration*5)*195;rect(xx,270,155,110,'#fff',9);text('One task',xx+77,305,20,'#333');w3Chip(names[k],xx+12,340,130);return;}
 if(m==='conveyor'){w3Title(t);line(40,355,960,355,'#333',4);for(let j=0;j<18;j++)ellipse(40+j*54,370,7,7,'#333');for(let i=0;i<7;i++){let x=frac(t*.08+i/7)*1100-50,y=t<15?260+Math.max(0,t-5)*sin(i)*4:260+sin(t+i)*7;at(x,y,1,t<15?Math.max(0,t-5)*sin(i)*.02:0,()=>{rect(-70,-30,140,60,'#eceee8',6);text(CONFIG.objects[i%CONFIG.objects.length],0,0,16,'#333','center','Arial',400,130)})}if(t>15)for(let j=0;j<3;j++){ellipse(280+j*220,460,38,38,CONFIG.palette[(j+2)%CONFIG.palette.length]);text(['✓','↗','…'][j],280+j*220,460,28,'#fff')}return;}
 if(m==='nodes'){w3Title(t);['Image','Text','Style'].forEach((v,i)=>{w3Chip(v,70,190+i*115,170);w3Arrow(240,208+i*115,415,330)});rect(415,225,190,220,P.accent,14);text('Design',510,330,28,'#fff');for(let i=0;i<3;i++){w3Arrow(605,330,755,215+i*110);rect(755,180+i*110,160,80,'#e9ebed',7);text('Output '+(i+1),835,220+i*110,20,'#333')}return;}
 if(m==='network'||m==='project'){w3Title(t);const cloud=m==='network'&&t>CONFIG.duration*.52;const cx=500,cy=cloud?415:330;if(cloud){rect(365,175,270,100,P.accent,16);text('Cloud',500,208,24,'#fff');text('Models · Review · Research',500,246,15,'#fff');w3Arrow(500,275,500,365)}const names=m==='project'?CONFIG.objects.slice(1,6):['Tools','Models','Sandbox','Harness','Orchestrator'];for(let i=0;i<5;i++){let a=i*TAU/5-1.5,x=cx+cos(a)*(cloud?330:270),y=cy+sin(a)*(cloud?65:155);line(cx,cy,x,y,P.accent,1.5);let z=frac(t*.15+i*.2);ellipse(mix(cx,x,z),mix(cy,y,z),4,4,P.accent);rect(x-65,y-20,130,40,dark?'#2c3435':'#e9edeb',9);text(names[i%names.length],x,y,16,dark?'#eee':'#333','center','Arial',400,122)}rect(cx-78,cy-38,156,76,P.accent,14);text(m==='project'?'Project':'Local',cx,cy,24,'#fff');return;}
 if(m==='vector'||m==='mask'){w3Title(t);w3Panel(80,160,840,340);rect(100,194,120,285,'#ecece8',5);rect(790,194,110,285,'#efefed',5);let pulse=sin(t*.5);saved(()=>{ctx.translate(510,330);if(m==='vector'){for(let i=0;i<4;i++)at(0,0,1,i*Math.PI/2,()=>ellipse(45,45,75+12*pulse,50,P.accent));for(let i=0;i<8;i++){let a=i*TAU/8;ellipse(cos(a)*110,sin(a)*85,4,4,'#fff',P.accent)}}else{rect(-170,-120,340,240,'#b7d1d4');for(let i=0;i<7;i++)ellipse(sin(i*2)*70,-40+cos(i)*60,45,60,t>CONFIG.duration*.62?'#83a679':P.accent);rect(-15,10,30,90,'#706146');if(t>CONFIG.duration*.75){rect(-170,-120,65,240,'#fafafa');rect(105,-120,65,240,'#fafafa')}}});w3TextRows(115,220,90,9);w3TextRows(805,220,70,9);cursor(600+sin(t)*20,320);return;}
 if(m==='timeline'){w3Title(t);rect(130,165,740,240,'#d5c4f4',20);let x=mix(220,760,.5+.5*sin(t*.4));ellipse(x,280,42,42,P.accent);for(let j=0;j<6;j++)ellipse(220+j*108,280,4,4,'#599bde');rect(130,440,740,70,'#ececec',6);line(150,460,850,460,'#aaa');let play=150+700*frac(t*.1);line(play,430,play,520,P.accent,2);for(let i=0;i<3;i++)rect(165+i*210,475,180,12,'#7dbce9',3);return;}
 if(m==='charts'){w3Title(t);w3Panel(150,160,700,360);let phaseN=n%3;if(phaseN===0){const points=Array.from({length:21},(_,i)=>[220+i*27,430-i*5-sin(i*.6)*30]);for(let i=1;i<points.length;i++)if(i/points.length<ease(u+.3))line(...points[i-1],...points[i],P.accent,3);let ix=Math.floor(frac(t*.12)*20);ellipse(...points[ix],6,6,P.accent);line(points[ix][0],220,points[ix][0],465,'#9bb5b477');text('Explore',500,195,18,'#333')}else{ellipse(510,345,170,80,null,'#98aaa4');ellipse(510,345,25,25,P.accent);ellipse(510+cos(t)*170,345+sin(t)*80,12,12,'#b9c2bd');ellipse(735,345,35,35,'#e9c675');text('Change a parameter',500,480,20,'#333')}return;}

 const stageLabel=CONFIG.stages[n].label;
 const longUI=['automation','workflow','reports','local','canvas','handoff','document','multiout','email'];
 if(longUI.includes(m)){
  w3Title(t);
  if(/主张|标题|品牌|总结|收尾/.test(stageLabel)){simpleMark(500,265,1.2);text(stageLabel,500,370,25,fg);return;}
  if(/输入|请求|提问|需求|提交/.test(stageLabel)){w3Panel(180,240,640,150,dark);text(progressText(CONFIG.objects.slice(0,3).join(' → '),clamp(u*2)),215,300,24,dark?'#eee':'#333','left','Arial',400,530);w3Chip('Send',690,330,95);cursor(742,357+18*(1-u));return;}
  if(/报告|结果|成果|文档|表格|产物|图表|看板/.test(stageLabel)){w3Panel(210,170,580,340,dark);text(stageLabel,250,225,25,dark?'#eee':'#333','left');w3TextRows(250,265,480,3,dark);for(let j=0;j<6;j++){rect(255+j*74,370,48,90*(.3+rand(j)*.7)*ease(u+.3),j===n%6?P.accent:(dark?'#44565e':'#c6d8d0'),3)}rect(245,470,510,2,P.accent);return;}
  if(/设置|菜单|选项|模型|共享|下载|选择/.test(stageLabel)){w3Panel(330,175,340,330,dark);text(stageLabel,500,220,24,dark?'#eee':'#333');CONFIG.objects.slice(0,4).forEach((v,i)=>{rect(350,255+i*52,300,42,i===Math.floor(u*4)?P.accent:(dark?'#242a30':'#eff0ed'),6);text(v,370,276+i*52,18,i===Math.floor(u*4)?'#fff':(dark?'#ddd':'#333'),'left')});return;}
 }
 // UI mechanisms retain their own hierarchy and state rather than replaying original screenshots.
 w3Title(t);const mobile=m==='mobile',tilt=m==='tilted'||m==='diff',terminal=m==='terminal';saved(()=>{if(tilt){ctx.translate(500,320);ctx.transform(1,-.12,.13,1,0,0);ctx.translate(-500,-320)}let x=mobile?335:145,w=mobile?330:710;w3Panel(x,165,w,350,dark||terminal);if(terminal){for(let i=0;i<10;i++){text((i===0?'> ':i%3?'  ':'✓ ')+progressText(['Build a workspace','Reading context','Creating modules','Deploying result'][i%4],clamp(t/4-i*.25)),x+25,215+i*24,16,i%3?'#aab6a4':P.accent,'left','monospace',400,w-50)}return;}
 if(m==='council'){for(let i=0;i<3;i++){rect(x+25,220+i*75,w-50,60,'#eff3f0',7);text('Model '+String.fromCharCode(65+i),x+45,242+i*75,18,'#333','left');rect(x+200,238+i*75,(w-250)*phase(t,9+i,18+i),5,P.accent)}if(t>21){rect(x+20,210,w-40,280,'#fff');for(let row=0;row<5;row++){line(x+30,240+row*45,x+w-30,240+row*45,'#ddd');for(let c=0;c<3;c++)text(row?'✓':'Compare',x+130+c*190,222+row*45,18,row?P.accent:'#333')}}return;}
 if(m==='email'){rect(x+12,199,130,295,'#eef1ed');w3TextRows(x+25,220,95,9);text(t<16?'New message':'Reply received',x+170,220,25,'#333','left');w3TextRows(x+170,260,w-210,5);w3Chip(t<16?'Send':'Open attachment',x+w-220,435,180);return;}
 if(m==='diff'){rect(x+18,210,w*.43,270,'#171b21');rect(x+w*.48,210,w*.49,270,'#171b21');for(let i=0;i<10;i++){rect(x+w*.5,220+i*25,w*.44,20,i%4===0?'#703f4655':i%3===0?'#35815855':'#202732');text((i+1)+'  '+['const result = input','return response','await review()'][i%3],x+w*.51,230+i*25,12,'#bfcbd5','left','monospace')}return;}
 if(m==='canvas'||m==='handoff'||m==='document'||m==='multiout'){const count=m==='document'?2:3;for(let j=0;j<count;j++){let xx=x+30+j*(w-45)/count;rect(xx,215,(w-80)/count,245,j===n%count?P.accent:'#e5ebe6',7);text(CONFIG.objects[j%CONFIG.objects.length],xx+12,240,17,j===n%count?'#fff':'#333','left','Arial',500,(w-100)/count);w3TextRows(xx+12,275,(w-130)/count,5);if(j===n%count){ctx.strokeStyle='#2f9cdb';ctx.lineWidth=2;ctx.strokeRect(xx-3,212,(w-80)/count+6,251)}}cursor(x+w*.6+sin(t)*30,400);return;}
 if(m==='automation'||m==='workflow'||m==='reports'||m==='local'){for(let i=0;i<4;i++){let yy=220+i*63;ellipse(x+45,yy,8,8,i<=n%5?P.accent:'#adb5b0');line(x+45,yy+10,x+45,yy+50,'#acb7b3');text(CONFIG.objects[i%CONFIG.objects.length],x+75,yy,20,dark?'#f0f0ee':'#333','left');rect(x+w-180,yy-8,120*clamp(u*2-i*.12),16,P.accent,5)}return;}
 if(mobile){rect(x+20,205,w-40,145,'#27212a');w3TextRows(x+35,220,w-70,5,true);rect(x+20,370,w-40,70,'#282b36',8);text(progressText('Review this change',u),x+35,397,18,'#eee','left');if(n<3)for(let j=0;j<9;j++)rect(x+20+j*32,470,28,28,'#343742',4);else text('Reply ready',500,470,22,P.accent);return;}
 w3TextRows(x+35,220,w-70,10,dark);});
}
function drawScene(t){bg();w3Diagram(t);if(!['portal','pixels','loading','poster'].includes(CONFIG.mechanism)){const n=stageAt(t);label(CONFIG.stages[n].label,30,565,CONFIG.palette[1]);rect(30,582,940,2,CONFIG.palette[1]+'22');rect(30,582,940*clamp(t/CONFIG.duration),2,P.accent);}}