Changeset 5412cbb in Klonkt for src/assets/js/ward-sky.js
- Timestamp:
- 08/12/2026 08:38:08 PM (3 months ago)
- Children:
- 2086ea2
- Parents:
- 4bb93aa
- File:
-
- 1 edited
-
src/assets/js/ward-sky.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/js/ward-sky.js
r4bb93aa r5412cbb 152 152 * @param {(index:number)=>void} onPick een gezicht aangetikt 153 153 */ 154 constructor(canvas, onPick ) {154 constructor(canvas, onPick, onNew) { 155 155 this.canvas = canvas; 156 156 this.g = canvas.getContext('2d'); 157 157 this.onPick = onPick; 158 // De (+) in het midden: de deur naar iemand NIEUW. Hij zit op de 159 // OORSPRONG van het veld en pant en zoomt met de gezichten mee, zodat hij 160 // altijd het midden van de vliegende avatars is, waar de hemel ook heen 161 // drijft. De plaatsing houdt daar bewust ruimte vrij (elk gezicht hangt 162 // minstens 1.4 cel naar buiten). 163 this.onNew = onNew; 158 164 this.faces = []; 159 165 this.spots = []; … … 211 217 const s = Math.min(Math.max(this.scale, 0.5), 1.6); 212 218 const draw = FACE * s; 219 220 // De (+) eerst, dan de gezichten eroverheen als het krap wordt. 221 if (this.interactive && this.onNew) { 222 const px = cx + this.panX; 223 const py = cy + this.panY; 224 const pr = 22 * s; 225 g.beginPath(); g.arc(px, py, pr, 0, Math.PI * 2); 226 g.fillStyle = 'rgba(255,255,255,0.92)'; g.fill(); 227 g.strokeStyle = '#11131a'; g.lineWidth = Math.max(2, 3 * s); g.lineCap = 'round'; 228 g.beginPath(); 229 g.moveTo(px - pr * 0.45, py); g.lineTo(px + pr * 0.45, py); 230 g.moveTo(px, py - pr * 0.45); g.lineTo(px, py + pr * 0.45); 231 g.stroke(); 232 } 213 233 214 234 for (let i = 0; i < this.spots.length; i++) { … … 248 268 if (moved < 6) { 249 269 const r = c.getBoundingClientRect(); 250 const hit = nearestFace(e.clientX - r.left, e.clientY - r.top, this.spots, { 270 const x = e.clientX - r.left; 271 const y = e.clientY - r.top; 272 const hit = nearestFace(x, y, this.spots, { 251 273 cx: this.w / 2, cy: this.h / 2, cell: CELL, scale: this.scale, 252 274 panX: this.panX, panY: this.panY, 253 275 }); 254 if (hit != null) this.onPick?.(hit); 276 if (hit != null) { this.onPick?.(hit); return; } 277 // Geen gezicht? Dan misschien de (+): zelfde middelpunt als getekend, 278 // met een raakzone die meeschaalt zodat mikken bij elke zoom klopt. 279 const s2 = Math.min(Math.max(this.scale, 0.5), 1.6); 280 const d = Math.hypot(x - (this.w / 2 + this.panX), y - (this.h / 2 + this.panY)); 281 if (d <= 26 * s2) this.onNew?.(); 255 282 } 256 283 };
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)