Deck.transition('portal-out', { dur: 1.35, frag: ` void main(){ if(p<=0.){ o=texture(tA,vUv); return; } if(p>=1.){ o=texture(tB,vUv); return; } float retreat=1.-pow(1.-p,2.); vec2 center=mix(vec2(.5),vec2(.5,.55),retreat); vec2 bounds=mix(vec2(.505),vec2(.085),retreat); vec2 uvA=(vUv-center)/(2.*bounds)+.5; vec2 metric=vec2(uRes.x/uRes.y,1.); float edge=sdBox((vUv-center)*metric,bounds*metric); float alive=1.-smoothstep(.65,1.,p); float hole=1.-smoothstep(-.001,.001,edge); float rim=smoothstep(-.001,.001,edge)*(1.-smoothstep(.003,.005,edge)); float shade=exp(-max(edge,0.)*95.)*(1.-hole)*alive; vec3 paper=texture(tB,vUv).rgb*(1.-.16*shade); vec3 sky=texture(tA,clamp(uvA,0.,1.)).rgb; sky*=1.-.13*retreat*smoothstep(-.028,0.,edge); vec3 c=mix(paper,sky,hole*alive); c=mix(c,vec3(.57,.68,.81),rim*alive*smoothstep(0.,.16,p)*.85); o=vec4(c,1.); } ` }); Deck.scene({ id: 'questions', title: 'Any questions?', enterWith: 'portal-out', post: {tone:'none', bloom:0, vignette:0, grain:0}, beats: [{dur:1.4,hold:5},{dur:2.65,hold:4},{dur:8.4,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 { first:'I have one.', last:'What do you want?', U:{uSlide:[0,0,960,540],uPose:[0,1,0]}, paper:d.pass(` uniform vec4 uSlide; uniform vec3 uPose; void main(){ vec2 p=design(vUv)-uSlide.xy; float co=cos(uPose.x), si=sin(uPose.x); vec2 q=vec2(co*p.x+si*p.y,co*p.y-si*p.x)/uPose.y; vec2 b=uSlide.zw; float edge=sdBox(q,b); float aa=max(.55,fwidth(edge)*.7); float inside=1.-smoothstep(-aa,aa,edge); float foot=smoothstep(b.y-9.-aa,b.y-9.+aa,q.y); vec3 sheet=mix(vec3(1.),vec3(.984,.986,.991),sat((q.y+b.y)/(2.*b.y))); sheet=mix(sheet,vec3(.106,.333,.742),foot); vec2 sh=q-vec2(3.,20.); float shadow=exp(-max(sdBox(sh,b-vec2(2.,3.)),0.)/24.); vec2 field=(p-vec2(-250.,-200.))/vec2(1600.,980.); vec3 room=mix(vec3(.047,.054,.068),vec3(.137,.155,.188),exp(-dot(field,field)*1.6)); room*=1.-.73*shadow; o=vec4(mix(room,sheet,mix(1.,inside,smoothstep(0.,.12,uPose.z))),1.); } `,'Office slide and drop shadow') }; }, draw(s,d,r) { const E=d.E, v=d.view, c=d.ctx2d; const cx=(v.x0+v.x1)*.5, cy=(v.y0+v.y1)*.5; const hw=v.w*.5, hh=v.h*.5; const tilt=s.k(2,6.95,8.4,E.io3); const angle=tilt*Math.PI/180, scale=1-.059*tilt; const U=r.U; U.uSlide[0]=cx; U.uSlide[1]=cy; U.uSlide[2]=hw; U.uSlide[3]=hh; U.uPose[0]=angle; U.uPose[1]=scale; U.uPose[2]=tilt; r.paper.draw(U); const box=s.k(1,.12,.76,E.out3); const typing=s.k(1,.83,2.65,E.lin); const deletion=s.k(2,.15,.95,E.lin); const rewrite=s.k(2,1.12,3.35,E.lin); const widen=s.k(2,.72,1.58,E.io3); const grow=s.k(2,3.7,5.45,E.io3); const breath=s.k(2,5.2,6.05)*2.6*Math.sin(s.t*1.75); const lineW=356+220*widen; const lineY=cy+145; const x0=-lineW*.5, y0=lineY-cy; const x1=-hw+32-breath, y1=-hh+64-breath; const right=hw-32+breath, bottom=hh-32+breath; const bx=cx+x0+(x1-x0)*grow; const by=cy+y0+(y1-y0)*grow; const bw=lineW+(right-x1-lineW)*grow; const bh=102+(bottom-y1-102)*grow; c.save(); c.translate(cx,cy); c.rotate(angle); c.scale(scale,scale); c.translate(-cx,-cy); d.text('Any questions?',{ x:cx,y:cy-59,size:94,font:'arial',color:'#111111',align:'center', style:'fade',show:s.k(0,.08,1.4,E.lin) }); if(box>0){ d.select(bx,by,bw,bh,{a:box}); const oldN=Math.round(r.first.length*typing*(1-deletion)); const newN=Math.round(r.last.length*rewrite); const second=s.p[2]>0 && deletion>=1; const line=second?r.last.slice(0,newN):r.first.slice(0,oldN); const tx=cx-lineW*.5+34, ty=lineY+17; let cursor=tx; if(line.length){ const bounds=d.text(line,{x:tx,y:ty,size:57,font:'arial',color:'#141414',show:1}); cursor=bounds.x+bounds.w+3; } const blink=Math.sin(s.t*7.8)>-.17?1:0; const ink=box*(1-s.k(2,3.45,3.7,E.lin))*blink; if(ink>0) d.rect(cursor,ty+8,2.6,58,'#202020',ink); } c.restore(); } });