feat(results): gold, silver and bronze medals for the top three in PDF, printouts and result tables (1.73.0)
This commit is contained in:
1 parent
7c25f23ad0
commit
41043a990d
12 files changed
+72
-12
No files matched your search
@@ -8,6 +8,12 @@ const THEMES = {
|
||||
minimal: { band: null, accent: "#3c4454", headFill: "#e9ecf1", headText: "#1d2330", zebra: "#f7f8fa" },
|
||||
};
|
||||
const PODIUM = { 1: "#d4af37", 2: "#a9b0bb", 3: "#c27c3e" };
|
||||
// Medal colours: rim, face, highlight, number.
|
||||
const MEDALS = {
|
||||
1: ["#9c7210", "#f0c53f", "#fff2b0", "#4a3500"],
|
||||
2: ["#7d8691", "#cfd5dc", "#ffffff", "#33383f"],
|
||||
3: ["#84491a", "#d38a4c", "#ffd7b0", "#3d2109"],
|
||||
};
|
||||
const TEXT = "#1d2330";
|
||||
const MUTED = "#6b7486";
|
||||
const RULE = "#d8dde6";
|
||||
@@ -150,6 +156,19 @@ function createWriter(pageWidth, pageHeight, title) {
|
||||
if (align === "center") left = x + (width - textWidth(value, size, bold)) / 2;
|
||||
writer.page.push(`BT ${rgb(color)} rg /${bold ? "F2" : "F1"} ${size} Tf ${n(left)} ${n(y)} Td (${escapePdfText(value)}) Tj ET`);
|
||||
},
|
||||
circle(cx, cy, r, color) {
|
||||
const k = r * 0.5523;
|
||||
writer.page.push(`${rgb(color)} rg ${n(cx + r)} ${n(cy)} m ${n(cx + r)} ${n(cy + k)} ${n(cx + k)} ${n(cy + r)} ${n(cx)} ${n(cy + r)} c ${n(cx - k)} ${n(cy + r)} ${n(cx - r)} ${n(cy + k)} ${n(cx - r)} ${n(cy)} c ${n(cx - r)} ${n(cy - k)} ${n(cx - k)} ${n(cy - r)} ${n(cx)} ${n(cy - r)} c ${n(cx + k)} ${n(cy - r)} ${n(cx + r)} ${n(cy - k)} ${n(cx + r)} ${n(cy)} c f`);
|
||||
},
|
||||
// A gold/silver/bronze medal: rim, face, a soft highlight and the place in bold.
|
||||
medal(cx, cy, place) {
|
||||
const [rim, face, light, ink] = MEDALS[place];
|
||||
writer.circle(cx, cy, 7, rim);
|
||||
writer.circle(cx, cy, 5.8, face);
|
||||
writer.circle(cx - 1.6, cy + 1.8, 2.4, light);
|
||||
writer.circle(cx - 0.3, cy + 0.3, 4.1, face);
|
||||
writer.text(cx - 6, cy - 2.6, String(place), 7.5, { bold: true, color: ink, align: "center", width: 12 });
|
||||
},
|
||||
image(x, y, w, h) {
|
||||
writer.page.push(`q ${n(w)} 0 0 ${n(h)} ${n(x)} ${n(y)} cm /Im1 Do Q`);
|
||||
},
|
||||
@@ -233,6 +252,11 @@ function drawTable(writer, section, theme) {
|
||||
let x = MARGIN;
|
||||
section.headers.forEach((_h, index) => {
|
||||
const bold = Boolean(podium) && index <= 1;
|
||||
if (podium && index === 0) {
|
||||
writer.medal(x + widths[0] / 2, top - rowHeight / 2, Number(String(row[0]).trim()));
|
||||
x += widths[0];
|
||||
return;
|
||||
}
|
||||
writer.text(x + PAD, top - 11.5, fitText(row[index], CELL_SIZE, bold, widths[index] - PAD * 2), CELL_SIZE, { bold, align: align(index), width: widths[index] - PAD * 2 });
|
||||
x += widths[index];
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user