Back to the app
The code
Jelly Orange Slice by GPT-6.2 Astra
Exactly as the AI wrote it. Shown as text, so nothing runs on this page.
index.html
works · auto-checked (Checked by an automated pass. Not hand-played yet.)<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Citrus Lab — Orange jelly</title><style>
*{box-sizing:border-box}body{margin:0;background:#f7f6ed;color:#253d2e;font-family:Arial,Helvetica,sans-serif}main{max-width:1530px;margin:auto;padding:0 5vw}header,footer,.row,.bar{display:flex;align-items:center;justify-content:space-between}header{height:84px;border-bottom:1px solid #bfc5b6}.brand{font:bold 23px Georgia;letter-spacing:-1px;display:flex;align-items:center;gap:11px}.mark{width:32px;height:32px;border:2px solid #314b35;border-radius:50%;background:repeating-conic-gradient(from 10deg,#314b35 0 3deg,transparent 4deg 44deg);box-shadow:inset 0 0 0 3px #f7f6ed}.mono,footer,label,.bar,output{font:10px/1.5 'Courier New',monospace;text-transform:uppercase;letter-spacing:1.5px}.status{display:flex;align-items:center;gap:8px}.dot{width:7px;height:7px;border-radius:50%;background:#66845c}.layout{display:grid;grid-template-columns:34% 66%;align-items:center;min-height:calc(100svh - 151px);padding:35px 0}.copy{z-index:1}.kicker{color:#9f4b1c;display:flex;align-items:center;gap:10px}.kicker:before{content:'';width:30px;height:2px;background:#df732c}h1{font:normal clamp(67px,7.8vw,119px)/.87 Georgia,serif;letter-spacing:-.075em;margin:24px 0}h1 i{color:#bb5318}p{font-size:15px;line-height:1.65;color:#566151;max-width:296px}.panel{max-width:332px;border-top:1px solid #b7bfaf;padding-top:20px;margin-top:32px}output{color:#a44818}input{width:100%;height:32px;margin:3px 0 15px;accent-color:#be591f;cursor:pointer}button{border:1px solid #b9c0b1;background:transparent;border-radius:8px;min-height:47px;color:inherit;padding:0 17px;font-size:14px;cursor:pointer}.buttons{display:flex;gap:10px}.primary{background:#294733;color:white;border-color:#294733;flex:1}.primary:active{background:#416249}.scene{position:relative;height:clamp(440px,71vh,800px);background:radial-gradient(ellipse at 48% 52%,#f5ebc9 0%,#f6f1dc 48%,#f7f6ed 73%)}canvas{width:100%;height:100%;display:block;touch-action:none;cursor:grab}canvas:active{cursor:grabbing}.bar{position:absolute;left:6%;right:3%;top:4%;color:#687361;pointer-events:none}.hint{position:absolute;bottom:3%;left:50%;transform:translateX(-50%);white-space:nowrap;color:#52614f;background:#f7f6eddd;border:1px solid #cbd0c1;padding:8px 15px;border-radius:25px;font-size:12px;pointer-events:none}footer{height:60px;border-top:1px solid #bfc5b6;color:#65725f} @media(max-width:740px){main{padding:0 6vw}header{height:60px}.layout{display:flex;flex-direction:column;align-items:stretch;padding:22px 0;min-height:auto}.copy{display:contents}h1{font-size:63px;margin:10px 0}h1 br{display:none}p{margin:0;max-width:none;font-size:14px}.scene{height:clamp(258px,39vh,395px);order:1}.panel{order:2;max-width:none;margin-top:9px;padding-top:11px}.bar{top:3%;font-size:8px}.hint{bottom:0}footer{font-size:8px}}
</style></head><body><main><header><div class="brand"><span class="mark"></span>Citrus Lab</div><div class="mono status"><span class="dot"></span>Live simulation</div></header><section class="layout"><div class="copy"><div class="mono kicker">Soft-body playground</div><h1>Orange<br> <i>jelly.</i></h1><p>Poke the slice, pull it gently, or give it a squeeze to release a little juice.</p><div class="panel"><div class="row"><label for="firm">Firmness</label><output id="value">45%</output></div><input id="firm" type="range" min="0" max="100" value="45"><div class="buttons"><button class="primary" id="squeeze">⇥ Squeeze ⇤</button><button id="reset">↺ Reset</button></div></div></div><div class="scene"><div class="bar"><span>Fig. 01 / Citrus slice</span><span>3D study</span></div><canvas id="view" aria-label="Interactive three-dimensional jelly orange slice"></canvas><span class="hint">✥ Drag to stretch</span></div></section><footer><span>Citrus Lab / Material studies</span><span>01 — Orange</span></footer></main><script>
const c=document.querySelector('canvas'),g=c.getContext('2d'),firm=document.querySelector('#firm'),val=document.querySelector('output'),TAU=Math.PI*2;
let seed=3412;function rand(){seed=(Math.imul(seed,1664525)+1013904223)>>>0;return seed/4294967296}
const tex=document.createElement('canvas');tex.width=1024;tex.height=530;const t=tex.getContext('2d'),cx=512,cy=10,R=492;
function pathArc(r,a,b){t.beginPath();t.moveTo(cx,cy);t.arc(cx,cy,r,a,b);t.closePath()}
pathArc(R,0,Math.PI);t.fillStyle='#f8990c';t.fill();pathArc(R-8,0,Math.PI);t.fillStyle='#fff1b4';t.fill();
for(let n=0;n<9;n++){let a=n*Math.PI/9+.009,b=(n+1)*Math.PI/9-.009;pathArc(R-21,a,b);let grad=t.createRadialGradient(cx,cy,15,cx+40,cy+15,R);grad.addColorStop(0,'#ffce47');grad.addColorStop(.49,n%2?'#ff9410':'#ffa612');grad.addColorStop(.84,'#f98209');grad.addColorStop(1,'#ffb424');t.fillStyle=grad;t.fill();t.save();t.clip();
for(let j=0;j<480;j++){let q=a+rand()*(b-a),r=Math.sqrt(rand())*(R-18),x=cx+Math.cos(q)*r,y=cy+Math.sin(q)*r,L=5+rand()*13,w=1.5+rand()*4;t.save();t.translate(x,y);t.rotate(q+(rand()-.5)*.65);t.beginPath();t.ellipse(0,0,L,w,0,0,TAU);let v=rand();t.fillStyle=v>.55?'rgba(255,223,86,.41)':'rgba(221,85,0,.24)';t.fill();t.strokeStyle='rgba(255,218,104,.35)';t.lineWidth=1;t.stroke();t.beginPath();t.ellipse(0,-.4,L*.82,w*.77,0,3.7,5.65);t.strokeStyle='rgba(255,251,195,'+(.12+rand()*.55)+')';t.lineWidth=1.4;t.stroke();t.restore()}t.restore()}
pathArc(18,0,Math.PI);t.fillStyle='#fff2bc';t.fill();
const nodes=[],faces=[],edges=[],seen=new Set();function node(x,y,z){nodes.push({x,y,z,X:x,Y:y,Z:z,u:0,v:0,w:0});return nodes.length-1}
function edge(a,b){let k=Math.min(a,b)+'/'+Math.max(a,b);if(seen.has(k))return;seen.add(k);let A=nodes[a],B=nodes[b];edges.push([a,b,Math.hypot(A.x-B.x,A.y-B.y,A.z-B.z)])}
let layers=[];const N=36,K=4;
for(let l=0;l<2;l++){let rings=[[node(0,-.39,l?.43:.015)]];for(let k=1;k<=K;k++){let ring=[];for(let i=0;i<=N;i++){let a=i*Math.PI/N,r=k/K;ring.push(node(Math.cos(a)*r,Math.sin(a)*r-.39,l?.43+.045*Math.sin(Math.PI*r):.015))}rings.push(ring)}layers.push(rings)}
function face(a,b,d,type){faces.push({ids:[a,b,d],type});edge(a,b);edge(b,d);edge(d,a)}
for(let l=0;l<2;l++){let rings=layers[l];for(let k=1;k<=K;k++)for(let i=0;i<N;i++){let a=rings[k-1][k===1?0:i],b=rings[k][i],d=rings[k][i+1];face(a,b,d,l?'top':'base');if(k>1)face(a,d,rings[k-1][i+1],l?'top':'base')}}
let boundary=[...layers[1][K]];for(let k=K-1;k>0;k--)boundary.push(layers[1][k][N]);boundary.push(layers[1][0][0]);for(let k=1;k<K;k++)boundary.push(layers[1][k][0]);let half=nodes.length/2;
for(let i=0;i<half;i++)edge(i,i+half);
for(let i=0;i<boundary.length;i++){let a=boundary[i],b=boundary[(i+1)%boundary.length];face(a,b,b-half,'side');face(a,b-half,a-half,'side')}
let W,H,S,OX,OY,ps=[],grab=null,press=0,held=false,drops=[],demo=location.hash.endsWith('#demo'),time=0,last=0;
function project(x,y,z){let X=.926*x-.378*y,Y=.378*x+.926*y;return [OX+X*S,OY+(Y*.64-z*.77)*S,Y+.8*z]}
function ellipse(x,y,rx,ry,fill){g.beginPath();g.ellipse(x,y,rx,ry,0,0,TAU);g.fillStyle=fill;g.fill()}
function plate(){let x=OX,y=OY+.035*S;g.save();g.shadowColor='#5c4b3954';g.shadowBlur=S*.11;g.shadowOffsetY=S*.095;ellipse(x,y,1.49*S,.86*S,'#d2cfc2');g.restore();let gr=g.createLinearGradient(x,y-S,x+.3*S,y+S);gr.addColorStop(0,'#fffef9');gr.addColorStop(.57,'#fffefa');gr.addColorStop(.87,'#e8e5db');gr.addColorStop(1,'#f9f8ef');ellipse(x,y-.024*S,1.49*S,.86*S,gr);let well=g.createLinearGradient(x,y-.7*S,x,y+.72*S);well.addColorStop(0,'#e2e0d5');well.addColorStop(.27,'#f4f2e9');well.addColorStop(.87,'#faf9f3');well.addColorStop(1,'#fff');ellipse(x,y,1.24*S,.689*S,well);g.save();g.filter='blur('+S*.05+'px)';ellipse(x,y+.035*S,.91*S,.35*S,'#8a66164a');g.restore()}
function texture(ids,P){let uv=ids.map(i=>[cx+nodes[i].X*R,cy+(nodes[i].Y+.39)*R]);let [a,b,d]=uv,[p,q,r]=P,A=b[0]-a[0],B=b[1]-a[1],C=d[0]-a[0],D=d[1]-a[1],det=A*D-B*C;
let m=((q[0]-p[0])*D-(r[0]-p[0])*B)/det,n=((r[0]-p[0])*A-(q[0]-p[0])*C)/det,o=((q[1]-p[1])*D-(r[1]-p[1])*B)/det,s=((r[1]-p[1])*A-(q[1]-p[1])*C)/det;g.save();g.clip();g.transform(m,o,n,s,p[0]-m*a[0]-n*a[1],p[1]-o*a[0]-s*a[1]);g.drawImage(tex,0,0);g.restore()}
let pores=Array.from({length:1300},()=>[rand()*N,rand(),rand()]);
function draw(){W=c.clientWidth;H=c.clientHeight;let dpi=Math.min(devicePixelRatio||1,2);if(c.width!==Math.round(W*dpi)||c.height!==Math.round(H*dpi)){c.width=Math.round(W*dpi);c.height=Math.round(H*dpi)}g.setTransform(dpi,0,0,dpi,0,0);g.clearRect(0,0,W,H);S=Math.min(W*.304,H*.421);OX=W*.5;OY=H*.54;plate();ps=nodes.map(n=>project(n.x,n.y,n.z));let sorted=faces.filter(f=>f.type!=='base').map(f=>[f,f.ids.reduce((s,i)=>s+ps[i][2],0)]).sort((a,b)=>a[1]-b[1]);
for(let [f] of sorted){let P=f.ids.map(i=>ps[i]),mx=P.reduce((s,p)=>s+p[0],0)/3,my=P.reduce((s,p)=>s+p[1],0)/3;g.beginPath();P.forEach((p,i)=>{let dx=p[0]-mx,dy=p[1]-my,mag=Math.hypot(dx,dy)||1;g[i?'lineTo':'moveTo'](p[0]+.7*dx/mag,p[1]+.7*dy/mag)});g.closePath();if(f.type==='top')texture(f.ids,P);else{let br=Math.max(0,Math.min(1,(mx-OX)/S*.47+.5));g.fillStyle='rgb( '+Math.round(255-21*br)+' '+Math.round(168-64*br)+' 8)';g.fill()}}
for(let [i,h,v] of pores){let j=Math.floor(i),a=layers[1][K][j],b=a+1,u=i-j,n=nodes[a],m=nodes[b];if(.378*n.X+.926*(n.Y+.39)<.12)continue;let p=project(n.x+(m.x-n.x)*u,n.y+(m.y-n.y)*u,n.z*h+nodes[a-half].z*(1-h));ellipse(p[0],p[1],S*(.0018+v*.003),S*.0026,v>.5?'#ffdb604f':'#a94e1340')}
for(let d of drops){let p=project(d.x,d.y,d.z);ellipse(p[0],p[1],d.r*S,d.r*S*(d.z>.03?1.2:.52),'rgba(247,155,17,.82)');ellipse(p[0]-d.r*S*.25,p[1]-d.r*S*.22,d.r*S*.33,d.r*S*.14,'#fff4bb')}}
function juice(){for(let j=0;j<5;j++){let a=.48+rand()*1.6;drops.push({x:Math.cos(a)*.92,y:Math.sin(a)*.92-.39,z:.18,v:.2+rand()*.5,dx:Math.cos(a)*(.25+rand()*.35),dy:Math.sin(a)*(.2+rand()*.35),r:.017+rand()*.02,age:0})}}
function squeeze(){press=.8;juice()}function reset(){for(let n of nodes)Object.assign(n,{x:n.X,y:n.Y,z:n.Z,u:0,v:0,w:0});grab=null;held=false;press=0;drops=[];firm.value=45;val.textContent='45%'}
function step(dt){let k=+firm.value*1.8+48;for(let [a,b,len] of edges){let n=nodes[a],m=nodes[b],x=m.x-n.x,y=m.y-n.y,z=m.z-n.z,L=Math.hypot(x,y,z)||1,F=(L-len)/L*k*dt; n.u+=F*x;n.v+=F*y;n.w+=F*z;m.u-=F*x;m.v-=F*y;m.w-=F*z}
let sq=held?1:Math.min(1,press*3);press=Math.max(0,press-dt);
for(let n of nodes){let ax=(n.X*(1+.09*sq)-n.x)*k*.68,ay=(n.Y-n.y)*k*.68,az=(n.Z*(1-.54*sq)-n.z)*k*.68;if(grab){let f=Math.exp(-6*((n.X-grab.n.X)**2+(n.Y-grab.n.Y)**2));ax+=f*115*grab.x;ay+=f*115*grab.y;az+=f*115*grab.z}let damp=Math.exp(-dt*4.9);n.u=(n.u+ax*dt)*damp;n.v=(n.v+ay*dt)*damp;n.w=(n.w+az*dt)*damp;n.x+=n.u*dt;n.y+=n.v*dt;n.z+=n.w*dt;if(n.z<.012){n.z=.012;n.w=Math.max(0,n.w)}}
for(let d of drops){d.age+=dt;if(d.z>.012||d.v>0){d.x+=d.dx*dt;d.y+=d.dy*dt;d.z+=d.v*dt;d.v-=3*dt;if(d.z<.012){d.z=.012;d.v=0}}}drops=drops.filter(d=>d.age<7)}
c.onpointerdown=e=>{let r=c.getBoundingClientRect(),x=e.clientX-r.left,y=e.clientY-r.top,best=Infinity,id=0;ps.forEach((p,i)=>{let dist=Math.hypot(x-p[0],y-p[1]);if(dist<best){best=dist;id=i}});if(best>S*.26)return;c.setPointerCapture(e.pointerId);grab={n:nodes[id],sx:x,sy:y,x:0,y:0,z:-.17};nodes[id].w=-1.6};
c.onpointermove=e=>{if(!grab||!c.hasPointerCapture(e.pointerId))return;let r=c.getBoundingClientRect(),dx=(e.clientX-r.left-grab.sx)/S,dy=(e.clientY-r.top-grab.sy)/S,cl=v=>Math.max(-.48,Math.min(.48,v));grab.x=cl(.926*dx+.378*dy);grab.y=cl(-.378*dx+.926*dy);grab.z=cl(-dy*.65-.07)};c.onlostpointercapture=()=>grab=null;
document.querySelector('#squeeze').onpointerdown=e=>{e.currentTarget.setPointerCapture(e.pointerId);held=true;squeeze()};document.querySelector('#squeeze').onlostpointercapture=()=>{held=false;press=.14};document.querySelector('#squeeze').onclick=e=>{if(!e.detail)squeeze()};document.querySelector('#reset').onclick=reset;firm.oninput=()=>val.textContent=firm.value+'%';document.addEventListener('pointerdown',()=>{if(demo){demo=false;grab=null}},{capture:true});
function frame(now){let dt=Math.min(.034,(now-last)/1000);last=now;if(demo){let old=time;time=(time+dt)%20;if(time<old)reset();if(time>2&&time<5)grab={n:nodes[half+K],x:.35*Math.sin((time-2)*.9),y:0,z:.22};else grab=null;if(old<8&&time>=8||old<15&&time>=15)squeeze();if(time>11&&time<13){firm.value=Math.round(45+(time-11)*20);val.textContent=firm.value+'%'}}for(let i=0;i<4;i++)step(dt/4);draw();requestAnimationFrame(frame)}requestAnimationFrame(frame);
</script></body></html>
