A tiny friend in your Mac's notch and on your iPhone that keeps an eye on your AI coding agents: Claude Code, Codex, Cursor, Gemini CLI, Antigravity and more. Approve from the notch or your Lock Screen.
Swift ai-agentsanthropicantigravityclaudeclaude-codecodexcursordynamic-islandgemini-cliiosiphonlinuxmacosmacos-appmenubar-appnotchopen-sourceswiftswiftuiwindows
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<title>Notch Buddy · séquence de dépôt (référence)</title>
<style>
:root{box-sizing:border-box;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px);
--bg:#E2E4E8;--ink:#16171B;--muted:#5F646D;--panel:#fff;--line:#D1D4DA;--chip:#EDEFF2}
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){--bg:#131417;--ink:#ECEDEF;--muted:#9A9FA8;--panel:#1E2024;--line:#32353B;--chip:#2A2D32}}
:root[data-theme="dark"]{--bg:#131417;--ink:#ECEDEF;--muted:#9A9FA8;--panel:#1E2024;--line:#32353B;--chip:#2A2D32}
*,*::before,*::after{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif}
.wrap{max-width:1000px;margin:0 auto;padding:26px 20px 40px}
h1{margin:0;font-size:24px;letter-spacing:-.02em}
p{margin:6px 0 16px;color:var(--muted);font-size:14px;line-height:1.45;max-width:70ch}
.stage{background:#07080A;border-radius:18px;overflow:hidden;box-shadow:0 20px 40px -24px rgba(0,0,0,.6)}
canvas{display:block;width:100%;height:auto}
.bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;margin-top:14px}
button{appearance:none;border:1px solid var(--line);background:var(--panel);color:var(--ink);border-radius:999px;padding:8px 14px;font:inherit;font-size:13.5px;cursor:pointer}
button.on{background:var(--ink);color:var(--panel);border-color:var(--ink)}
input[type=range]{flex:1;min-width:200px}
.t{font-family:"SF Mono",ui-monospace,Menlo,monospace;font-size:13px;min-width:170px}
.phase{font-size:14px;font-weight:600;min-width:260px}
</style>
</head>
<body>
<div class="wrap">
<h1>Séquence de dépôt, référence exacte</h1>
<p>Tout est une fonction du temps : le même instant donne toujours la même image. Coordonnées en points, dans le repère de l'island (640 de large, 176 de haut). À porter tel quel dans l'app.</p>
<div class="stage"><canvas id="c" width="1280" height="560"></canvas></div>
<div class="bar">
<button id="play" class="on">Pause</button>
<button id="restart">Recommencer</button>
<button id="slow">Ralenti ×4</button>
<button id="guides">Repères</button>
<button id="snd">Son</button>
<span class="t" id="t">t = 0.000 s</span>
</div>
<div class="bar"><input type="range" id="scrub" min="0" max="7.2" step="0.001" value="0"><span class="phase" id="phase"></span></div>
</div>
<script>
(()=>{
/* ====================== CONSTANTES (repère island, points) ====================== */
const W=640, H=280; // scène : island 640x176 + 104 sous l'island pour l'approche du curseur
const ISL_H=176; // hauteur de l'island pendant TOUTE la séquence (pas de saut de hauteur)
const CARD={x:10,y:36,w:588,h:130,r:20}; // carte / zone de dépôt (laisse 42 à droite pour la colonne d'agents)
const REST={x:140,y:101}; // position de repos de la boîte
const D_BOX=62; // diamètre du corps en zone de dépôt
const FOLLOW={min:CARD.x+50,max:CARD.x+CARD.w-50};
const TEXT={x:196,y:94}; // « Dépose tes fichiers ici »
const BAR={x0:46,x1:520,y:118}; // barre de progression
const CHOOSE={x:60,y:101,d:52}; // place du Mochi dans la vue « choose »
const LOCK_IN=60, LOCK_OUT=90; // verrouillage sous le fichier
const MOUTH={ajar:.20,open:.42,max:.50}; // hauteurs de la bouche, en fraction de R
const GREEN='#34D399', GREEN_D='#1FA87A', GREEN_L='#6EE7B7';
const T={drop:1.95, suckStart:2.03, suckEnd:2.33, closeEnd:2.42, chew1:2.60, chew2:2.74, chewEnd:2.88,
shrinkEnd:3.23, barIn:3.00, progStart:3.25, progEnd:5.05, growStart:5.30, growEnd:5.75, end:7.2};
/* trajet du curseur (le fichier est sous le curseur) */
const PATH=[[0.00,600,262],[0.35,470,150],[0.80,330,70],[1.25,210,50],[1.65,140,36],[1.95,140,36]];
/* ====================== OUTILS ====================== */
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v)), lerp=(a,b,t)=>a+(b-a)*t;
const E={out:t=>1-Math.pow(1-t,3),in:t=>t*t*t,inOut:t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2,
back:t=>{const c1=1.70158,c3=c1+1;return 1+c3*Math.pow(t-1,3)+c1*Math.pow(t-1,2)}};
const seg=(t,a,b)=>clamp((t-a)/(b-a),0,1);
function cursorAt(t){ for(let i=1;i<PATH.length;i++){ const [t0,x0,y0]=PATH[i-1],[t1,x1,y1]=PATH[i]; if(t<=t1){ const k=E.inOut(seg(t,t0,t1)); return {x:lerp(x0,x1,k),y:lerp(y0,y1,k)} } } const l=PATH[PATH.length-1]; return {x:l[1],y:l[2]} }
function inZone(p){ return p.x>CARD.x-40&&p.x<CARD.x+CARD.w+40&&p.y<ISL_H+26 }
// ressort critique-ish à pas fixe
function spring(s,target,response,damping,dt){ const k=Math.pow(2*Math.PI/response,2), c=2*damping*Math.sqrt(k); const a=k*(target-s.v)-c*s.vel; s.vel+=a*dt; s.v+=s.vel*dt }
// keyframes [[t, valeur], ...] avec easing sur chaque segment
function kf(t,keys,ease=E.inOut){ if(t<=keys[0][0])return keys[0][1]; for(let i=1;i<keys.length;i++){ if(t<=keys[i][0]){ const k=seg(t,keys[i-1][0],keys[i][0]); return lerp(keys[i-1][1],keys[i][1],(keys[i][2]||ease)(k)) } } return keys[keys.length-1][1] }
function progressCurve(u){ if(u<.4) return .6*E.out(u/.4); if(u<.85) return .6+.32*E.inOut((u-.4)/.45); return .92+.08*E.in((u-.85)/.15) }
/* ====================== SIMULATION (pas fixe 1/240 s) ====================== */
const DT=1/240;
function newSim(){ return {t:0, bx:{v:REST.x,vel:0}, by:{v:REST.y,vel:0}, tilt:0, mouth:{v:0,vel:0}, locked:false, lockAt:-9, entered:-9, events:[], lastPct:0} }
let S=newSim();
function step(s){
const t=s.t, c=cursorAt(t), dragging=t<T.drop;
if(dragging&&s.entered<0&&inZone(c)){ s.entered=t; s.events.push('enter') }
// suivi horizontal + verrouillage
if(dragging&&s.entered>=0){
const dist=Math.hypot(c.x-s.bx.v,(c.y+14)-s.by.v);
const c2=cursorAt(Math.max(0,t-.05)), speed=Math.hypot(c.x-c2.x,c.y-c2.y)/.05;
if(!s.locked&&dist<LOCK_IN&&speed<180){ s.locked=true; s.lockAt=t; s.events.push('lock') }
if(s.locked&&dist>LOCK_OUT){ s.locked=false }
const tx=clamp(c.x,FOLLOW.min,FOLLOW.max), ty=REST.y;
if(s.locked){ spring(s.bx,tx,.18,.75,DT); spring(s.by,ty,.18,.75,DT) } else { spring(s.bx,tx,.35,.7,DT); spring(s.by,ty,.35,.7,DT) }
}
s.tilt=lerp(s.tilt, dragging?clamp(s.bx.vel*.0015,-.18,.18):0, 1-Math.pow(.0005,DT));
// bouche
let mt=0; if(s.entered>=0&&t<T.suckEnd) mt=s.locked||t>=T.drop?MOUTH.open:MOUTH.ajar;
if(t>=T.drop&&t<T.suckEnd) mt=MOUTH.max;
if(t>=T.suckEnd) mt=0;
if(t>=T.suckEnd) s.mouth.v=Math.max(0,lerp(MOUTH.max,0,E.in(seg(t,T.suckEnd,T.closeEnd)))); else spring(s.mouth,mt,.25,.6,DT);
if(s.mouth.v<0) s.mouth.v=0;
// sons (événements)
if(t>=T.suckEnd&&!s.gulp){ s.gulp=1; s.events.push('gulp') }
const pr=progressAt(t); const pc=Math.floor(pr*10); if(t>T.progStart&&pc>s.lastPct){ s.lastPct=pc; s.events.push('tick') }
if(t>=T.progEnd&&!s.ok){ s.ok=1; s.events.push('approve') }
s.t+=DT;
}
function simulateTo(t){ if(t<S.t-1e-9) S=newSim(); while(S.t<t) step(S) }
function progressAt(t){ return t<T.progStart?0:progressCurve(seg(t,T.progStart,T.progEnd)) }
/* ====================== ÉTAT DÉRIVÉ POUR UN INSTANT ====================== */
function frame(t){
const s=S, c=cursorAt(t), f={t,cursor:c};
const entered=s.entered>=0?s.entered:1e9;
// morph 0 (rond) -> 1 (boîte) à l'entrée, retour 1 -> 0 pendant le rétrécissement
f.morph=t<T.chewEnd? E.back(seg(t,entered,entered+.38)) : 1-E.out(seg(t,T.chewEnd,T.shrinkEnd));
f.morph=clamp(f.morph,0,1.08);
// position / taille du Mochi
let x=s.bx.v, y=s.by.v, d=D_BOX;
if(t>=T.chewEnd&&t<T.progStart){ const k=E.inOut(seg(t,T.chewEnd,T.shrinkEnd)); x=lerp(s.bx.v,BAR.x0,k); y=lerp(s.by.v,BAR.y,k); d=lerp(D_BOX,14,k) }
if(t>=T.progStart){ const p=progressAt(t); x=lerp(BAR.x0,BAR.x1,p); y=BAR.y; d=14 }
if(t>=T.progEnd){ x=BAR.x1; y=BAR.y-8*Math.sin(Math.PI*seg(t,T.progEnd,T.progEnd+.2)) }
if(t>=T.growStart){ const k=E.back(seg(t,T.growStart,T.growEnd)); x=lerp(BAR.x1,CHOOSE.x,E.inOut(seg(t,T.growStart,T.growEnd))); y=lerp(BAR.y,CHOOSE.y,E.inOut(seg(t,T.growStart,T.growEnd))); d=lerp(14,CHOOSE.d,k) }
f.x=x; f.y=y; f.d=d;
// échelle (écrasements)
let sx=1, sy=1;
if(t>=T.drop&&t<T.suckStart){ const k=E.out(seg(t,T.drop,T.suckStart)); sy=lerp(1,.92,k); sx=lerp(1,1.06,k) }
if(t>=T.suckStart&&t<T.suckEnd){ const k=E.inOut(seg(t,T.suckStart,T.suckEnd)); sy=lerp(.92,1.06,k); sx=lerp(1.06,.97,k) }
if(t>=T.suckEnd&&t<T.chew1){ sy=kf(t,[[T.suckEnd,1.06],[T.suckEnd+.07,.82,E.out],[T.suckEnd+.2,1.1,E.out],[T.chew1,1]]); sx=kf(t,[[T.suckEnd,.97],[T.suckEnd+.07,1.14,E.out],[T.suckEnd+.2,.95,E.out],[T.chew1,1]]) }
if(t>=T.chew1&&t<T.chewEnd){ const k=((t-T.chew1)%.14)/.14; sy=1-.05*Math.sin(Math.PI*k); sx=1+.03*Math.sin(Math.PI*k) }
if(t>=T.chewEnd&&t<T.shrinkEnd){ const k=seg(t,T.chewEnd,T.shrinkEnd); sy=1+.12*Math.sin(Math.PI*k); sx=1-.06*Math.sin(Math.PI*k) }
if(t>=T.progStart&&t<T.progEnd){ const v=(progressAt(t+.01)-progressAt(t))/.01; const st=clamp(v*.18,0,1); sx=1+.25*st; sy=1-.15*st }
if(t>=T.growStart&&t<T.growEnd){ const k=seg(t,T.growStart,T.growEnd); sy=1+.06*Math.sin(Math.PI*k) }
f.sx=sx; f.sy=sy; f.tilt=s.tilt;
// saut au verrouillage
f.hop=s.lockAt>0&&t<T.drop?-5*Math.sin(Math.PI*seg(t,s.lockAt,s.lockAt+.15)):0;
f.mouth=s.mouth.v;
// yeux
f.eye='pill';
if(s.locked&&t<T.suckEnd) f.eye='cup';
if(t>=T.suckEnd&&t<T.chewEnd+.1) f.eye='content';
if(t>=T.progEnd&&t<T.growEnd+.3) f.eye='content';
const look=t<T.suckEnd?{x:c.x-x,y:(c.y+10)-y}:t<T.progStart?{x:0,y:0}:{x:40,y:0};
f.lookX=clamp(look.x/200,-1,1); f.lookY=clamp(look.y/150,-1,1);
// fichier
f.fileVisible=t<T.suckEnd; f.suck=seg(t,T.suckStart,T.suckEnd);
// contenu
f.zoneOver=s.entered>=0&&t<T.chewEnd&&inZone(c);
f.zoneAlpha=1-seg(t,T.chewEnd,T.chewEnd+.2);
const overlap=clamp(1-Math.abs((x+32)-(TEXT.x-8))/40,0,1)*(x+32>TEXT.x-8?1:0);
f.textAlpha=f.zoneAlpha*(x>TEXT.x-40&&t<T.drop?.25:1);
f.barReveal=E.out(seg(t,T.barIn,T.barIn+.25))*(1-seg(t,T.growStart,T.growStart+.2));
f.barAlpha=seg(t,T.barIn+.05,T.barIn+.25)*(1-seg(t,T.growStart,T.growStart+.2));
f.progress=progressAt(t);
f.flash=t>=T.progEnd?Math.sin(Math.PI*seg(t,T.progEnd,T.progEnd+.3)):0;
f.check=t>=T.progEnd?E.back(seg(t,T.progEnd,T.progEnd+.25)):0;
f.greenWash=Math.max(f.zoneOver?.35:0, t>=T.progEnd?.5*seg(t,T.progEnd,T.progEnd+.3)*(1-seg(t,T.growEnd,T.growEnd+.6)):0);
f.chooseAlpha=seg(t,T.growStart+.15,T.growEnd);
return f;
}
/* ====================== DESSIN ====================== */
const cv=document.getElementById('c'), X=cv.getContext('2d'); const K=cv.width/W;
let guides=false;
function rr(x,a,b,w,h,r){r=Math.max(0,Math.min(r,w/2,h/2));x.beginPath();x.moveTo(a+r,b);x.arcTo(a+w,b,a+w,b+h,r);x.arcTo(a+w,b+h,a,b+h,r);x.arcTo(a,b+h,a,b,r);x.arcTo(a,b,a+w,b,r);x.closePath()}
function bodyPath(m,R){ // superellipse : exposant 2.15 (rond Mochi v2) -> 5.5 (boîte)
const n=lerp(2.15,5.5,clamp(m,0,1)), rx=R*lerp(1.04,1.0,clamp(m,0,1)), ry=R*lerp(.97,.94,clamp(m,0,1)), p=new Path2D();
for(let i=0;i<=96;i++){ const a=i/96*Math.PI*2, ca=Math.cos(a), sa=Math.sin(a); const px=rx*Math.sign(ca)*Math.pow(Math.abs(ca),2/n), py=ry*Math.sign(sa)*Math.pow(Math.abs(sa),2/n); i?p.lineTo(px,py):p.moveTo(px,py) }
p.closePath(); return {p,rx,ry};
}
function drawEye(shape,w,h){
switch(shape){
case 'cup': { const hh=h*.55; X.beginPath(); X.moveTo(-w/2,-hh/2); X.lineTo(w/2,-hh/2); X.lineTo(w/2,hh/2-w/2); X.arc(0,hh/2-w/2,w/2,0,Math.PI); X.closePath(); X.fill(); break }
case 'content': X.lineWidth=w*.5; X.lineCap='round'; X.beginPath(); X.arc(0,-h*.12,w*.85,Math.PI*.15,Math.PI*.85); X.stroke(); break;
default: rr(X,-w/2,-h/2,w,h,w/2); X.fill();
}
}
function drawMochi(f){
const R=f.d/2/1.04, m=f.morph;
X.save(); X.translate(f.x,f.y+f.hop); X.rotate(f.tilt); X.scale(f.sx,f.sy);
const {p,rx,ry}=bodyPath(m,R);
// corps mat : dégradé clair haut-droite -> gris bas-gauche
const g=X.createLinearGradient(rx*.7,-ry*.9,-rx*.8,ry*.9); g.addColorStop(0,'#EDEDEF'); g.addColorStop(1,'#C4C5CA'); X.fillStyle=g; X.fill(p);
const sh=X.createRadialGradient(rx*.2,-ry*.25,R*.2,0,0,R*1.3); sh.addColorStop(0,'rgba(0,0,0,0)'); sh.addColorStop(.62,'rgba(0,0,0,0)'); sh.addColorStop(1,'rgba(0,0,0,.12)'); X.fillStyle=sh; X.fill(p);
// liseré clair du rebord haut (boîte)
if(m>.3){ X.save(); X.clip(p); X.strokeStyle=`rgba(255,255,255,${.6*clamp((m-.3)/.7,0,1)})`; X.lineWidth=1.2; X.beginPath(); X.moveTo(-rx*.72,-ry+.9); X.lineTo(rx*.72,-ry+.9); X.stroke(); X.restore() }
// bouche : trou en pilule À L'INTÉRIEUR, rebord tout autour, ancré en haut
const mh=f.mouth*R*clamp(m,0,1);
if(mh>.3){ const mw=2*rx-2*.12*R, mx=-mw/2, my=-ry+.10*R;
X.save(); X.clip(p);
const ig=X.createLinearGradient(0,my,0,my+mh); ig.addColorStop(0,'#030304'); ig.addColorStop(1,'#101114'); X.fillStyle=ig; rr(X,mx,my,mw,mh,mh/2); X.fill();
X.strokeStyle='rgba(255,255,255,.55)'; X.lineWidth=1; X.beginPath(); X.moveTo(mx+mh/2,my+mh+.5); X.lineTo(mx+mw-mh/2,my+mh+.5); X.stroke();
if(guides){ X.strokeStyle='#F0F'; X.lineWidth=.5; rr(X,mx,my,mw,mh,mh/2); X.stroke() }
X.restore(); f._mouth={x:f.x+mx*f.sx,w:mw*f.sx,y:f.y+f.hop+my*f.sy,h:mh*f.sy} } else f._mouth={x:f.x-rx*.8,w:rx*1.6,y:f.y-ry+.1*R,h:0};
// yeux : pilules, rond -> boîte ils descendent et rétrécissent, regard borné dans la boîte
X.save(); X.clip(p); X.fillStyle='#0E0F12'; X.strokeStyle='#0E0F12';
const mm=clamp(m,0,1), ew=R*.25, eh=R*lerp(.62,.46,mm), ey=R*lerp(.02,.30,mm), sp=R*.30;
const lx=f.lookX*R*lerp(.34,.26,mm), ly=f.lookY*R*lerp(.16,.07,mm);
for(const sd of[-1,1]){ X.save(); X.translate(sd*sp+lx,ey+ly); drawEye(f.eye,ew,eh); X.restore() }
X.restore();
if(guides){ X.strokeStyle='#0FF'; X.lineWidth=.5; X.stroke(p) }
X.restore();
}
function drawFile(f){
const c=f.cursor;
if(f.suck<=0){ X.save(); X.globalAlpha=.92; drawDoc(c.x,c.y+14,1,1,1); X.restore(); return }
// aspiration : entonnoir (bord bas qui se resserre), descend dans la bouche, masqué sous le haut de la bouche
const p=E.in(f.suck), m=f._mouth, W0=34, H0=42;
const topY=lerp(c.y+14-H0/2, m.y-2, E.inOut(f.suck));
const hs=lerp(1.08,.55,E.inOut(f.suck)), Hh=H0*hs, sc=lerp(1,.55,p);
X.save(); X.beginPath(); X.rect(0,0,W,m.y+m.h*.5); X.clip();
const q=E.out(f.suck); const N=28; for(let i=0;i<N;i++){ const v0=i/N, v1=(i+1)/N; const wsc=lerp(1,lerp(.92,.22*m.w/W0,Math.pow(v0,1.2)),q)*sc;
const cx=lerp(c.x,m.x+m.w/2,E.out(f.suck)), yy=topY+v0*Hh, hh=Hh/N+.6; const wob=Math.sin(f.suck*Math.PI*2)*.1*(1-p);
X.save(); X.translate(cx,yy); X.rotate(wob); X.beginPath(); X.rect(-W0*wsc/2,0,W0*wsc,hh); X.clip(); X.translate(-cx,-yy);
drawDoc(cx,topY+Hh/2,wsc,hs,1,topY,Hh); X.restore() }
X.restore();
// particules vertes aspirées
for(let i=0;i<4;i++){ const a=i/4*Math.PI*2+.6, r0=24; const k=clamp((f.suck-i*.08)/.7,0,1); if(k<=0||k>=1)continue;
const sx0=c.x+Math.cos(a)*r0, sy0=c.y+14+Math.sin(a)*r0, ex=m.x+m.w/2, ey=m.y+m.h*.3; const kk=Math.pow(k,.7);
X.fillStyle=`rgba(52,211,153,${1-k})`; X.beginPath(); X.arc(lerp(sx0,ex,kk),lerp(sy0,ey,kk)-Math.sin(Math.PI*k)*6,2.2*(1-k*.5),0,Math.PI*2); X.fill() }
}
function drawDoc(cx,cy,wsc,hsc,alpha,top,hh){ // icône de document générique (la vraie app utilise l'icône du fichier)
const w=34*wsc, h=42*hsc, x=cx-w/2, y=(top!==undefined?top:cy-h/2); const fold=8*Math.min(wsc,hsc);
X.save(); X.globalAlpha*=alpha; X.shadowColor='rgba(0,0,0,.45)'; X.shadowBlur=8; X.shadowOffsetY=3;
X.fillStyle='#F4F4F6'; X.beginPath(); X.moveTo(x+2,y); X.lineTo(x+w-fold,y); X.lineTo(x+w,y+fold); X.lineTo(x+w,y+h-2); X.quadraticCurveTo(x+w,y+h,x+w-2,y+h); X.lineTo(x+2,y+h); X.quadraticCurveTo(x,y+h,x,y+h-2); X.lineTo(x,y+2); X.quadraticCurveTo(x,y,x+2,y); X.fill();
X.shadowColor='transparent'; X.fillStyle='#D5D6DB'; X.beginPath(); X.moveTo(x+w-fold,y); X.lineTo(x+w-fold,y+fold); X.lineTo(x+w,y+fold); X.fill();
X.fillStyle='#3B82F6'; rr(X,x+w*.18,y+h*.58,w*.64,h*.16,2); X.fill(); X.restore();
}
function drawCursor(c,down){ X.save(); X.translate(c.x,c.y); if(down) X.scale(.88,.88); X.fillStyle='#fff'; X.strokeStyle='#000'; X.lineWidth=1.1; X.lineJoin='round';
X.beginPath(); X.moveTo(0,0); X.lineTo(0,16); X.lineTo(4,12.4); X.lineTo(7,19); X.lineTo(9.6,17.8); X.lineTo(6.7,11.4); X.lineTo(11.6,11.4); X.closePath(); X.fill(); X.stroke(); X.restore() }
function text(s,x,y,size,weight,color,align='left'){ X.font=`${weight} ${size}px -apple-system,BlinkMacSystemFont,"SF Pro Text",system-ui,sans-serif`; X.fillStyle=color; X.textAlign=align; X.textBaseline='middle'; X.fillText(s,x,y) }
function chip(s,x,y){ X.font='500 11px -apple-system,system-ui,sans-serif'; const w=X.measureText(s).width+16; X.fillStyle='rgba(255,255,255,.07)'; rr(X,x,y-9,w,18,9); X.fill(); text(s,x+8,y,11,500,'#B9BDC4'); return w+6 }
function draw(t){
simulateTo(t); const f=frame(t);
X.setTransform(K,0,0,K,0,0); X.clearRect(0,0,W,H);
// fond écran + island
X.fillStyle='#0B0D12'; X.fillRect(0,0,W,H);
X.fillStyle='#000'; rr(X,-30,-30,W+60,ISL_H+30,30); X.fill();
// en-tête (simplifié)
X.fillStyle='#1D1F23'; rr(X,108,4,44,26,13); X.fill();
X.fillStyle='#8E939C'; X.beginPath(); X.moveTo(24,20); X.lineTo(31,13); X.lineTo(38,20); X.lineTo(38,25); X.lineTo(24,25); X.fill();
X.beginPath(); X.arc(72,18,7,0,Math.PI*2); X.fill();
X.strokeStyle='#F5F6F8'; X.lineWidth=1.8; X.lineCap='round'; X.beginPath(); X.moveTo(130,12); X.lineTo(130,22); X.moveTo(125,17); X.lineTo(135,17); X.stroke();
X.fillStyle='#8E939C'; X.beginPath(); X.arc(578,17,6,0,Math.PI*2); X.fill(); X.fillStyle='#000'; X.beginPath(); X.arc(578,17,2.5,0,Math.PI*2); X.fill();
// colonne d'agents
['#FF5A4E','#2EC4A0','#F29B38'].forEach((c,i)=>{ X.fillStyle=c; X.beginPath(); X.arc(W-10-21,36+14+i*24,8,0,Math.PI*2); X.fill() });
// carte
X.save(); rr(X,CARD.x,CARD.y,CARD.w,CARD.h,CARD.r); X.clip();
X.fillStyle='#121316'; X.fillRect(CARD.x,CARD.y,CARD.w,CARD.h);
if(f.greenWash>0){ const gw=X.createRadialGradient(CARD.x+CARD.w/2,CARD.y+CARD.h*1.3,10,CARD.x+CARD.w/2,CARD.y+CARD.h*1.3,CARD.w*.6); gw.addColorStop(0,`rgba(52,211,153,${f.greenWash})`); gw.addColorStop(1,'rgba(52,211,153,0)'); X.fillStyle=gw; X.fillRect(CARD.x,CARD.y,CARD.w,CARD.h) }
X.restore();
// bordure pointillée fine
if(f.zoneAlpha>0){ X.save(); X.globalAlpha=f.zoneAlpha; X.setLineDash([6,5]); X.lineWidth=1.5; X.strokeStyle=f.zoneOver?'rgba(52,211,153,.55)':'rgba(255,255,255,.14)'; rr(X,CARD.x+.75,CARD.y+.75,CARD.w-1.5,CARD.h-1.5,CARD.r); X.stroke(); X.restore()
X.save(); X.globalAlpha=f.textAlpha; text('Dépose tes fichiers ici',TEXT.x,TEXT.y-4,13,500,'#D5D7DB'); let cx=TEXT.x; for(const s of['PDF','Images','Code','Docs']) cx+=chip(s,cx,TEXT.y+18); X.restore() }
// barre de progression
if(f.barAlpha>0||f.barReveal>0){ X.save(); X.globalAlpha=Math.max(f.barAlpha,.001);
text('Envoi de capture.png',BAR.x0,BAR.y-30,12.5,500,'#A9ADB5');
if(f.check>0){ X.save(); X.translate(BAR.x1-8,BAR.y-30); X.scale(f.check,f.check); X.fillStyle=GREEN; X.beginPath(); X.arc(0,0,8,0,Math.PI*2); X.fill(); X.strokeStyle='#07130E'; X.lineWidth=2; X.lineCap='round'; X.lineJoin='round'; X.beginPath(); X.moveTo(-3.6,.2); X.lineTo(-1,2.8); X.lineTo(3.8,-2.6); X.stroke(); X.restore() }
else { X.font='500 12.5px ui-monospace,"SF Mono",Menlo,monospace'; text(Math.round(f.progress*100)+' %',BAR.x1,BAR.y-30,12.5,500,'#A9ADB5','right') }
const L=(BAR.x1-BAR.x0)*f.barReveal; X.fillStyle='rgba(255,255,255,.08)'; rr(X,BAR.x0,BAR.y-3,L,6,3); X.fill();
const fx=lerp(BAR.x0,BAR.x1,f.progress); if(fx>BAR.x0+1){ const g=X.createLinearGradient(BAR.x0,0,fx,0); g.addColorStop(0,GREEN_D); g.addColorStop(1,f.flash>0?`rgb(${lerp(52,110,f.flash)|0},${lerp(211,231,f.flash)|0},${lerp(153,183,f.flash)|0})`:GREEN); X.fillStyle=g; rr(X,BAR.x0,BAR.y-3,fx-BAR.x0,6,3); X.fill() }
// traînée derrière le point
if(t>T.progStart&&t<T.progEnd){ const v=(progressAt(t+.01)-progressAt(t))/.01; const tl=clamp(8+v*40,8,34); const tg=X.createLinearGradient(fx-tl,0,fx,0); tg.addColorStop(0,'rgba(52,211,153,0)'); tg.addColorStop(1,'rgba(110,231,183,.6)'); X.save(); X.filter='blur(3px)'; X.fillStyle=tg; rr(X,fx-tl,BAR.y-4,tl,8,4); X.fill(); X.restore() }
X.restore() }
// vue « choose »
if(f.chooseAlpha>0){ X.save(); X.globalAlpha=f.chooseAlpha; X.translate(0,(1-f.chooseAlpha)*4);
text('capture.png est prêt.',100,80,14,600,'#F5F6F8'); text('Tu veux en faire quoi ?',100,100,12.5,400,'#9398A1');
X.fillStyle='#F5F6F8'; rr(X,100,113,176,26,13); X.fill(); text('Poser une question dessus',188,126,12.5,500,'#0B0C0E','center');
X.fillStyle='rgba(255,255,255,.09)'; rr(X,284,113,128,26,13); X.fill(); text('Envoyer par mail',348,126,12.5,500,'#F1F2F4','center'); X.restore() }
// Mochi puis fichier par-dessus (le fichier est masqué sous le haut de la bouche)
drawMochi(f);
if(f.fileVisible) drawFile(f);
drawCursor(f.cursor,t>=T.drop&&t<T.drop+.12);
if(guides){ X.strokeStyle='#FF0'; X.lineWidth=.5; X.setLineDash([3,3]); X.beginPath(); X.moveTo(FOLLOW.min,36); X.lineTo(FOLLOW.min,166); X.moveTo(FOLLOW.max,36); X.lineTo(FOLLOW.max,166); X.stroke(); X.setLineDash([]); X.beginPath(); X.arc(f.x,f.y,LOCK_IN,0,Math.PI*2); X.stroke() }
// étiquette de phase
const ph=t<(S.entered>=0?S.entered:9)?'0 · Le fichier approche':t<T.drop?(S.locked?'2 · Verrouillé : bouche grande ouverte':'1 · La boîte suit le fichier'):t<T.suckStart?'3 · Anticipation':t<T.suckEnd?'4 · Aspiration en entonnoir':t<T.chewEnd?'5 · Gloups + mâchage':t<T.progStart?'6 · Redevient une boule, rétrécit en point':t<T.progEnd?'7 · Progression (fausse)':t<T.growStart?'8 · Succès vert':'9 · Regrandit, vue « choose »';
return ph;
}
/* ====================== LECTURE ====================== */
const Snd={on:false,ctx:null,
init(){ if(this.ctx)return; const C=window.AudioContext||window.webkitAudioContext; if(!C)return; this.ctx=new C(); this.g=this.ctx.createGain(); this.g.gain.value=.7; this.g.connect(this.ctx.destination) },
tone(f,to,d,g,delay=0,type='sine'){ const c=this.ctx,t=c.currentTime+delay,o=c.createOscillator(),n=c.createGain(); o.type=type; o.frequency.setValueAtTime(f,t); if(to)o.frequency.exponentialRampToValueAtTime(to,t+d*.9); n.gain.setValueAtTime(.0001,t); n.gain.exponentialRampToValueAtTime(g,t+.006); n.gain.exponentialRampToValueAtTime(.0001,t+d); o.connect(n); n.connect(this.g); o.start(t); o.stop(t+d+.05) },
play(e){ if(!this.on)return; this.init(); if(!this.ctx)return; if(this.ctx.state==='suspended')this.ctx.resume();
if(e==='enter')this.tone(2100,0,.05,.014); if(e==='lock')this.tone(480,1150,.11,.05);
if(e==='gulp'){this.tone(340,120,.16,.11);this.tone(210,80,.22,.09,.1)} if(e==='tick')this.tone(2400,0,.03,.012);
if(e==='approve'){this.tone(660,0,.18,.05);this.tone(990,0,.3,.05,.08)} }
};
let t=0, playing=true, slow=1, last=performance.now();
const $=id=>document.getElementById(id);
function loop(now){ const dt=Math.min(.05,(now-last)/1000); last=now;
if(playing){ t+=dt/slow; if(t>T.end){ t=0 } }
const evBefore=S.events.length; const ph=draw(t); for(const e of S.events.slice(evBefore)) if(playing) Snd.play(e); if(S.events.length>200) S.events.length=0;
$('t').textContent='t = '+t.toFixed(3)+' s'; $('phase').textContent=ph; $('scrub').value=t;
requestAnimationFrame(loop) }
$('play').onclick=()=>{ playing=!playing; $('play').textContent=playing?'Pause':'Lecture'; $('play').classList.toggle('on',playing) };
$('restart').onclick=()=>{ t=0; S=newSim(); playing=true; $('play').textContent='Pause'; $('play').classList.add('on') };
$('slow').onclick=()=>{ slow=slow===1?4:1; $('slow').classList.toggle('on',slow===4) };
$('guides').onclick=()=>{ guides=!guides; $('guides').classList.toggle('on',guides) };
$('snd').onclick=()=>{ Snd.on=!Snd.on; if(Snd.on)Snd.init(); $('snd').classList.toggle('on',Snd.on) };
$('scrub').oninput=e=>{ t=+e.target.value; playing=false; $('play').textContent='Lecture'; $('play').classList.remove('on') };
window.__draw=(tt)=>{ t=tt; playing=false; return draw(tt) };
requestAnimationFrame(loop);
})();
</script>
</body>
</html>