// ─────────── data ─────────── const ART = { 'css-grid-lanes':'note','spool':'code','ferrotype':'code','building-ui-in-gpui':'code', 'the-black-magic-of-canvas-and-text-editing':'note','fig-gen-making-generative-art-in-figma':'image', 'writing-with-adhd':'prose','design-workshop':'image' }; const KL={code:'Source',image:'Pictures',prose:'Longform',note:'Note'}; let POSTS=[]; const esc=s=>s.replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); const pad=n=>String(n).padStart(2,'0'); const dfmt=d=>d.replace(/-/g,'.'); function stats(p){const d=document.createElement('div');d.innerHTML=p.html;const pres=[...d.querySelectorAll('pre')];const cl=pres.reduce((n,x)=>n+x.querySelectorAll('.line').length,0);pres.forEach(x=>x.remove());return{words:(d.textContent.match(/\S+/g)||[]).length,codeLines:cl,imgs:d.querySelectorAll('img').length};} // ─────────── stripe field ─────────── const Field=(()=>{ const cv=document.getElementById('field'); const gl=cv.getContext('webgl',{antialias:false,premultipliedAlpha:false}); const MS=.5; // mask scale const maskCv=[document.createElement('canvas'),document.createElement('canvas')]; const S={mix:1,mixT:1,cur:0,fade:0,fadeT:0,mouse:[innerWidth*.62,innerHeight*.5],mouseT:[innerWidth*.62,innerHeight*.5],beamY:innerHeight*.5,beamYT:innerHeight*.5,lens:0,lensT:1,vel:0}; if(!gl){return{show(){},setFade(){},beam(){},S};} const vs='attribute vec2 p;void main(){gl_Position=vec4(p,0.,1.);}'; const fs=` precision highp float; uniform sampler2D uA,uB; uniform float uMix,uTime,uFade,uBeamY,uLens,uVel,uP; uniform vec2 uRes,uMouse; float hash(float n){return fract(sin(n*12.9898)*43758.5453);} void main(){ vec2 fc=gl_FragCoord.xy; vec2 m=vec2(uMouse.x,uRes.y-uMouse.y); vec2 d=fc-m; float R=uRes.y*.2; float lens=exp(-dot(d,d)/(R*R))*uLens; // lines pushed away from the lens horizon, and pinched toward the beam float by=uRes.y-uBeamY; float push=sign(fc.y-by)*lens*R*.55*(1.-exp(-abs(fc.y-by)/(R*.25))); float wave=sin(fc.x*.0045+uTime*.7+fc.y*.002)*4.*(1.-uFade)+sin(fc.x*.013-uTime*1.3)*uVel*.6; float y=fc.y-push+wave; vec2 tuv=vec2(fc.x+d.x*lens*-.15,y)/uRes; tuv.y=1.-tuv.y; float idx=floor(y/uP); float sw=smoothstep(hash(idx)*.7,hash(idx)*.7+.3,uMix); float mk=mix(texture2D(uA,tuv).r,texture2D(uB,tuv).r,sw); float duty=mix(.17,.86,mk); duty=mix(duty,.07,uFade); float f=abs(fract(y/uP)-.5)*2.; float aa=1.2/uP; float ink=1.-smoothstep(duty-aa,duty+aa,f); vec3 paper=vec3(.373,.584,.847), inkc=vec3(.11,.05,.063); // subtle print grain float g=hash(fc.x*1.7+fc.y*91.3+floor(uTime*8.))*.04; vec3 col=mix(paper-g,inkc,ink*(1.-uFade*.72)); // beam float bd=abs(fc.y-by); float bw=6.+lens*14.; float beam=smoothstep(bw,bw-2.,bd)*(1.-uFade*.9); float cx=abs(fc.x-m.x)/uRes.x; vec3 bc=mix(vec3(.94,.42,.23),vec3(.94,.56,.75),smoothstep(.0,.25,cx)); bc=mix(vec3(.48,.34,.78),bc,smoothstep(.0,.06,cx)); col=mix(col,bc,beam); gl_FragColor=vec4(col,1.); }`; const sh=(t,s)=>{const o=gl.createShader(t);gl.shaderSource(o,s);gl.compileShader(o);if(!gl.getShaderParameter(o,gl.COMPILE_STATUS))console.error(gl.getShaderInfoLog(o));return o;}; const pr=gl.createProgram();gl.attachShader(pr,sh(gl.VERTEX_SHADER,vs));gl.attachShader(pr,sh(gl.FRAGMENT_SHADER,fs));gl.linkProgram(pr);gl.useProgram(pr); const b=gl.createBuffer();gl.bindBuffer(gl.ARRAY_BUFFER,b);gl.bufferData(gl.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),gl.STATIC_DRAW); const loc=gl.getAttribLocation(pr,'p');gl.enableVertexAttribArray(loc);gl.vertexAttribPointer(loc,2,gl.FLOAT,false,0,0); const U={};['uA','uB','uMix','uTime','uFade','uBeamY','uLens','uVel','uP','uRes','uMouse'].forEach(k=>U[k]=gl.getUniformLocation(pr,k)); const tex=[0,1].map(i=>{const t=gl.createTexture();gl.activeTexture(gl.TEXTURE0+i);gl.bindTexture(gl.TEXTURE_2D,t); gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR); gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);return t;}); gl.uniform1i(U.uA,0);gl.uniform1i(U.uB,1); let dpr=1; function resize(){dpr=Math.min(devicePixelRatio||1,1.5);cv.width=innerWidth*dpr;cv.height=innerHeight*dpr;gl.viewport(0,0,cv.width,cv.height); maskCv.forEach(c=>{c.width=Math.ceil(innerWidth*MS);c.height=Math.ceil(innerHeight*MS);});if(last)paint(1,last,true);} // text mask let last=null; function wrap(words,ctx,maxW){const lines=[];let cur='';for(const w of words){const t=cur?cur+' '+w:w;if(ctx.measureText(t).width>maxW&&cur){lines.push(cur);cur=w;}else cur=t;}if(cur)lines.push(cur);return lines;} function paint(slot,spec,up){ const c=maskCv[slot],ctx=c.getContext('2d');const W=c.width,H=c.height; ctx.fillStyle='#000';ctx.fillRect(0,0,W,H); const box={x:spec.box[0]*W,y:spec.box[1]*H,w:spec.box[2]*W,h:spec.box[3]*H}; const text=spec.text.toUpperCase(); ctx.fontStretch='extra-expanded'; // find size that fits let size=box.h, lines; for(let k=0;k<40;k++){ ctx.font=`900 ${size}px "Anybody Variable"`; lines=wrap(text.split(/\s+/),ctx,box.w); const wide=Math.max(...lines.map(l=>ctx.measureText(l).width)); if(lines.length*size*.86<=box.h&&wide<=box.w*1.001)break; size*=.93; } ctx.fillStyle='#fff';ctx.textBaseline='alphabetic'; const lh=size*.86, total=lines.length*lh, y0=box.y+(box.h-total)/2+lh*.82; lines.forEach((l,i)=>{const w=ctx.measureText(l).width;const x=spec.align==='left'?box.x:box.x+(box.w-w)/2;ctx.fillText(l,x,y0+i*lh);}); // soften so stroke thickness ramps at edges ctx.filter='blur(1.2px)';ctx.drawImage(c,0,0);ctx.filter='none'; gl.activeTexture(gl.TEXTURE0+slot);gl.bindTexture(gl.TEXTURE_2D,tex[slot]); gl.texImage2D(gl.TEXTURE_2D,0,gl.LUMINANCE,gl.LUMINANCE,gl.UNSIGNED_BYTE,c); if(up)last=spec; } let showing=null, aIs=0; function show(spec){ const key=JSON.stringify(spec); if(key===showing)return; showing=key; // copy current B into A, new into B if(last){paint(0,last,false);}else paint(0,spec,false); paint(1,spec,true); S.mix=0; } addEventListener('resize',resize); addEventListener('pointermove',e=>{S.mouseT=[e.clientX,e.clientY];}); let lastSY=scrollY; const t0=performance.now(); function frame(now){ const t=(now-t0)/1000; S.mix=Math.min(1,S.mix+.018); S.fade+=(S.fadeT-S.fade)*.08; for(let i=0;i<2;i++)S.mouse[i]+=(S.mouseT[i]-S.mouse[i])*.09; S.beamY+=(S.beamYT-S.beamY)*.08; S.lens+=(S.lensT-S.lens)*.06; const v=scrollY-lastSY;lastSY=scrollY;S.vel+=(Math.max(-60,Math.min(60,v))-S.vel)*.15; document.documentElement.style.setProperty('--skew',(-S.vel*.25).toFixed(2)+'deg'); gl.uniform1f(U.uMix,S.mix);gl.uniform1f(U.uTime,t);gl.uniform1f(U.uFade,S.fade); gl.uniform1f(U.uBeamY,S.beamY*dpr);gl.uniform1f(U.uLens,S.lens);gl.uniform1f(U.uVel,S.vel); gl.uniform1f(U.uP,Math.max(5,Math.round(Math.min(innerHeight,innerWidth*1.3)/88))*dpr); gl.uniform2f(U.uRes,cv.width,cv.height);gl.uniform2f(U.uMouse,S.mouse[0]*dpr,S.mouse[1]*dpr); gl.drawArrays(gl.TRIANGLES,0,3); requestAnimationFrame(frame); } resize();requestAnimationFrame(frame); return{show,S,beam(y){S.beamYT=y;},setFade(f){S.fadeT=f;}}; })(); const dot=document.getElementById('dot'); addEventListener('pointermove',e=>{dot.style.left=e.clientX+'px';dot.style.top=e.clientY+'px';}); // ─────────── views ─────────── const app=document.getElementById('app'); let cleanup=[]; const on=(t,e,f,o)=>{t.addEventListener(e,f,o);cleanup.push(()=>t.removeEventListener(e,f,o));}; const narrow=()=>innerWidth<860; function renderIndex(){ document.title='nate.rip — line field'; document.getElementById('ctr').textContent='WRITING 2015—'+POSTS[0].date.slice(0,4); app.innerHTML=`
${POSTS.length} entriesScroll ↓Rust · canvas · type · making
`; const items=[...app.querySelectorAll('.item')]; let hover=-1, active=-2; const heroSpec=narrow()?{text:'nate. rip',box:[.06,.2,.88,.5],align:'left'}:{text:'nate.rip',box:[.04,.14,.92,.66],align:'center'}; const specFor=i=>narrow()?{text:POSTS[i].title,box:[.05,.08,.9,.3],align:'left'}:{text:POSTS[i].title,box:[.04,.1,.47,.8],align:'left'}; function upd(){ const vh=innerHeight; let a=-1; if(hover>=0)a=hover; else if(scrollY>vh*.55){let best=1e9;items.forEach((el,i)=>{const r=el.getBoundingClientRect();const dd=Math.abs(r.top+r.height/2-vh*.5);if(ddel.classList.toggle('on',i===a));Field.show(a<0?heroSpec:specFor(a));} if(a>=0){const r=items[a].getBoundingClientRect();Field.beam(r.top+r.height/2);}else Field.beam(vh*.82); } items.forEach((el,i)=>{on(el,'pointerenter',()=>{hover=i;dot.classList.add('big');upd();});on(el,'pointerleave',()=>{hover=-1;dot.classList.remove('big');upd();});}); on(window,'scroll',upd,{passive:true}); Field.setFade(0);Field.S.lensT=1; upd(); } function renderPost(p){ const i=POSTS.indexOf(p), next=POSTS[i+1]||POSTS[0]; document.title=p.title+' — nate.rip'; document.getElementById('ctr').textContent=`${pad(i+1)} / ${pad(POSTS.length)}`; app.innerHTML=`

