Enhance web UI: 2.5D agents, road-waypoint movement, weekend badge
Browse files- Rewrote drawPerson() for realistic 2.5D look: larger head with shine/mood
mouth, two-segment arms with elbow bend, two-segment legs with knee, shoes
via roundRect, 3-face isometric torso (front/side/top), belt, female skirt
- Moving agents now smoothly traverse road waypoints instead of teleporting;
lerp rate 0.022 for moving state, 0.07 for stationary
- Added agentPrevLocations + agentWaypoints; computeAgentTarget() inserts a
mid-road waypoint on location change during 'moving' state
- Weekend badge (gold pulsing pill) shown in top bar on days 6 & 7 of each week
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 unmodified lines2324252627282930121 unmodified lines152153154155156157188 unmodified lines346347348349350351179 unmodified lines5315325335345355365375381099 unmodified lines1638163916401641164216437 unmodified lines16511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799278 unmodified lines207820792080208120822083208422 unmodified linesheight: 50px;}#header h1 { font-size: 18px; color: #e94560; letter-spacing: 2px; }#header .info { display: flex; gap: 20px; font-size: 13px; color: #a0a0c0; }#header .info span { display: flex; align-items: center; gap: 6px; }.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }.dot.green { background: #4ecca3; } .dot.yellow { background: #f0c040; } .dot.red { background: #e94560; }#main { display: flex; height: calc(100vh - 50px); }121 unmodified lines<h1>SOCI CITY</h1><div class="info"><span id="clock">Day 1, 06:00</span><span><span id="weather-icon"></span> <span id="weather">Sunny</span></span><span id="agent-count"><span class="dot green"></span> 0 agents</span><span id="conv-count">0 convos</span>188 unmodified lines// Pan & zoom statelet panX = 0, panY = 0;let zoom = 1.0;let isDragging = false, dragStartX = 0, dragStartY = 0, dragPanStartX = 0, dragPanStartY = 0;// Rectangle-zoom statelet rectZoomMode = false, isRectDragging = false, rectStart = null, rectEnd = null;179 unmodified linesfor (const [id, target] of Object.entries(agentTargets)) {if (!agentPositions[id]) { agentPositions[id] = {...target}; continue; }const p = agentPositions[id];p.x += (target.x - p.x) * 0.06;p.y += (target.y - p.y) * 0.06;}draw();requestAnimationFrame(animate);1099 unmodified linesagentTargets[id] = { x: pos.x * W + ox, y: pos.y * H + oy };}if (!agentPositions[id]) agentPositions[id] = {...agentTargets[id]};}// ============================================================7 unmodified linesconst isSel = id === selectedAgentId;const isHov = id === hoveredAgent;const gender = agent.gender || 'unknown';const scale = (isSel ? 1.0 : (isHov ? 0.9 : 0.72));const isMoving = agent.state === 'moving';const isSleeping = agent.state === 'sleeping';const tgt = agentTargets[id];const moving = tgt && Math.hypot(ax-tgt.x, ay-tgt.y) > 3;ctx.save();ctx.translate(ax, ay);ctx.scale(scale, scale);if (isSel) { ctx.shadowColor=color; ctx.shadowBlur=12; }const walkAnim = isMoving || moving;const walkPhase = animFrame * 0.28;const bounce = walkAnim ? Math.sin(walkPhase) * 2.8 : 0;const armSwing = walkAnim ? Math.sin(walkPhase) * 18 : 0;const legSwing = walkAnim ? Math.sin(walkPhase) * 13 : 0;// Ground shadow (isometric ellipse)ctx.fillStyle = 'rgba(0,0,0,0.18)';ctx.beginPath(); ctx.ellipse(1, 10, 6, 2.5, 0.15, 0, 6.28); ctx.fill();// Determine skin tones for varietyconst skinTones = ['#f0d0b0','#d4a574','#c68642','#8d5524','#e8c4a0','#f5d6b8'];const skinIdx = (globalIdx * 7 + 3) % skinTones.length;const skin = skinTones[skinIdx];// --- BODY (2.5D: front + slight right side visible) ---// Torso β front faceif (gender==='female') {ctx.fillStyle = color;ctx.beginPath();ctx.moveTo(-3, -8+bounce); ctx.lineTo(3, -8+bounce);ctx.lineTo(5, 3+bounce); ctx.lineTo(-5, 3+bounce);ctx.closePath(); ctx.fill();// Torso side (2.5D)ctx.fillStyle = dim(color, 0.7);ctx.beginPath();ctx.moveTo(3, -8+bounce); ctx.lineTo(5, -9+bounce);ctx.lineTo(7, 2+bounce); ctx.lineTo(5, 3+bounce);ctx.closePath(); ctx.fill();} else {// Male/NB β blocky torsoctx.fillStyle = color;ctx.fillRect(-3.5, -8+bounce, 7, 10);// Torso side (2.5D)ctx.fillStyle = dim(color, 0.65);ctx.beginPath();ctx.moveTo(3.5, -8+bounce); ctx.lineTo(5.5, -9.5+bounce);ctx.lineTo(5.5, 0.5+bounce); ctx.lineTo(3.5, 2+bounce);ctx.closePath(); ctx.fill();}// Legs (with perspective offset)const legColor = gender==='female' ? skin : dim(color, 0.5);ctx.strokeStyle = legColor;ctx.lineWidth = walkAnim ? 2.5 : 1.8;const lx1 = walkAnim ? -3 - legSwing * 0.25 : -3;const lx2 = walkAnim ? 3 + legSwing * 0.25 : 3;const ly = walkAnim ? 11 : 8;ctx.beginPath(); ctx.moveTo(-2, 3+bounce); ctx.lineTo(lx1, ly+bounce+legSwing); ctx.stroke();ctx.beginPath(); ctx.moveTo( 2, 3+bounce); ctx.lineTo(lx2, ly+bounce-legSwing); ctx.stroke();// Feetctx.fillStyle = '#2a2a2a';ctx.fillRect(lx1-2, ly-1+bounce+legSwing, 4, 2);ctx.fillRect(lx2-1, ly-1+bounce-legSwing, 4, 2);// Armsctx.strokeStyle = skin;ctx.lineWidth = walkAnim ? 2.0 : 1.5;const armX1 = walkAnim ? -9 : -7;const armX2 = walkAnim ? 9 : 7;const armY = walkAnim ? 2 : 0;ctx.beginPath(); ctx.moveTo(-3.5, -6+bounce); ctx.lineTo(armX1, armY+bounce+armSwing); ctx.stroke();ctx.beginPath(); ctx.moveTo( 3.5, -6+bounce); ctx.lineTo(armX2, armY+bounce-armSwing); ctx.stroke();// Head (slightly offset for 2.5D)ctx.fillStyle = skin;ctx.beginPath(); ctx.arc(0.5, -13+bounce, 5, 0, 6.28); ctx.fill();// Head side shadingctx.fillStyle = dim(skin, 0.85);ctx.beginPath(); ctx.arc(2, -13+bounce, 4.5, -0.3, 1.2); ctx.fill();// Hairconst hairColor = dim(color, 0.5);ctx.fillStyle = hairColor;if (gender==='female') {ctx.beginPath(); ctx.ellipse(0.5, -15.5+bounce, 6, 3.5, 0, Math.PI, 0); ctx.fill();ctx.beginPath(); ctx.ellipse(-3, -11+bounce, 2, 5, 0.3, 0, 6.28); ctx.fill();ctx.beginPath(); ctx.ellipse(4, -11+bounce, 2, 5, -0.3, 0, 6.28); ctx.fill();} else if (gender==='male') {ctx.beginPath(); ctx.ellipse(0.5, -15.5+bounce, 5.5, 3, 0, Math.PI, 0); ctx.fill();} else {ctx.beginPath(); ctx.ellipse(0.5, -15.5+bounce, 6, 3.5, 0, Math.PI, 0); ctx.fill();ctx.beginPath(); ctx.ellipse(-3.5, -12+bounce, 1.5, 4, 0.2, 0, 6.28); ctx.fill();}// Eyes (tiny dots)ctx.fillStyle = '#222';ctx.fillRect(-1.5, -14+bounce, 1, 1);ctx.fillRect(2, -14+bounce, 1, 1);ctx.shadowColor='transparent'; ctx.shadowBlur=0;// State effectsif (agent.state==='in_conversation') {ctx.fillStyle='rgba(240,192,64,0.85)';ctx.beginPath(); ctx.ellipse(10, -17+bounce, 7, 5, 0, 0, 6.28); ctx.fill();ctx.fillStyle='#1a1a2e'; ctx.font='bold 6px Segoe UI'; ctx.textAlign='center'; ctx.textBaseline='middle';ctx.fillText('...', 10, -17+bounce);}if (isSleeping) {const t=animFrame*0.04;ctx.font='bold 7px Segoe UI'; ctx.textAlign='left';for (let i=0;i<3;i++) {ctx.globalAlpha=0.3+i*0.25; ctx.fillStyle='#8ab4f8';ctx.fillText('z', 7+i*3, -18-i*5+Math.sin(t+i)*2);}ctx.globalAlpha=1;}if (agent.partner_id) {drawHeart(0, -22+bounce+Math.sin(animFrame*0.04)*2, 3, 'rgba(233,30,144,0.7)');}ctx.restore();// Name label (smaller)const firstName = (agent.name||id).split(' ')[0];ctx.font=`${isSel?'bold ':''}8px Segoe UI`; ctx.textAlign='center'; ctx.textBaseline='top';ctx.fillStyle='rgba(0,0,0,0.45)'; ctx.fillText(firstName, ax+1, ay+10*scale+1);ctx.fillStyle=isSel?'#fff':'#c0c0d0'; ctx.fillText(firstName, ax, ay+10*scale);// Mood bar (smaller)const mood=agent.mood||0;const mw=14, mx=ax-mw/2, my=ay+10*scale+11;ctx.fillStyle='rgba(15,52,96,0.4)'; ctx.fillRect(mx,my,mw,2);const mf=(mood+1)/2;ctx.fillStyle=mf>0.6?'#4ecca3':(mf>0.3?'#f0c040':'#e94560');ctx.fillRect(mx,my,mw*mf,2);}// ============================================================278 unmodified linescurrentTimeOfDay = clock.time_of_day || 'morning';currentWeather = (data.weather || 'sunny').toLowerCase();document.getElementById('clock').textContent = `Day ${clock.day||1}, ${clock.time_str||'??:??'} (${currentTimeOfDay})`;document.getElementById('weather-icon').textContent = WEATHER_ICONS[currentWeather] || '\u2600\uFE0F';document.getElementById('weather').textContent = currentWeather;document.getElementById('agent-count').innerHTML = `<span class="dot green"></span> ${Object.keys(data.agents||{}).length} agents`;22 unmodified lines232425262728293031323334353637383940414243121 unmodified lines165166167168169170171188 unmodified lines360361362363364365366367368179 unmodified lines5485495505515525535545555565575585595605615625635645655665675681099 unmodified lines1668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616977 unmodified lines17051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946278 unmodified lines22252226222722282229223022312232223322342235223622 unmodified linesheight: 50px;}#header h1 { font-size: 18px; color: #e94560; letter-spacing: 2px; }#header .info { display: flex; gap: 20px; font-size: 13px; color: #a0a0c0; align-items: center; }#header .info span { display: flex; align-items: center; gap: 6px; }#weekend-badge {display: none; align-items: center; gap: 5px;background: linear-gradient(135deg, #f0c040, #e67e22);color: #1a1a2e; font-weight: 800; font-size: 11px;padding: 3px 10px; border-radius: 12px;letter-spacing: 1px; text-transform: uppercase;box-shadow: 0 0 10px rgba(240,192,64,0.5);animation: weekend-pulse 2s ease-in-out infinite;}@keyframes weekend-pulse {0%, 100% { box-shadow: 0 0 8px rgba(240,192,64,0.4); }50% { box-shadow: 0 0 18px rgba(240,192,64,0.8); }}.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }.dot.green { background: #4ecca3; } .dot.yellow { background: #f0c040; } .dot.red { background: #e94560; }#main { display: flex; height: calc(100vh - 50px); }121 unmodified lines<h1>SOCI CITY</h1><div class="info"><span id="clock">Day 1, 06:00</span><span id="weekend-badge">ποΈ Weekend</span><span><span id="weather-icon"></span> <span id="weather">Sunny</span></span><span id="agent-count"><span class="dot green"></span> 0 agents</span><span id="conv-count">0 convos</span>188 unmodified lines// Pan & zoom statelet panX = 0, panY = 0;let zoom = 1.0;// Movement tracking β previous location + road waypoints for smooth walkinglet agentPrevLocations = {}; // {id: locationId} last known locationlet agentWaypoints = {}; // {id: {x,y}} intermediate road point during transitlet isDragging = false, dragStartX = 0, dragStartY = 0, dragPanStartX = 0, dragPanStartY = 0;// Rectangle-zoom statelet rectZoomMode = false, isRectDragging = false, rectStart = null, rectEnd = null;179 unmodified linesfor (const [id, target] of Object.entries(agentTargets)) {if (!agentPositions[id]) { agentPositions[id] = {...target}; continue; }const p = agentPositions[id];const agent = agents[id];// If there's a road waypoint, move toward it firstconst wp = agentWaypoints[id];if (wp) {const d = Math.hypot(p.x - wp.x, p.y - wp.y);if (d < 4) delete agentWaypoints[id]; // arrived at waypoint}const dest = agentWaypoints[id] || target;// Moving agents travel slower so the walk is visible; others snap fasterconst isMoving = agent && (agent.state === 'moving');const lerpRate = isMoving ? 0.022 : 0.07;p.x += (dest.x - p.x) * lerpRate;p.y += (dest.y - p.y) * lerpRate;}draw();requestAnimationFrame(animate);1099 unmodified linesagentTargets[id] = { x: pos.x * W + ox, y: pos.y * H + oy };}if (!agentPositions[id]) agentPositions[id] = {...agentTargets[id]};// ββ Road-waypoint routing for moving agents ββββββββββββββββββ// When location changes while moving, insert a road waypoint so// the agent walks along the street grid instead of cutting straight.const prevLoc = agentPrevLocations[id];if (agent.state === 'moving' && prevLoc && prevLoc !== loc) {const prevPos = allPos[prevLoc];if (prevPos && agentPositions[id]) {const midX = (prevPos.x + pos.x) / 2;const midY = (prevPos.y + pos.y) / 2;// Snap midpoint to nearest horizontal or vertical roadconst hRoads = [0.28, 0.43, 0.58, 0.72];const vRoads = [0.15, 0.30, 0.50, 0.70, 0.85];const nearH = hRoads.reduce((b, r) => Math.abs(midY - r) < Math.abs(midY - b) ? r : b, hRoads[0]);const nearV = vRoads.reduce((b, r) => Math.abs(midX - r) < Math.abs(midX - b) ? r : b, vRoads[0]);const useH = Math.abs(midY - nearH) <= Math.abs(midX - nearV);const jitter = (localIdx % 3 - 1) * 7; // lane spreadagentWaypoints[id] = {x: (useH ? midX : nearV) * W + (useH ? jitter : 0),y: (useH ? nearH : midY) * H + (useH ? 0 : jitter),};}}agentPrevLocations[id] = loc;}// ============================================================7 unmodified linesconst isSel = id === selectedAgentId;const isHov = id === hoveredAgent;const gender = agent.gender || 'unknown';const scale = isSel ? 1.15 : (isHov ? 1.0 : 0.82);const isMoving = agent.state === 'moving';const isSleeping = agent.state === 'sleeping';// Visual movement = interpolated position is far from targetconst tgt = agentTargets[id];const movingVisually = tgt && Math.hypot(ax - tgt.x, ay - tgt.y) > 4;const walkAnim = isMoving || movingVisually;const walkPhase = animFrame * 0.28;const bounce = walkAnim ? Math.sin(walkPhase) * 2.5 : 0;const legSwing = walkAnim ? Math.sin(walkPhase) * 12 : 0;const armSwing = walkAnim ? Math.sin(walkPhase) * 16 : 0;// Skin & hairconst skinTones = ['#f5dbb8','#d4a574','#c68642','#8d5524','#e8c4a0','#f0c090'];const skin = skinTones[(globalIdx * 7 + 3) % skinTones.length];const hairColor = dim(color, 0.45);// Pants = darker variant of shirt, shoes = very darkconst pantsColor = dim(color, 0.55);const shoeColor = currentTimeOfDay === 'night' ? '#1a1a1a' : '#2a2010';ctx.save();ctx.translate(ax, ay);ctx.scale(scale, scale);if (isSel) { ctx.shadowColor = color; ctx.shadowBlur = 14; }// ββ Ground shadow (elongated, ISO-angled) βββββββββββββββββctx.fillStyle = 'rgba(0,0,0,0.22)';ctx.beginPath(); ctx.ellipse(3, 13, 8, 3, 0.2, 0, 6.28); ctx.fill();// ββ SHOES ββββββββββββββββββββββββββββββββββββββββββββββββconst lKneeX = walkAnim ? -1.5 - legSwing * 0.18 : -1.5;const rKneeX = walkAnim ? 1.5 + legSwing * 0.18 : 1.5;const lFootX = walkAnim ? -2.5 - legSwing * 0.35 : -2.5;const rFootX = walkAnim ? 2.5 + legSwing * 0.35 : 2.5;const lFootY = 12 + bounce + legSwing;const rFootY = 12 + bounce - legSwing;// Shoe bodyctx.fillStyle = shoeColor;ctx.beginPath(); ctx.roundRect(lFootX - 3, lFootY - 1, 5, 2.5, 1); ctx.fill();ctx.beginPath(); ctx.roundRect(rFootX - 1.5, rFootY - 1, 5, 2.5, 1); ctx.fill();// ββ LEGS (two-segment: thigh + shin with knee) βββββββββββctx.lineWidth = walkAnim ? 2.8 : 2.2;ctx.lineCap = 'round';// Left legctx.strokeStyle = gender === 'female' ? dim(pantsColor, 0.85) : pantsColor;ctx.beginPath(); ctx.moveTo(-1.5, 4 + bounce);ctx.lineTo(lKneeX, 8 + bounce + legSwing * 0.5);ctx.lineTo(lFootX, lFootY); ctx.stroke();// Right legctx.beginPath(); ctx.moveTo(1.5, 4 + bounce);ctx.lineTo(rKneeX, 8 + bounce - legSwing * 0.5);ctx.lineTo(rFootX, rFootY); ctx.stroke();// Right leg 2.5D depth (slightly lighter)ctx.strokeStyle = dim(gender === 'female' ? dim(pantsColor, 0.85) : pantsColor, 1.2);ctx.lineWidth = 1.2;ctx.beginPath(); ctx.moveTo(1.5 + 1.5, 4 + bounce);ctx.lineTo(rKneeX + 1.5, 8 + bounce - legSwing * 0.5);ctx.lineTo(rFootX + 1.5, rFootY); ctx.stroke();// ββ TORSO (2.5D shirt with shoulder width + side face) βββconst tY = -10 + bounce;const tw = gender === 'female' ? 7 : 8; // half-width at shouldersconst bw = gender === 'female' ? 5 : 7; // half-width at waist// Front facectx.fillStyle = color;ctx.beginPath();ctx.moveTo(-tw, tY); ctx.lineTo(tw, tY);ctx.lineTo(bw, tY + 13); ctx.lineTo(-bw, tY + 13);ctx.closePath(); ctx.fill();// Right side face (2.5D depth)ctx.fillStyle = dim(color, 0.6);ctx.beginPath();ctx.moveTo(tw, tY);ctx.lineTo(tw + 4, tY - 2);ctx.lineTo(bw + 4, tY + 11);ctx.lineTo(bw, tY + 13);ctx.closePath(); ctx.fill();// Top face (shoulder plane)ctx.fillStyle = dim(color, 1.15 > 1 ? 1 : 1.15);ctx.beginPath();ctx.moveTo(-tw, tY);ctx.lineTo(-tw + 4, tY - 2);ctx.lineTo(tw + 4, tY - 2);ctx.lineTo(tw, tY);ctx.closePath(); ctx.fill();// Collar / necklinectx.fillStyle = dim(color, 0.75);ctx.beginPath(); ctx.ellipse(0.5, tY + 1, 2.5, 1.5, 0, 0, 6.28); ctx.fill();// Belt linectx.strokeStyle = dim(color, 0.4);ctx.lineWidth = 1;ctx.beginPath(); ctx.moveTo(-bw, tY + 12); ctx.lineTo(bw, tY + 12); ctx.stroke();// Female: skirt flareif (gender === 'female') {ctx.fillStyle = dim(color, 0.8);ctx.beginPath();ctx.moveTo(-bw, tY + 12); ctx.lineTo(-bw - 2, tY + 16 + bounce);ctx.lineTo(bw + 2, tY + 16 + bounce); ctx.lineTo(bw, tY + 12);ctx.closePath(); ctx.fill();}// ββ ARMS (two-segment with elbow when walking) ββββββββββββconst shoulderY = tY + 2;// Elbow positionsconst lElbowX = walkAnim ? -tw - 3 + armSwing * 0.3 : -tw - 3;const lElbowY = walkAnim ? shoulderY + 5 + armSwing * 0.4 : shoulderY + 5;const rElbowX = walkAnim ? tw + 3 - armSwing * 0.3 : tw + 3;const rElbowY = walkAnim ? shoulderY + 5 - armSwing * 0.4 : shoulderY + 5;// Hand positionsconst lHandX = walkAnim ? lElbowX - 2 + armSwing * 0.6 : lElbowX - 1;const lHandY = walkAnim ? lElbowY + 4 + armSwing * 0.8 : lElbowY + 4;const rHandX = walkAnim ? rElbowX + 2 - armSwing * 0.6 : rElbowX + 1;const rHandY = walkAnim ? rElbowY + 4 - armSwing * 0.8 : rElbowY + 4;ctx.strokeStyle = skin; ctx.lineWidth = walkAnim ? 2.0 : 1.6; ctx.lineCap = 'round';// Left arm (upper arm + forearm)ctx.beginPath(); ctx.moveTo(-tw + 1, shoulderY);ctx.lineTo(lElbowX, lElbowY); ctx.lineTo(lHandX, lHandY); ctx.stroke();// Right armctx.beginPath(); ctx.moveTo(tw - 1, shoulderY);ctx.lineTo(rElbowX, rElbowY); ctx.lineTo(rHandX, rHandY); ctx.stroke();// Handsctx.fillStyle = skin;ctx.beginPath(); ctx.arc(lHandX, lHandY, 1.5, 0, 6.28); ctx.fill();ctx.beginPath(); ctx.arc(rHandX, rHandY, 1.5, 0, 6.28); ctx.fill();// ββ NECK βββββββββββββββββββββββββββββββββββββββββββββββββctx.fillStyle = skin;ctx.fillRect(-1.5, tY - 3.5, 3, 4);// ββ HEAD (2.5D β sphere-like with side shading) βββββββββββconst hx = 1, hy = tY - 10; // head center (slightly right for 2.5D)const hr = 6.5;// Back-of-head / shading arcctx.fillStyle = dim(skin, 0.78);ctx.beginPath(); ctx.arc(hx + 1.5, hy, hr - 0.5, 0, 6.28); ctx.fill();// Main facectx.fillStyle = skin;ctx.beginPath(); ctx.arc(hx, hy, hr, 0, 6.28); ctx.fill();// Right cheek highlight (2.5D lit from upper-left)ctx.fillStyle = `rgba(255,255,255,0.12)`;ctx.beginPath(); ctx.arc(hx - 2, hy - 2, hr * 0.55, 0, 6.28); ctx.fill();// Ear (right side, 2.5D)ctx.fillStyle = dim(skin, 0.88);ctx.beginPath(); ctx.ellipse(hx + hr - 0.5, hy + 1, 1.5, 2, 0, 0, 6.28); ctx.fill();// ββ HAIR βββββββββββββββββββββββββββββββββββββββββββββββββctx.fillStyle = hairColor;if (gender === 'female') {// Long hair β top cap + side curtainsctx.beginPath(); ctx.arc(hx, hy - 1, hr + 0.5, Math.PI * 1.1, Math.PI * 0.05); ctx.fill();ctx.beginPath(); ctx.ellipse(hx - hr + 1, hy + 3, 2.2, hr * 0.85, -0.2, 0, 6.28); ctx.fill();ctx.beginPath(); ctx.ellipse(hx + hr - 0.5, hy + 3, 1.8, hr * 0.7, 0.2, 0, 6.28); ctx.fill();} else if (gender === 'male') {// Short cropctx.beginPath(); ctx.arc(hx, hy - 1, hr + 0.5, Math.PI * 1.15, Math.PI * -0.1); ctx.fill();ctx.fillRect(hx - hr - 0.5, hy - 1, 3, hr * 0.6); // left side} else {// Medium / non-binaryctx.beginPath(); ctx.arc(hx, hy - 1, hr + 0.5, Math.PI * 1.08, Math.PI * 0.0); ctx.fill();ctx.beginPath(); ctx.ellipse(hx - hr + 0.5, hy + 2, 2, hr * 0.65, -0.15, 0, 6.28); ctx.fill();}// ββ FACE βββββββββββββββββββββββββββββββββββββββββββββββββ// Eyesctx.fillStyle = '#1a1010';ctx.beginPath(); ctx.arc(hx - 2.2, hy - 1, 1.1, 0, 6.28); ctx.fill();ctx.beginPath(); ctx.arc(hx + 1.5, hy - 1, 1.1, 0, 6.28); ctx.fill();// Eye shinectx.fillStyle = 'rgba(255,255,255,0.6)';ctx.beginPath(); ctx.arc(hx - 1.8, hy - 1.5, 0.45, 0, 6.28); ctx.fill();ctx.beginPath(); ctx.arc(hx + 1.9, hy - 1.5, 0.45, 0, 6.28); ctx.fill();// Mouth (tiny arc)const moodVal = agent.mood || 0;ctx.strokeStyle = dim(skin, 0.55); ctx.lineWidth = 0.8;ctx.beginPath(); ctx.arc(hx - 0.3, hy + 2.5, 1.8, 0.1, Math.PI - 0.1, moodVal < -0.2); ctx.stroke();ctx.shadowColor = 'transparent'; ctx.shadowBlur = 0;// ββ STATE EFFECTS βββββββββββββββββββββββββββββββββββββββββif (agent.state === 'in_conversation') {ctx.fillStyle = 'rgba(240,192,64,0.9)';ctx.beginPath(); ctx.roundRect(hr + 3, hy - hr - 6, 16, 11, 3); ctx.fill();// speech tailctx.beginPath(); ctx.moveTo(hr + 3, hy - hr - 2); ctx.lineTo(hr - 1, hy); ctx.lineTo(hr + 7, hy - hr - 2); ctx.fill();ctx.fillStyle = '#1a1a2e'; ctx.font = 'bold 6px Segoe UI';ctx.textAlign = 'center'; ctx.textBaseline = 'middle';ctx.fillText('...', hr + 11, hy - hr);}if (isSleeping) {const t = animFrame * 0.04;ctx.font = 'bold 8px Segoe UI'; ctx.textAlign = 'left';for (let i = 0; i < 3; i++) {ctx.globalAlpha = 0.3 + i * 0.25; ctx.fillStyle = '#8ab4f8';ctx.fillText('z', hr + 2 + i * 4, hy - hr - i * 6 + Math.sin(t + i) * 2);}ctx.globalAlpha = 1;}if (agent.partner_id) {drawHeart(1, hy - hr - 10 + Math.sin(animFrame * 0.04) * 2, 3.5, 'rgba(233,30,144,0.8)');}// Selected ringif (isSel) {ctx.strokeStyle = color; ctx.lineWidth = 1.5;ctx.setLineDash([3, 3]);ctx.beginPath(); ctx.arc(hx, hy, hr + 3, 0, 6.28); ctx.stroke();ctx.setLineDash([]);}ctx.restore();// ββ Name label βββββββββββββββββββββββββββββββββββββββββββconst firstName = (agent.name || id).split(' ')[0];ctx.font = `${isSel ? 'bold ' : ''}8px Segoe UI`;ctx.textAlign = 'center'; ctx.textBaseline = 'top';ctx.fillStyle = 'rgba(0,0,0,0.5)'; ctx.fillText(firstName, ax + 1, ay + 14 * scale + 1);ctx.fillStyle = isSel ? '#fff' : '#c8c8d8'; ctx.fillText(firstName, ax, ay + 14 * scale);// ββ Mood bar ββββββββββββββββββββββββββββββββββββοΏ½οΏ½οΏ½ββββββββconst moodV = agent.mood || 0;const mw = 16, mxb = ax - mw / 2, myb = ay + 14 * scale + 11;ctx.fillStyle = 'rgba(15,52,96,0.45)'; ctx.fillRect(mxb, myb, mw, 2.5);const mf = (moodV + 1) / 2;ctx.fillStyle = mf > 0.6 ? '#4ecca3' : (mf > 0.3 ? '#f0c040' : '#e94560');ctx.fillRect(mxb, myb, mw * mf, 2.5);}// ============================================================278 unmodified linescurrentTimeOfDay = clock.time_of_day || 'morning';currentWeather = (data.weather || 'sunny').toLowerCase();const dayNum = clock.day || 1;const dayOfWeek = ((dayNum - 1) % 7) + 1; // 1=Mon β¦ 7=Sunconst isWeekend = dayOfWeek >= 6;document.getElementById('clock').textContent = `Day ${dayNum}, ${clock.time_str||'??:??'} (${currentTimeOfDay})`;const badge = document.getElementById('weekend-badge');badge.style.display = isWeekend ? 'flex' : 'none';document.getElementById('weather-icon').textContent = WEATHER_ICONS[currentWeather] || '\u2600\uFE0F';document.getElementById('weather').textContent = currentWeather;document.getElementById('agent-count').innerHTML = `<span class="dot green"></span> ${Object.keys(data.agents||{}).length} agents`;
web/index.html+269-117