- commit
- e50e8a56bc5afa553dc8ffb52f04674443dd6648
- parent
- 16534aacc6952ac1a1a6ad01b179b0a9f07e91d2
- author
- dami <gazey55@gmail.com>
| M | site/ | 91 | +++++++++++------------------- |
@@ -451,23 +451,6 @@ function renderMapTile(
451451 }452452 }453453 }454- // a dead agent: a small cross on its last solved tile455- for (const an of s.analysis.agents) {456- if (an.health.state !== "dead" || an.last_solved === null) continue;457- const t = s.manifest!.tiles[an.last_solved];458- if (!t || !tiles.has(t.id)) continue;459- const cx = (t.x0 + t.w / 2 - cx0) * ppc, cy = (t.y0 + t.h / 2 - cy0) * ppc;460- const r = Math.max(3, Math.min(t.w, t.h) * ppc * 0.18);461- ctx.strokeStyle = theme.danger;462- ctx.globalAlpha = 0.9;463- ctx.lineWidth = Math.max(1, r * 0.22);464- ctx.beginPath();465- ctx.moveTo(cx - r, cy - r);466- ctx.lineTo(cx + r, cy + r);467- ctx.moveTo(cx + r, cy - r);468- ctx.lineTo(cx - r, cy + r);469- ctx.stroke();470- }471454 ctx.globalAlpha = 1;472455 if (level === 1) return { canvas, ppc };473456 @@ -681,7 +664,37 @@ function focusTile(
681664 return tid ?? null;682665 }683666 684-/** L3 overlay: the coordinates on the frame of the focus tile, its pins. */667+/** Per-frame: a dead agent's cross on its last solved tile, above the stones. */668+function drawDeaths(669+ ctx: CanvasRenderingContext2D,670+ f: Frame,671+ view: View,672+ theme: Theme,673+) {674+ const s = f.s;675+ const { scale, ox, oy } = view;676+ for (const an of s.analysis.agents) {677+ if (an.health.state !== "dead" || an.last_solved === null) continue;678+ const t = s.manifest!.tiles[an.last_solved];679+ if (!t) continue;680+ const cx = ox + (t.x0 + t.w / 2) * scale,681+ cy = oy + (t.y0 + t.h / 2) * scale;682+ const r = Math.max(4, Math.min(t.w, t.h) * scale * 0.18);683+ ctx.save();684+ ctx.strokeStyle = theme.danger;685+ ctx.globalAlpha = 0.95;686+ ctx.lineWidth = Math.max(1.5, r * 0.22);687+ ctx.beginPath();688+ ctx.moveTo(cx - r, cy - r);689+ ctx.lineTo(cx + r, cy + r);690+ ctx.moveTo(cx + r, cy - r);691+ ctx.lineTo(cx - r, cy + r);692+ ctx.stroke();693+ ctx.restore();694+ }695+}696+697+/** L3 overlay: the frame of the focus tile and its pins. */685698 function drawFocus(686699 ctx: CanvasRenderingContext2D,687700 f: Frame,@@ -701,45 +714,8 @@ function drawFocus(
701714 ctx.globalAlpha = 0.9;702715 ctx.lineWidth = 1;703716 traceOutline(ctx, t, mask, scale, ox, oy);704- const fs = Math.max(9, Math.min(13, scale * 0.35));705- ctx.font = `${fs}px "Noto Serif JP", serif`;706- ctx.fillStyle = theme.ink;707- ctx.textAlign = "center";708- ctx.textBaseline = "bottom";709- for (let lx = 0; lx < t.w; lx++) {710- // the top-most cell of this column711- let top = -1;712- for (let ly = 0; ly < t.h; ly++) {713- if (mask[ly * t.w + lx]) {714- top = ly;715- break;716- }717- }718- if (top < 0) continue;719- const L = String.fromCharCode(65 + (lx >= 8 ? lx + 1 : lx)); // no I, as on a board720- ctx.fillText(721- L,722- ox + (t.x0 + lx + 0.5) * scale,723- oy + (t.y0 + top) * scale - 3,724- );725- }726- ctx.textAlign = "right";727- ctx.textBaseline = "middle";728- for (let ly = 0; ly < t.h; ly++) {729- let left = -1;730- for (let lx = 0; lx < t.w; lx++) {731- if (mask[ly * t.w + lx]) {732- left = lx;733- break;734- }735- }736- if (left < 0) continue;737- ctx.fillText(738- String(t.h - ly),739- ox + (t.x0 + left) * scale - 4,740- oy + (t.y0 + ly + 0.5) * scale,741- );742- }717+ // no coordinates: they collide with the stones at this scale; the718+ // frame and the pins are enough to say which tile this is743719 // pins: the overlaps an alternative solution differs on, marked on744720 // their shared cells with a small triangle745721 ctx.fillStyle = theme.ink;@@ -836,6 +812,7 @@ function compose(
836812 if (level >= 2) drawLastMove(ctx, f, view, theme, snap);837813 if (level === 3) {838814 focus = focusTile(f, view, W, H);815+ drawDeaths(ctx, f, view, theme);839816 if (focus !== null) drawFocus(ctx, f, scene, view, focus, theme);840817 }841818 const dt = performance.now() - t0;