// ───────────────────────── data ───────────────────────── const ART = { // per-post art direction: kind, chrome shape id, tint 'css-grid-lanes': { kind:'note', shape:4, tint:[1.0,0.92,0.78], device:'bondi' }, 'spool': { kind:'code', shape:2, tint:[0.9,1.0,0.85] }, 'ferrotype': { kind:'code', shape:1, tint:[1.0,0.78,0.62] }, 'building-ui-in-gpui': { kind:'code', shape:3, tint:[0.86,0.95,1.0] }, 'the-black-magic-of-canvas-and-text-editing': { kind:'note', shape:5, tint:[0.92,0.86,1.0], device:'white' }, 'fig-gen-making-generative-art-in-figma': { kind:'image', shape:6, tint:[0.85,0.93,1.0] }, 'writing-with-adhd': { kind:'prose', shape:7, tint:[1.0,0.86,0.95] }, 'design-workshop': { kind:'image', shape:8, tint:[0.88,1.0,0.95] }, }; const KIND_LABEL = { code:'Source', image:'Gallery', prose:'Longform', note:'Memo' }; let POSTS = []; function stats(p){ const d = document.createElement('div'); d.innerHTML = p.html; const pres = [...d.querySelectorAll('pre')]; const codeLines = pres.reduce((n,x)=>n+x.querySelectorAll('.line').length,0); pres.forEach(x=>x.remove()); const words = (d.textContent.match(/\S+/g)||[]).length; const imgs = [...d.querySelectorAll('img')].map(i=>i.src); return { words, codeLines, blocks:pres.length, imgs, mins:Math.max(1,Math.round(words/230)) }; } function classify(p){ const a = ART[p.slug]; if (a) return a; const s = p.s; return { kind: s.imgs.length>=4?'image': s.codeLines>=30?'code': s.words<320?'note': 'prose', shape:0, tint:[1,1,1] }; } const fmt = d => new Date(d+'T12:00:00').toLocaleDateString('en-US',{year:'numeric',month:'short',day:'2-digit'}).toUpperCase(); const esc = s => s.replace(/[&<>"]/g,c=>({'&':'&','<':'<','>':'>','"':'"'}[c])); // ───────────────────────── chrome shader ───────────────────────── const gl = (()=>{ const c = document.getElementById('gl'); const g = c.getContext('webgl',{premultipliedAlpha:true,alpha:true,antialias:false}); if(!g) return null; const vs = `attribute vec2 p;void main(){gl_Position=vec4(p,0.,1.);}`; const fs = ` precision highp float; uniform vec2 uRes; uniform float uTime; uniform vec2 uMouse; uniform float uA, uB, uMix; uniform vec3 uTint; uniform vec3 uPos; uniform float uSpin; mat2 rot(float a){float c=cos(a),s=sin(a);return mat2(c,-s,s,c);} float smin(float a,float b,float k){float h=clamp(.5+.5*(b-a)/k,0.,1.);return mix(b,a,h)-k*h*(1.-h);} float sdBox(vec3 p,vec3 b,float r){vec3 q=abs(p)-b;return length(max(q,0.))+min(max(q.x,max(q.y,q.z)),0.)-r;} float sdTorus(vec3 p,vec2 t){vec2 q=vec2(length(p.xz)-t.x,p.y);return length(q)-t.y;} float sdCyl(vec3 p,float h,float r){vec2 d=abs(vec2(length(p.xz),p.y))-vec2(r,h);return min(max(d.x,d.y),0.)+length(max(d,0.));} float shape(float id, vec3 p){ float t=uTime; if(id<.5){ // metaball cluster float d=length(p)-.85; for(int i=0;i<5;i++){float f=float(i); vec3 c=vec3(sin(t*.7+f*1.7)*1.15,cos(t*.53+f*2.3)*.85,sin(t*.41+f*1.1)*.6); d=smin(d,length(p-c)-(.36+.1*sin(f*3.+t)),.6);} return smin(d,length(p-vec3(uMouse*1.4,.8))-.28,.7); } if(id<1.5){ // ferrotype: twisted iron plate vec3 q=p; q.xz*=rot(q.y*.55+sin(t*.6)*.4); return sdBox(q,vec3(.95,1.25,.12),.12); } if(id<2.5){ // spool vec3 q=p; q.yz*=rot(1.2); q.xy*=rot(.3); float core=sdCyl(q,.9,.42+.04*sin(q.y*30.)); float r1=sdCyl(q-vec3(0,.92,0),.09,1.05)-.05; float r2=sdCyl(q+vec3(0,.92,0),.09,1.05)-.05; float thread=sdTorus(q.xzy*vec3(1,1,1)-vec3(0,0,0),vec2(.62,.18)); return min(min(r1,r2),smin(core,sdCyl(q,.7,.62+.03*sin(q.y*40.+t*2.)),.05)); } if(id<3.5){ // gpui: window slab float b=sdBox(p,vec3(1.2,.85,.18),.14); float w=sdBox(p-vec3(0,-.1,.25),vec3(1.0,.58,.2),.05); float dots=length(p-vec3(-.95,.68,.3))-.07; dots=min(dots,length(p-vec3(-.75,.68,.3))-.07); dots=min(dots,length(p-vec3(-.55,.68,.3))-.07); return min(max(b,-w),dots); } if(id<4.5){ // grid lanes: masonry columns float d=1e9; for(int i=0;i<3;i++){float f=float(i); float h=.35+.25*sin(t*.9+f*2.1)+.2*f; d=smin(d,sdBox(p-vec3((f-1.)*.72,h-.6,0.),vec3(.28,h,.28),.08),.12); d=smin(d,sdBox(p-vec3((f-1.)*.72,h*2.-.25+.35,0.),vec3(.28,.18,.28),.08),.1);} return d; } if(id<5.5){ // black magic: rippling crystal ball float r=length(p); return r-1.05-.06*sin(9.*p.x+t*2.)*sin(9.*p.y-t*1.5)*sin(9.*p.z+t); } if(id<6.5){ // fig-gen: sine-strung beads float d=1e9; for(int i=0;i<9;i++){float f=float(i)-4.; vec3 c=vec3(f*.28,sin(f*.9+t*1.4)*.75,cos(f*.7+t)*.35); d=smin(d,length(p-c)-(.17+.05*cos(f+t*2.)),.22);} return d; } if(id<7.5){ // adhd: wandering, scattering float d=1e9; for(int i=0;i<7;i++){float f=float(i); vec3 c=vec3(sin(t*(.5+f*.13)+f*4.)*1.3,cos(t*(.37+f*.11)+f*2.)*1.,sin(t*(.29+f*.07)+f)*.7); d=smin(d,length(p-c)-(.24+.08*sin(f)),.45);} return d; } // design workshop: faceted rock vec3 q=abs(p); float d=dot(q,normalize(vec3(1,1,1)))-.95; d=max(d,dot(q,normalize(vec3(1,.2,.5)))-.9); d=max(d,dot(q,normalize(vec3(.3,1,.4)))-.88); d=max(d,dot(q,normalize(vec3(.4,.3,1)))-.82); d=max(d,dot(p,normalize(vec3(-.6,.8,.2)))-.7); return d; } float map(vec3 p){ p.xz*=rot(uTime*.18+uMouse.x*.5+uSpin); p.yz*=rot(-uMouse.y*.4+.15); float a=shape(uA,p), b=shape(uB,p); return mix(a,b,uMix); } vec3 nrm(vec3 p){vec2 e=vec2(.002,-.002);return normalize(e.xyy*map(p+e.xyy)+e.yyx*map(p+e.yyx)+e.yxy*map(p+e.yxy)+e.xxx*map(p+e.xxx));} vec3 env(vec3 r){ float y=r.y; vec3 sky=mix(vec3(.97,.98,1.),vec3(.42,.6,.92),smoothstep(.02,.9,y)); vec3 gnd=mix(vec3(.05,.05,.07),vec3(.32,.31,.35),smoothstep(-.8,-.02,y)); vec3 c=y>0.?sky:gnd; c+=vec3(1.)*exp(-abs(y)*28.)*1.1; c+=vec3(1.,.98,.95)*smoothstep(.88,.96,dot(r,normalize(vec3(-.6,.65,.45))))*1.4; c+=vec3(.9,.95,1.)*smoothstep(.93,.98,dot(r,normalize(vec3(.85,.25,.4))))*1.; c+=vec3(.75,1.,.2)*smoothstep(.96,.995,dot(r,normalize(vec3(.2,-.3,.95))))*.6; float band=sin(atan(r.z,r.x)*3.+y*6.); c=mix(c,c*vec3(.85,.9,1.05),.25*smoothstep(.6,1.,band)); return c; } void main(){ vec2 uv=(gl_FragCoord.xy-.5*uRes)/uRes.y; uv=(uv-uPos.xy)/uPos.z; vec3 ro=vec3(0,0,4.4), rd=normalize(vec3(uv,-1.75)); float t=0.,d; bool hit=false; for(int i=0;i<80;i++){d=map(ro+rd*t); if(d<.0015){hit=true;break;} t+=d*.85; if(t>9.)break;} if(!hit){ // soft contact glow float g=exp(-d*3.)*.0; gl_FragColor=vec4(0.); return; } vec3 p=ro+rd*t, n=nrm(p), r=reflect(rd,n); float fr=pow(1.-max(dot(n,-rd),0.),3.); vec3 col=env(r); vec3 irid=.5+.5*cos(6.2831*(vec3(0.,.33,.67)+dot(n,-rd)*1.3+uTime*.04)); col=mix(col,col*irid*1.5,.22+fr*.25); col*=uTint; col+=fr*.25; col=pow(col,vec3(.95)); gl_FragColor=vec4(col,1.); }`; function sh(t,s){const o=g.createShader(t);g.shaderSource(o,s);g.compileShader(o);if(!g.getShaderParameter(o,g.COMPILE_STATUS))console.error(g.getShaderInfoLog(o));return o;} const pr=g.createProgram();g.attachShader(pr,sh(g.VERTEX_SHADER,vs));g.attachShader(pr,sh(g.FRAGMENT_SHADER,fs));g.linkProgram(pr);g.useProgram(pr); const b=g.createBuffer();g.bindBuffer(g.ARRAY_BUFFER,b);g.bufferData(g.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),g.STATIC_DRAW); const loc=g.getAttribLocation(pr,'p');g.enableVertexAttribArray(loc);g.vertexAttribPointer(loc,2,g.FLOAT,false,0,0); const U={};['uRes','uTime','uMouse','uA','uB','uMix','uTint','uPos','uSpin'].forEach(k=>U[k]=g.getUniformLocation(pr,k)); const S={a:0,b:0,mix:1,tint:[1,1,1],tintT:[1,1,1],pos:[.42,0,1],posT:[.42,0,1],mouse:[0,0],mouseT:[0,0],spin:0,spinV:0}; const scale=.6; function resize(){const w=innerWidth,h=innerHeight;c.width=Math.round(w*scale);c.height=Math.round(h*scale);g.viewport(0,0,c.width,c.height);} addEventListener('resize',resize);resize(); addEventListener('pointermove',e=>{S.mouseT=[(e.clientX/innerWidth-.5)*2,-(e.clientY/innerHeight-.5)*2];}); let lastY=scrollY; const t0=performance.now(); function frame(now){ const t=(now-t0)/1000; S.mix=Math.min(1,S.mix+0.022); const e=S.mix<1?S.mix*S.mix*(3-2*S.mix):1; for(let i=0;i<3;i++){S.tint[i]+=(S.tintT[i]-S.tint[i])*.05;S.pos[i]+=(S.posT[i]-S.pos[i])*.06;} for(let i=0;i<2;i++)S.mouse[i]+=(S.mouseT[i]-S.mouse[i])*.06; const dy=scrollY-lastY;lastY=scrollY;S.spinV+=dy*.0016;S.spinV*=.92;S.spin+=S.spinV; if(window.__postMode){ // shrink & drift with scroll const k=Math.min(1,scrollY/700); S.posT=[...window.__postPos]; S.posT[1]=window.__postPos[1]+k*.18; S.posT[2]=window.__postPos[2]*(1-k*.35); } g.uniform2f(U.uRes,c.width,c.height);g.uniform1f(U.uTime,t);g.uniform2f(U.uMouse,S.mouse[0],S.mouse[1]); g.uniform1f(U.uA,S.a);g.uniform1f(U.uB,S.b);g.uniform1f(U.uMix,e);g.uniform3fv(U.uTint,S.tint);g.uniform3fv(U.uPos,S.pos);g.uniform1f(U.uSpin,S.spin); g.drawArrays(g.TRIANGLES,0,3); requestAnimationFrame(frame); } requestAnimationFrame(frame); return { to(shape,tint,pos){ if(!S.init){S.init=1;S.a=S.b=shape;S.mix=1;S.tint=[...tint];S.pos=[...pos];} if(shape!==S.b){S.a=S.b;S.b=shape;S.mix=0;} S.tintT=tint; S.posT=pos; }, }; })(); function blobLayout(mode){ const narrow = innerWidth<900, asp=innerWidth/innerHeight; if(mode==='index') return narrow?[.12,.33,.3]:[.5*asp-.3,.04,.46]; return narrow?[.2,.34,.3]:[.5*asp-.24,.2,.34]; } // ───────────────────────── views ───────────────────────── const app = document.getElementById('app'); function orbInner(p){ const k=p.a.kind; if(k==='image') return ``; return `${String(POSTS.indexOf(p)+1).padStart(2,'0')}`; } function capExtra(p){ const k=p.a.kind; if(k==='code'){ const d=document.createElement('div');d.innerHTML=p.html; const lines=[...d.querySelectorAll('pre .line')].map(l=>l.textContent.trim()).filter(l=>l.length>8).slice(0,4).join(' · '); return `${esc(lines)}`; } if(k==='prose') return `${p.s.words.toLocaleString()} words`; if(k==='image') return `${p.s.imgs.length} frames`; return `${p.s.words} words`; } function renderIndex(){ window.__postMode=false; gl&&gl.to(0,[1,1,1],blobLayout('index')); document.title='nate.rip — liquid chrome'; const counts={};POSTS.forEach(p=>counts[p.a.kind]=(counts[p.a.kind]||0)+1); app.innerHTML=`
WRITING · TOOLS · TINKERING — EST. 2015