${esc(p.title)}

${KL[p.k]}${dfmt(p.date)}${p.s.words} words${Math.max(1,Math.round(p.s.words/230))} min${p.s.codeLines?`${p.s.codeLines} lines of code`:''}${p.s.imgs?`${p.s.imgs} images`:''}
${p.html}
`; const body=document.getElementById('body'); build(body,p); const box=narrow()?[.05,.12,.9,.6]:p.title.length<12?[.04,.12,.92,.68]:[.04,.1,.92,.72]; Field.show({text:p.title,box,align:p.title.length<12?'center':'left'}); Field.S.lensT=1; const upd=()=>{const k=Math.min(1,scrollY/(innerHeight*.8));Field.setFade(k);Field.beam(innerHeight*(.86-k*.0));Field.S.lensT=1-k*.7; // marquee bands body.querySelectorAll('.band .row').forEach((r,j)=>{const b=r.parentNode.getBoundingClientRect();const x=(b.top-innerHeight)*(j%2?.6:-.6);r.style.transform=`translateX(${x-300}px)`;}); }; on(window,'scroll',upd,{passive:true});upd(); observe(body); } function build(body,p){ const h1=body.querySelector('h1');if(h1&&h1.textContent.trim().toLowerCase()===p.title.toLowerCase())h1.remove(); body.querySelectorAll('a[href^="http"]').forEach(a=>{a.target='_blank';a.rel='noopener'}); // code slabs let c=0; body.querySelectorAll('pre').forEach(pre=>{ c++;const txt=pre.textContent,ln=pre.querySelectorAll('.line'); const lang=/#\[|fn |let |impl |struct |::|pub /.test(txt)?'Rust':/^\s*(cargo|spool|npm|git)\b/m.test(txt)?'Shell':/display\s*:|grid-/.test(txt)?'CSS':/type |interface /.test(txt)?'TypeScript':'Text'; ln.forEach((l,j)=>l.style.setProperty('--l',j)); const s=document.createElement('figure');s.className='slab';s.innerHTML=`
${pad(c)} — ${lang}${ln.length} ln
`; pre.replaceWith(s);s.appendChild(pre); }); // images let m=0; body.querySelectorAll('img').forEach(img=>{ m++;const host=img.closest('p')||img;const f=document.createElement('figure');f.className='blind';img.loading='lazy'; f.appendChild(img);const cap=document.createElement('figcaption');cap.innerHTML=`${esc(img.alt||'')}Fig. ${pad(m)}`;f.appendChild(cap);host.replaceWith(f); }); // prose: headings become scrolling bands, parentheticals get marked if(p.k==='prose'){ body.querySelectorAll('h2').forEach((h,j)=>{ const t=esc(h.textContent.replace(/\.$/,''));const band=document.createElement('div');band.className='band'+(j%2?' alt':''); band.setAttribute('role','heading');band.setAttribute('aria-level','2'); band.innerHTML=`
${Array(6).fill(t).join('✶')}✶
`;h.replaceWith(band); }); body.querySelectorAll('p').forEach(pp=>{ if(pp.querySelector('a,code'))return; pp.innerHTML=pp.innerHTML.replace(/\(([^()]{12,})\)/g,'($1)'); }); } // link-list note becomes a link roll if(p.k==='note'&&body.querySelectorAll('p > a > strong').length>=4){ const roll=document.createElement('div');roll.className='roll'; const kids=[...body.children];let started=false;const keep=[];let lastLn=null; kids.forEach(el=>{ if(el.tagName==='H2'||el.tagName==='H3'){started=true;lastLn=null;const g=document.createElement('div');g.className='grp';g.textContent=el.textContent;roll.appendChild(g);return;} if(!started){keep.push(el);return;} if(el.tagName==='HR'){started=false;keep.push(roll,el);return;} if(el.tagName==='P'&&el.querySelector('a > strong')){ const main=[...el.querySelectorAll('a')].filter(a=>a.querySelector('strong')); const by=el.textContent.split(/\s[-–]\s/).slice(1).join(' ').trim(); main.forEach(a=>{const l=document.createElement('a');l.className='ln';l.href=a.href;l.target='_blank';l.rel='noopener';l.innerHTML=`${esc(a.textContent)}${esc(by)}`;roll.appendChild(l);lastLn=l;}); return; } if(el.tagName==='P'&&lastLn){const s=document.createElement('span');s.className='desc';s.textContent=el.textContent;lastLn.appendChild(s);lastLn=null;return;} if(el.tagName==='P'){el.className='desc';roll.appendChild(el);return;} roll.appendChild(el); }); if(!keep.includes(roll))keep.push(roll); body.innerHTML='';keep.forEach(e=>body.appendChild(e)); } } let io; function observe(body){ io&&io.disconnect(); io=new IntersectionObserver(es=>es.forEach(e=>{if(e.isIntersecting){e.target.classList.add('in');io.unobserve(e.target);}}),{rootMargin:'0px 0px -12% 0px'}); body.querySelectorAll('h2,.slab,.blind').forEach(el=>io.observe(el)); } function route(){ cleanup.forEach(f=>f());cleanup=[]; const slug=decodeURIComponent(location.hash.slice(1)); const p=POSTS.find(x=>x.slug===slug); scrollTo(0,0); p?renderPost(p):renderIndex(); } Promise.all([fetch('../content/posts.json').then(r=>r.json()),document.fonts.load('900 100px "Anybody Variable"').catch(()=>{})]).then(([list])=>{ POSTS=list.map(p=>{p.s=stats(p);p.k=ART[p.slug]||(p.s.imgs>=4?'image':p.s.codeLines>=30?'code':p.s.words<320?'note':'prose');return p;}); addEventListener('hashchange',route); route(); });