Subscribe

Build

Full page

SourceQwen4 35B-A3B MTP, Extra high effort · OpenCode · 04.12.2026 06:15

index.html · 15.9 KB · 453 lines. Exactly as the agent wrote it.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="theme-color" content="#0e0d16"><meta name="color-scheme" content="dark"><title>Glow Lamp — lava lamp simulation</title><style>  *{margin:0;padding:0;box-sizing:border-box}  html,body{height:100%;overflow:hidden}  body{    background:radial-gradient(120% 100% at 50% 18%, #191627 0%, #0e0d16 62%, #090811 100%);    font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;    user-select:none;-webkit-user-select:none;touch-action:manipulation;  }  #scene{position:fixed;inset:0;display:block}  #lava{position:fixed;pointer-events:none;filter:url(#goo)}  #sheen{    position:fixed;pointer-events:none;transition:opacity .9s ease;    background:linear-gradient(100deg,      rgba(255,255,255,0) 24%,      rgba(255,255,255,.10) 39%,      rgba(255,255,255,.02) 50%,      rgba(255,255,255,.13) 61%,      rgba(255,255,255,0) 76%);  }  body.off #sheen{opacity:.14}  #dim{position:fixed;inset:0;pointer-events:none;background:rgba(6,4,14,.62);opacity:0;transition:opacity .9s ease}  body.off #dim{opacity:1}  #ui{position:fixed;inset:0;pointer-events:none}  #switch{    position:fixed;left:50%;transform:translateX(-50%);    width:74px;height:42px;border-radius:21px;    background:linear-gradient(#3a3752,#221f33);    border:1px solid rgba(255,255,255,.09);    box-shadow:inset 0 2px 6px rgba(0,0,0,.55),0 6px 18px rgba(0,0,0,.45);    cursor:pointer;pointer-events:auto;-webkit-tap-highlight-color:transparent;    transition:box-shadow .35s,background .35s;  }  #switch:focus-visible{outline:2px solid #ffb066;outline-offset:3px}  #switch.on{background:linear-gradient(#54426a,#332747);box-shadow:inset 0 2px 6px rgba(0,0,0,.4),0 0 24px rgba(255,120,50,.35)}  #knob{    position:absolute;top:4px;left:4px;width:32px;height:32px;border-radius:50%;    background:radial-gradient(circle at 35% 28%,#ffffff,#c9c6dd 45%,#8f8ba8 72%,#6f6b86);    box-shadow:0 3px 7px rgba(0,0,0,.5),inset 0 -2px 3px rgba(0,0,0,.25);    transition:transform .22s cubic-bezier(.55,.06,.35,1.4);  }  #switch.on #knob{transform:translateX(32px)}  #hint{    position:fixed;left:0;right:0;bottom:max(10px,env(safe-area-inset-bottom));    text-align:center;color:rgba(235,228,255,.38);font-size:12px;letter-spacing:.16em;    pointer-events:none;transition:opacity .6s ease;  }</style></head><body><canvas id="scene"></canvas><canvas id="lava"></canvas><div id="dim"></div><div id="ui">  <div id="sheen"></div>  <button id="switch" class="on" type="button" aria-label="Lamp switch"><span id="knob"></span></button>  <div id="hint">tap the switch</div></div><svg width="0" height="0" style="position:absolute" aria-hidden="true">  <defs>    <filter id="goo" x="-40%" y="-40%" width="180%" height="180%" color-interpolation-filters="sRGB">      <feGaussianBlur id="gooBlur" in="SourceGraphic" stdDeviation="5" result="b"/>      <feColorMatrix in="b" mode="matrix"        values="1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -7"/>    </filter>  </defs></svg><script>"use strict";/* ---------- tiny helpers ---------- */const clamp=(v,a,b)=>v<a?a:v>b?b:v;const lerp=(a,b,t)=>a+(b-a)*t;const rand=(a,b)=>a+Math.random()*(b-a);/* ---------- canvases ---------- */const scene=document.getElementById('scene');const sctx=scene.getContext('2d');const lava=document.getElementById('lava');const lctx=lava.getContext('2d');const gooBlur=document.getElementById('gooBlur');const hintEl=document.getElementById('hint');let W=0,H=0,DPR=1;const LV={x:0,y:0,w:0,h:0}; // lava canvas region = glass + blur margin/* ---------- lamp geometry (computed on resize) ---------- */const G={cx:0,deskY:0,glassTop:0,glassBot:0,glassW:0,baseTop:0,baseBot:0,heaterY:0};/* ---------- wax blobs ---------- */const blobs=[];const MAX_BLOBS=14;/* physics constants */const P={  buoy:260,         // upward accel per unit of (temp - neutral)  drag:1.6,  heatRate:1.1,     // temp gain per second inside heater zone  // slow cooling is what lets hot wax cross the whole glass before it sinks  coolRate:0.075,  ambientOn:0.34,   // settled wax cools below neutral, so it sinks  ambientOff:0.30,  // lamp off: everything drifts down to the plate  neutral:0.55,     // temp at which buoyancy is zero  mergeDist:0.8,    // fraction of summed radii that triggers merge  splitTemp:0.72,   // min temp for a big blob to split  splitSize:1.32,   // min radius, as a multiple of the base blob radius  wander:8};function blobRadius(){ // radius in px, set on resize  return clamp(G.glassW*0.07, 7, 26);}function makeBlob(x,y,r){  return {x,y,vx:0,vy:0,r,T:P.ambientOn*0.5,seed:Math.random()*1000};}function seedBlobs(){  blobs.length=0;  const n=7;  for(let i=0;i<n;i++){    const r=blobRadius()*rand(0.7,1.25);    const x=G.cx+rand(-G.glassW*0.3,G.glassW*0.3);    const y=rand(G.glassTop+G.glassW*0.4, G.glassBot-G.glassW*0.3);    const nb=makeBlob(x,y,r);    nb.T=rand(0.35,0.85); // varied warmth so the lamp starts mid-circulation    blobs.push(nb);  }}/* ---------- layout ---------- */function layout(){  const deskH=Math.min(H*0.16, 120);  G.deskY=H-deskH;  // lamp vertical span: leave room for base + headroom  const topPad=H*0.06;  const baseH=Math.min(H*0.14, 96);  G.baseBot=G.deskY;  G.baseTop=G.baseBot-baseH;  G.glassBot=G.baseTop;  G.glassTop=topPad+baseH*0.15;  // glass width fits phone width  const maxW=Math.min(W*0.42, 190);  const hSpan=G.glassBot-G.glassTop;  G.glassW=Math.min(maxW, hSpan*0.34);  G.cx=W/2;  G.heaterY=G.glassBot-Math.min(hSpan*0.22, 70); // warm zone near bottom  // position the HTML switch on the lamp base  const sw=document.getElementById('switch');  sw.style.top=(G.baseTop+baseH*0.5-21)+'px';}/* ---------- static scene: drawn only on resize ---------- */function drawScene(){  const c=sctx, cx=G.cx, gW=G.glassW;  c.clearRect(0,0,W,H);  // pool of light behind the lamp  const gy=(G.glassTop+G.glassBot)*0.58;  let rg=c.createRadialGradient(cx,gy,gW*0.15,cx,gy,gW*3.6);  rg.addColorStop(0,'rgba(255,140,66,.20)');  rg.addColorStop(.5,'rgba(150,82,190,.10)');  rg.addColorStop(1,'rgba(0,0,0,0)');  c.fillStyle=rg;c.fillRect(0,0,W,H);  // desk  const dg=c.createLinearGradient(0,G.deskY,0,H);  dg.addColorStop(0,'#241e37');dg.addColorStop(1,'#0b0913');  c.fillStyle=dg;c.fillRect(0,G.deskY,W,H-G.deskY);  c.fillStyle='rgba(255,255,255,.08)';c.fillRect(0,G.deskY,W,1);  // contact shadow  c.save();  c.translate(cx,G.baseBot+5);c.scale(1,.2);  const sg=c.createRadialGradient(0,0,0,0,0,gW*1.6);  sg.addColorStop(0,'rgba(0,0,0,.6)');sg.addColorStop(1,'rgba(0,0,0,0)');  c.fillStyle=sg;c.beginPath();c.arc(0,0,gW*1.6,0,6.2832);c.fill();  c.restore();  // liquid body  glassPath(c);  const lg=c.createLinearGradient(0,G.glassTop,0,G.glassBot);  lg.addColorStop(0,'rgba(94,72,140,.30)');  lg.addColorStop(.6,'rgba(128,72,132,.34)');  lg.addColorStop(1,'rgba(214,112,58,.42)');  c.fillStyle=lg;c.fill();  // heater bloom + side shading, clipped to the glass  c.save();glassPath(c);c.clip();  const hg=c.createRadialGradient(cx,G.heaterY,0,cx,G.heaterY,gW*1.2);  hg.addColorStop(0,'rgba(255,180,96,.8)');  hg.addColorStop(.45,'rgba(255,118,54,.32)');  hg.addColorStop(1,'rgba(255,90,40,0)');  c.fillStyle=hg;c.fillRect(cx-gW*1.4,G.heaterY-gW*1.4,gW*2.8,gW*2.8);  const sh=c.createLinearGradient(cx-gW*.5,0,cx+gW*.5,0);  sh.addColorStop(0,'rgba(0,0,0,.3)');sh.addColorStop(.3,'rgba(0,0,0,0)');  sh.addColorStop(.7,'rgba(0,0,0,0)');sh.addColorStop(1,'rgba(0,0,0,.3)');  c.fillStyle=sh;c.fillRect(cx-gW,G.glassTop,gW*2,G.glassBot-G.glassTop);  c.restore();  // glass outline  glassPath(c);  c.lineWidth=2;c.strokeStyle='rgba(228,216,255,.3)';c.stroke();  // cap  const capW=halfWidthAt(G.glassTop)*2, capH=Math.min(30,gW*.28);  c.beginPath();  c.moveTo(cx-capW*.43,G.glassTop-capH);  c.lineTo(cx+capW*.43,G.glassTop-capH);  c.lineTo(cx+capW*.5,G.glassTop);  c.lineTo(cx-capW*.5,G.glassTop);  c.closePath();  const cg=c.createLinearGradient(0,G.glassTop-capH,0,G.glassTop);  cg.addColorStop(0,'#6d6586');cg.addColorStop(.5,'#3c3552');cg.addColorStop(1,'#241f34');  c.fillStyle=cg;c.fill();  c.lineWidth=1;c.strokeStyle='rgba(255,255,255,.15)';c.stroke();  // base  const tW=gW*1.22, bW=gW*1.78;  c.beginPath();  c.moveTo(cx-tW/2,G.baseTop);  c.lineTo(cx+tW/2,G.baseTop);  c.lineTo(cx+bW/2,G.baseBot);  c.lineTo(cx-bW/2,G.baseBot);  c.closePath();  const bg=c.createLinearGradient(cx-bW/2,0,cx+bW/2,0);  bg.addColorStop(0,'#191627');bg.addColorStop(.3,'#4b4462');  bg.addColorStop(.56,'#2e2942');bg.addColorStop(1,'#131120');  c.fillStyle=bg;c.fill();  c.lineWidth=1;c.strokeStyle='rgba(255,255,255,.11)';c.stroke();  // heater spill along the top rim of the base  c.beginPath();c.moveTo(cx-tW/2+3,G.baseTop+1.5);c.lineTo(cx+tW/2-3,G.baseTop+1.5);  c.lineWidth=2;c.strokeStyle='rgba(255,152,82,.5)';c.stroke();}/* ---------- layer sizing ---------- */function sizeLava(){  const pad=22;              // margin for the goo blur + threshold  const LD=Math.min(DPR,1.5);// cap the filtered surface so the blur stays cheap  // keep blur proportional to the wax: a fixed sigma would thin small blobs  // below the alpha threshold and make them flicker out of existence  gooBlur.setAttribute('stdDeviation',clamp(blobRadius()*0.42,3,5.5).toFixed(2));  LV.x=Math.round(G.cx-G.glassW*.5-pad);  LV.y=Math.round(G.glassTop-pad);  LV.w=Math.round(G.glassW+pad*2);  LV.h=Math.round(G.glassBot-G.glassTop+pad*2);  lava.style.left=LV.x+'px';lava.style.top=LV.y+'px';  lava.style.width=LV.w+'px';lava.style.height=LV.h+'px';  lava.width=Math.round(LV.w*LD);lava.height=Math.round(LV.h*LD);  // draw in page coordinates  lctx.setTransform(LD,0,0,LD,-LV.x*LD,-LV.y*LD);  // glass highlight, clipped to the tapered silhouette  const m=6, sh=document.getElementById('sheen');  const bx=G.cx-G.glassW*.5-m, by=G.glassTop-m;  const bw=G.glassW+m*2, bh=G.glassBot-G.glassTop+m*2;  const tW=halfWidthAt(G.glassTop), bW=halfWidthAt(G.glassBot);  const pt=(x,y)=>((x-bx)/bw*100).toFixed(2)+'% '+((y-by)/bh*100).toFixed(2)+'%';  sh.style.left=bx+'px';sh.style.top=by+'px';  sh.style.width=bw+'px';sh.style.height=bh+'px';  sh.style.clipPath='polygon('+    pt(G.cx-tW,G.glassTop)+','+pt(G.cx+tW,G.glassTop)+','+    pt(G.cx+bW,G.glassBot)+','+pt(G.cx-bW,G.glassBot)+')';}function resize(){  DPR=Math.min(window.devicePixelRatio||1,2);  W=window.innerWidth;H=window.innerHeight;  scene.width=Math.round(W*DPR);scene.height=Math.round(H*DPR);  scene.style.width=W+'px';scene.style.height=H+'px';  sctx.setTransform(DPR,0,0,DPR,0,0);  layout();  sizeLava();  drawScene();}window.addEventListener('resize',resize);window.addEventListener('orientationchange',resize);/* ---------- physics ---------- */let on=true;function halfWidthAt(y){  // glass tapers: wider at bottom, narrower at top (classic cone)  const t=clamp((y-G.glassTop)/(G.glassBot-G.glassTop),0,1);  const wBot=G.glassW*0.5, wTop=G.glassW*0.30;  return lerp(wTop,wBot,t);}function step(dt){  const ambient=on?P.ambientOn:P.ambientOff;  for(const b of blobs){    // temperature: heat near the bottom while on, cool toward ambient    const inHeater=on && b.y>G.heaterY-b.r;    if(inHeater){      const d=clamp((b.y-G.heaterY)/Math.max(1,G.glassBot-G.heaterY),0,1);      b.T+=P.heatRate*dt*(1.25-d*0.6); // strong at the plate, softer toward the glass wall    }    b.T+=(ambient-b.T)*P.coolRate*dt;    b.T=clamp(b.T,0,1);    // buoyancy: warm rises (negative y), cool sinks    const drive=(b.T-P.neutral)*P.buoy;    b.vy-=drive*dt;    // gentle wandering so blobs don't stack in a perfect column    b.vx+=Math.sin(perf*0.001+b.seed)*P.wander*dt*(b.T*0.6+0.4);    b.vy+=Math.cos(perf*0.0013+b.seed*1.7)*P.wander*0.4*dt;    // drag    const d=Math.exp(-P.drag*dt);    b.vx*=d;b.vy*=d;    b.x+=b.vx*dt;b.y+=b.vy*dt;    // walls of the tapered glass    const hw=Math.max(1,halfWidthAt(b.y)-b.r); // never inverts on tiny screens    if(b.x<G.cx-hw){b.x=G.cx-hw;b.vx=Math.abs(b.vx)*0.4;}    if(b.x>G.cx+hw){b.x=G.cx+hw;b.vx=-Math.abs(b.vx)*0.4;}    // floor (the heater plate) and ceiling    if(b.y>G.glassBot-b.r){b.y=G.glassBot-b.r;b.vy=-Math.abs(b.vy)*0.25;}    if(b.y<G.glassTop+b.r*0.8){b.y=G.glassTop+b.r*0.8;b.vy=Math.abs(b.vy)*0.25;}  }  handleMerges();  handleSplits(dt);}function handleMerges(){  for(let i=0;i<blobs.length;i++){    for(let j=i+1;j<blobs.length;j++){      const a=blobs[i],c=blobs[j];      const dx=c.x-a.x,dy=c.y-a.y;      const dist=Math.hypot(dx,dy);      if(dist < (a.r+c.r)*P.mergeDist && dist>0.001){        // volume-conserving merge (r^3)        const va=a.r*a.r*a.r, vc=c.r*c.r*c.r, vt=va+vc;        a.x=(a.x*va+c.x*vc)/vt;        a.y=(a.y*va+c.y*vc)/vt;        a.r=Math.cbrt(vt);        a.T=(a.T*va+c.T*vc)/vt;        a.vx=(a.vx*va+c.vx*vc)/vt;        a.vy=(a.vy*va+c.vy*vc)/vt;        blobs.splice(j,1);        j--; // re-check same i against shifted array      }    }  }}function handleSplits(dt){  const minR=blobRadius()*P.splitSize;  // only blobs bigger than this split  for(let i=blobs.length-1;i>=0;i--){    const b=blobs[i];    if(blobs.length>=MAX_BLOBS) break;    if(b.r<minR) continue;              // only big blobs split    if(b.T<P.splitTemp) continue;         // only warm blobs split    // stochastic split while warm and large    if(Math.random()<dt*0.9){      const r2=b.r*Math.cbrt(0.5);        // two halves conserve volume      const ang=rand(0,Math.PI*2);      const off=r2*0.9;      const nx=Math.cos(ang)*off, ny=Math.sin(ang)*off;      const nb=makeBlob(b.x+nx,b.y+ny,r2);      nb.T=b.T; nb.vx=b.vx+nx*1.4; nb.vy=b.vy+ny*1.4;      b.r=r2; b.x-=nx*0.5; b.y-=ny*0.5;      b.vx-=nx*0.8; b.vy-=ny*0.8;      blobs.push(nb);    }  }}/* ---------- drawing helpers ---------- */function glassPath(c){  // tapered cone: narrow at the top, wide at the bottom  const tW=halfWidthAt(G.glassTop), bW=halfWidthAt(G.glassBot);  c.beginPath();  c.moveTo(G.cx-tW,G.glassTop);  c.lineTo(G.cx+tW,G.glassTop);  c.lineTo(G.cx+bW,G.glassBot);  c.lineTo(G.cx-bW,G.glassBot);  c.closePath();}function waxColor(w){ // 0 = cool wax, 1 = hot wax  const r=lerp(184,255,w)|0, g=lerp(48,157,w)|0, b=lerp(110,46,w)|0;  return `rgb(${r},${g},${b})`;}function drawBlob(c,b){  const w=clamp((b.T-P.neutral)*1.7+0.45,0,1);  const r=b.r;  c.fillStyle=waxColor(w);  c.beginPath();c.arc(b.x,b.y,r,0,6.2832);c.fill();  // specular core: opaque underneath, so the goo threshold keeps it  c.fillStyle=`rgba(255,226,178,${0.25+w*0.35})`;  c.beginPath();c.arc(b.x-r*0.28,b.y-r*0.32,r*0.42,0,6.2832);c.fill();}function render(){  lctx.clearRect(LV.x,LV.y,LV.w,LV.h);  lctx.save();  glassPath(lctx);          // keep wax inside the silhouette  lctx.clip();  for(const b of blobs) drawBlob(lctx,b);  lctx.restore();}/* ---------- main loop ---------- */let perf=0,last=0;function frame(t){  requestAnimationFrame(frame);  if(!last)last=t;  let dt=(t-last)/1000;last=t;  perf=t;  dt=Math.min(dt,0.033); // clamp to keep physics stable on hitches  step(dt);  render();}/* ---------- switch ---------- */const switchEl=document.getElementById('switch');function setOn(v){  on=v;  document.body.classList.toggle('off',!on);  switchEl.classList.toggle('on',on);  switchEl.setAttribute('aria-pressed',String(on));}function toggle(){ setOn(!on); hintEl.style.opacity='0'; }switchEl.addEventListener('click',toggle);window.addEventListener('keydown',e=>{  if(e.code==='Space'||e.code==='Enter'){e.preventDefault();toggle();}});/* ---------- boot ---------- */resize();seedBlobs();setOn(true);requestAnimationFrame(frame);</script></body></html>