nate.rip

Nate Butler builds design tools and writes about Rust, canvases, type systems and the strange business of making things.

${['code','image','prose','note'].map(k=>`${KIND_LABEL[k]} · ${counts[k]||0}`).join('')}
© NATE BUTLER${POSTS.length} ENTRIES IN MEMORY
`; // hovering a capsule previews its chrome form app.querySelectorAll('.cap').forEach(el=>{ const p=POSTS.find(x=>'#'+x.slug===el.getAttribute('href')); el.addEventListener('pointerenter',()=>gl&&gl.to(p.a.shape,p.a.tint,blobLayout('index'))); el.addEventListener('pointerleave',()=>gl&&gl.to(0,[1,1,1],blobLayout('index'))); }); } function enhance(root,p){ const accent={code:'var(--lime)',image:'var(--ice)',prose:'var(--pink)',note:'var(--amber)'}[p.a.kind]; root.style.setProperty('--c',accent); // drop duplicate h1 const h1=root.querySelector('h1'); if(h1&&h1.textContent.trim().toLowerCase()===p.title.toLowerCase()) h1.remove(); root.querySelectorAll('pre').forEach((pre,i)=>{ const bay=document.createElement('div');bay.className='bay'; const n=pre.querySelectorAll('.line').length; const txt=pre.textContent; const lang=/#\[|fn |let |impl |struct |::/.test(txt)?'RUST':/^\s*(cargo|spool|npm|git)\b/m.test(txt)?'SHELL':/[{};]\s*$/m.test(txt)&&/:\s/.test(txt)&&/\.|display/.test(txt)?(/type |interface |\|/.test(txt)?'TYPESCRIPT':'CSS'):/type |interface /.test(txt)?'TYPESCRIPT':'TEXT'; bay.innerHTML=`
  BAY ${String(i+1).padStart(2,'0')} — ${lang}${n} LN
