Deck.transition('portal-out',{dur:1.4,frag:`void main(){ float e=p*p*(3.-2.*p); // eased pull-back vec2 c=vUv-.5; float dd=max(abs(c.x),abs(c.y)); float hf=(1.-e)*.504; // the old scene sits in a 16:9 frame that recedes to nothing float m=1.-smoothstep(hf-.003,hf,dd); // 1 inside the frame; exactly 1 everywhere at p=0, 0 at p=1 vec4 a=texture(tA,clamp(.5+c/max(1.-e,.0005),0.,1.)); // old picture shrinks with its frame vec4 b=texture(tB,.5+c*mix(.55,1.,e)); // the new slide starts close and settles as we back out b.rgb*=1.-.4*exp(-max(dd-hf,0.)*28.)*e*(1.-e)*4.; // soft shadow round the receding frame o=mix(b,a,m); }`}); Deck.scene({ id:'questions', title:'Any questions?', enterWith:'portal-out', post:{tone:'none'}, beats:[{dur:.6,hold:4},{dur:2.8,hold:4},{dur:8.6,hold:6}], notes:[ 'Any questions? (Back to the dull template. Let people think it is over.)', '(Press next and look at the screen, not at the room.)', 'Leave it up. That is the question the whole talk comes down to: something is going to be able to edit the world, and we have to be able to say what we want. (After a few seconds the slide tilts by one degree.)' ], setup(d){ return { A:'I have one.', B:'What do you want?', U:{uC:[960,540],uH:[960,540],uA:0,uK:0,uM:[0,0]}, bg:d.pass(`uniform vec2 uC,uH,uM; uniform float uA,uK; void main(){ vec2 q=design(vUv)-uC; float cs=cos(uA),sn=sin(uA); vec2 l=vec2(cs*q.x+sn*q.y,-sn*q.x+cs*q.y); // slide-local coordinates (inverse of the canvas rotation) float dS=sdBox(l,uH), dSh=sdBox(l-vec2(16.,30.),uH); vec3 back=vec3(.075,.08,.1)*(.8+.35*fbm(q*.004+uM*.05+uTime*.01)); // dark backdrop, faintly uneven back*=1.-.35*smoothstep(500.,1300.,length(q)); back*=1.-.75*uK*exp(-max(dSh,0.)/46.); // soft shadow under the slide vec3 slide=vec3(1.); slide=mix(slide,vec3(.17,.43,.86),smoothstep(-1.,1.,l.y-(uH.y-26.))); // thin blue bar along the bottom edge slide*=1.-.03*uK*smoothstep(-200.,0.,dS); o=vec4(mix(back,slide,smoothstep(1.,-1.,dS)),1.); }`,'questions slide') } }, draw(s,d,r){ const c=d.ctx2d, E=d.E, L=E.lin, v=d.view, U=r.U; const cx=(v.x0+v.x1)/2, cy=(v.y0+v.y1)/2; const k=s.k(2,7.4,8.6,E.io3); // the tilt, a few seconds after the box has grown const sc=1-.08*k, ang=-Math.PI/180*k; // exactly one degree U.uC[0]=cx; U.uC[1]=cy; U.uH[0]=v.w/2*sc+8*(1-k); U.uH[1]=v.h/2*sc+8*(1-k); U.uA=ang; U.uK=k; U.uM[0]=s.mouse.x; U.uM[1]=s.mouse.y; r.bg.draw(U); c.save(); c.translate(cx,cy); c.rotate(ang); c.scale(sc,sc); c.translate(-cx,-cy); // text and box ride on the slide d.text('Any questions?',{x:960,y:350,size:124,font:'arial',color:'#000',align:'center',style:'fade'}); const kA=s.k(1,1,2.6,L)*(1-s.k(2,0,.8,L)); // typed, then deleted const nA=Math.round(kA*r.A.length), nB=Math.round(s.k(2,1.1,2.8,L)*r.B.length); const str=nB>0?r.B.slice(0,nB):r.A.slice(0,nA); const t=d.text(str,{x:960,y:592,size:64,font:'arial',color:'#222',align:'center',show:1}); const a=s.k(1,.2,.8,L); if(a>0&&Math.sin(s.t*6)>-.2) d.rect(str?t.x+t.w+6:958,588,4,74,'#222',a); // blinking text cursor const g=s.k(2,3.4,5,E.io3), br=3*Math.sin(s.t*1.3)*g; // grow to the slide's edges, then breathe const bw=Math.max(520,(str?t.w:0)+90); const x0=960-bw/2, y0=574, w0=bw, h0=100; const x1=v.x0+50-br, y1=v.y0+64-br, w1=v.w-100+2*br, h1=v.h-64-60+2*br; d.select(x0+(x1-x0)*g,y0+(y1-y0)*g,w0+(w1-w0)*g,h0+(h1-h0)*g,{a}); c.restore(); } });