Polish: full-width text, links and bold, methods tabs, readable map choices
- Prose no longer stops at ~70 characters; it uses its column's full width. - Sources linked (responses sheet, route PDF, register, megathreads, Reddit users, Dragonkind, the repo) and statistical methods linked to their references; key terms and numbers in bold. - Data & Methods: the seven method sections are now tabs (arrow keys work). - Valley map: when a choice point is opened, each option's chance sits under its own labelled place and overlapping labels are pushed apart; small choice points can label above themselves. Checked: no overlapping text for any dragon and any opened choice. - Register cards: the age sits inside the arch; all-caps names shown normally. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7366af2f7d
commit
99f60282ed
+32
-5
@@ -190,8 +190,11 @@
|
||||
};
|
||||
// label text is always dark ink (light dragon colours like Orange are unreadable as text on paper);
|
||||
// the dragon's colour goes on the border instead
|
||||
function pill(g, x, y, text, { ink = PAPER.ink, edge = null, strong = false, bg = PAPER.halo } = {}) {
|
||||
let pills = []; // every label drawn this render, so overlapping ones can be pushed apart afterwards
|
||||
function pill(g0, x, y, text, { ink = PAPER.ink, edge = null, strong = false, bg = PAPER.halo } = {}) {
|
||||
const w = 10 + text.length * (strong ? 7.2 : 6.4), h = strong ? 20 : 17;
|
||||
const g = el("g", {}, g0);
|
||||
pills.push({ g, x, y, w, h, dy: 0 });
|
||||
el("rect", { x: x - w / 2, y: y - h / 2, width: w, height: h, rx: h / 2, fill: bg, "fill-opacity": 0.95, stroke: edge || ink, "stroke-opacity": edge ? 0.95 : 0.4, "stroke-width": edge ? 2 : 1 }, g);
|
||||
el("text", { x, y: y + (strong ? 4.5 : 4), "text-anchor": "middle", "font-size": strong ? 12.5 : 11, "font-weight": strong ? 700 : 500, fill: ink, "font-family": "var(--font-data)" }, g).textContent = text;
|
||||
}
|
||||
@@ -272,8 +275,9 @@
|
||||
if (!P || P.kind === "dragon") return;
|
||||
const strong = onRoute.has(id);
|
||||
el("circle", { cx: P.x, cy: P.y, r: strong ? 6 : 4.5, fill: PAPER.ink, "fill-opacity": strong ? 0.95 : 0.7, stroke: PAPER.halo, "stroke-width": 2 }, g);
|
||||
const right = (P.lab || "right") !== "left";
|
||||
const t = el("text", { x: P.x + (right ? 10 : -10), y: P.y + 4, "text-anchor": right ? "start" : "end", "font-family": "var(--font-display)", "font-size": strong ? 14 : 13,
|
||||
// small choice points sit close together, so they honour "above" as well as left/right
|
||||
const pos = P.kind === "small" && P.lab === "above" ? "above" : (P.lab || "right") === "left" ? "left" : "right";
|
||||
const t = el("text", { x: P.x + (pos === "right" ? 10 : pos === "left" ? -10 : 0), y: P.y + (pos === "above" ? -10 : 4), "text-anchor": pos === "right" ? "start" : pos === "left" ? "end" : "middle", "font-family": "var(--font-display)", "font-size": strong ? 14 : 13,
|
||||
fill: PAPER.ink, "fill-opacity": strong ? 1 : 0.8, "paint-order": "stroke", stroke: PAPER.halo, "stroke-width": 3.5, "stroke-linejoin": "round" }, g);
|
||||
t.textContent = LANDMARK_NAME[id] || P.name;
|
||||
});
|
||||
@@ -345,8 +349,9 @@
|
||||
if (!pid || !L[pid] || v === m.s.taken) return;
|
||||
const B = L[pid], rel2 = val.pX / best2;
|
||||
const p = el("path", { d: curve(P, B, 0.1), fill: "none", stroke: tc, "stroke-width": 2 + 4 * rel2, "stroke-opacity": 0.35 + 0.5 * rel2, "stroke-dasharray": "6 6", "stroke-linecap": "round", class: "ex-alt", tabindex: 0, role: "button", "aria-label": `${v}: ${pct(val.pX)}. Take this instead.` }, gLab);
|
||||
const m2 = mid(P, B, 0.72, 0.1);
|
||||
pill(gLab, m2.x, m2.y, `${v.length > 18 ? v.slice(0, 17) + "…" : v} ${pct(val.pX)}`);
|
||||
// the option's own place is labelled on the map, so its chance sits just under that place
|
||||
onRoute.add(pid);
|
||||
pill(gLab, B.x, B.y + 17, pct(val.pX));
|
||||
const pick = () => choose(m.s.var, v);
|
||||
p.addEventListener("click", pick);
|
||||
p.addEventListener("keydown", (e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); pick(); } });
|
||||
@@ -357,6 +362,26 @@
|
||||
return onRoute;
|
||||
}
|
||||
|
||||
/** Push overlapping labels apart vertically (a few relaxation passes), so no two chances sit on top of each other. */
|
||||
function spreadPills() {
|
||||
const gap = 3;
|
||||
for (let pass = 0; pass < 30; pass++) {
|
||||
let moved = false;
|
||||
for (let i = 0; i < pills.length; i++) for (let j = i + 1; j < pills.length; j++) {
|
||||
const a = pills[i], b = pills[j];
|
||||
const ox = Math.min(a.x + a.w / 2, b.x + b.w / 2) - Math.max(a.x - a.w / 2, b.x - b.w / 2);
|
||||
const ay = a.y + a.dy, by = b.y + b.dy;
|
||||
const oy = Math.min(ay + a.h / 2, by + b.h / 2) - Math.max(ay - a.h / 2, by - b.h / 2);
|
||||
if (ox > 0 && oy > -gap) {
|
||||
const push = (oy + gap) / 2, down = by >= ay ? 1 : -1;
|
||||
a.dy -= push * down; b.dy += push * down; moved = true;
|
||||
}
|
||||
}
|
||||
if (!moved) break;
|
||||
}
|
||||
pills.forEach((p) => { if (p.dy) p.g.setAttribute("transform", `translate(0 ${p.dy.toFixed(1)})`); });
|
||||
}
|
||||
|
||||
/* ---------- tooltip ---------- */
|
||||
function showTip(e, html) { const t = $("#ex-tip"); t.innerHTML = html; t.hidden = false; moveTip(e); }
|
||||
function moveTip(e) {
|
||||
@@ -500,7 +525,9 @@
|
||||
return r;
|
||||
}).sort((a, b) => b.value.x - a.value.x);
|
||||
if (!st.focus || !routes.some((r) => r.enc === st.focus)) st.focus = routes[0].enc;
|
||||
pills = [];
|
||||
onRoute = drawRoutes(gRoute, gLab, routes);
|
||||
spreadPills();
|
||||
}
|
||||
drawLandmarks(gLand, onRoute);
|
||||
drawScenery(gScene, onRoute);
|
||||
|
||||
Reference in New Issue
Block a user