`; pre.replaceWith(bay);bay.appendChild(pre); }); let flip=0; root.querySelectorAll('img').forEach(img=>{ const host=img.closest('p')||img; const fig=document.createElement('figure');fig.className='gel '+(flip++%2?'tr':'tl'); img.loading='lazy'; fig.appendChild(img); if(img.alt){const c=document.createElement('figcaption');c.textContent=img.alt;fig.appendChild(c);} host.replaceWith(fig); img.addEventListener('click',()=>{const lb=document.createElement('div');lb.className='lb';lb.innerHTML=``;lb.onclick=()=>lb.remove();document.body.appendChild(lb);}); }); root.querySelectorAll('a[href^="http"]').forEach(a=>{a.target='_blank';a.rel='noopener'}); root.querySelectorAll(':scope > *').forEach(el=>el.classList.add('reveal')); } function renderPost(p){ const i=POSTS.indexOf(p), prev=POSTS[i+1], next=POSTS[i-1]; window.__postMode=true; window.__postPos=blobLayout('post'); gl&&gl.to(p.a.shape,p.a.tint,window.__postPos); document.title=p.title+' — nate.rip'; const k=p.a.kind; const meta=`
DATE${fmt(p.date)} WORDS${p.s.words.toLocaleString()} READ${p.s.mins} MIN ${p.s.codeLines?`CODE${p.s.codeLines} LN`:''} ${p.s.imgs.length?`FRAMES${p.s.imgs.length}`:''}
`; const head=`
${KIND_LABEL[k]} · Nº ${String(i+1).padStart(2,'0')}

${esc(p.title)}

${meta}
`; let body; if(k==='note'){ const host=new URL(location.href).host||'nate.rip'; body=`
${esc(p.title)} : NetRip v3.1?×
http://nate.rip/${p.slug}
${p.html}
◐ あ ✎ ▲${fmt(p.date)} ▮▮▮
PERSONAL · WRITING · TOOL
NATE.RIP
${prev?`Prev`:'—'} Home OK Top ${next?`Next`:'—'}
`; } else { body=`
${p.html}
`; } const pager=``; app.innerHTML=`
${head}${body}${pager}
`; const art=document.getElementById('body');enhance(art,p); if(k==='prose') buildGauge(art); } let gaugeCleanup=null; function buildGauge(art){ const g=document.createElement('div');g.className='gauge';g.innerHTML='
'; app.appendChild(g); const hs=[...art.querySelectorAll('h2')]; const ticks=hs.map(h=>{const t=document.createElement('div');t.className='tick';t.innerHTML=`${esc(h.textContent)}`;g.appendChild(t);return t;}); const fill=g.querySelector('.fill'); function upd(){ const top=art.getBoundingClientRect().top+scrollY, H=art.offsetHeight, vh=innerHeight; const p=Math.min(1,Math.max(0,(scrollY+vh*.5-top)/H)); fill.style.setProperty('--p',(p*100)+'%'); hs.forEach((h,i)=>{const hp=(h.getBoundingClientRect().top+scrollY-top)/H;ticks[i].style.top=(100-hp*100)+'%';ticks[i].classList.toggle('on',p>=hp);}); } addEventListener('scroll',upd,{passive:true});upd(); gaugeCleanup=()=>removeEventListener('scroll',upd); } let io; function observeReveal(){ 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 -8% 0px'}); document.querySelectorAll('.reveal').forEach(el=>io.observe(el)); } function route(){ gaugeCleanup&&gaugeCleanup();gaugeCleanup=null; const w=document.getElementById('wipe');w.classList.remove('go');void w.offsetWidth;w.classList.add('go'); const slug=decodeURIComponent(location.hash.slice(1)); const p=POSTS.find(x=>x.slug===slug); if(p) renderPost(p); else renderIndex(); scrollTo(0,0); } // clock setInterval(()=>{const d=new Date();document.getElementById('clock').textContent=d.toTimeString().slice(0,5);},1000); document.getElementById('clock').textContent=new Date().toTimeString().slice(0,5); fetch('../content/posts.json').then(r=>r.json()).then(list=>{ POSTS=list.map(p=>{p.s=stats(p);return p;}); POSTS.forEach(p=>p.a=classify(p)); addEventListener('hashchange',route); addEventListener('resize',()=>{window.__postPos=blobLayout(window.__postMode?'post':'index');if(!window.__postMode&&gl)gl.to(0,[1,1,1],blobLayout('index'));}); route(); });