diff --git a/AGENTS.md b/AGENTS.md
index 10604adf7ef8c5855ad7be44ef5bcd64b0b2bde6..9ce2aaabe219b2f2f2421ad22b6942daf997a078 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -23,6 +23,9 @@ run no compute, so they are free; do not switch it to Gradio or Docker (those ne
`` to the generated files and resizes the iframes when a page posts `{saFrameHeight}`.
Keeps the tab and the selections in the URL hash (tab keys `leaderboard`, `tradeoffs`,
`stability`, `validity`; old names such as `summary`, `performance`, `data` and `about` still work).
+- `assets/downloads.js`: SVG / PNG / PDF downloads of the figures drawn in `index.html` (the
+ `.fig-dl` buttons of the 22-hour and Lasso/ElasticNet ablation figures, and of Figure D.3), in the
+ light paper look; the PDF holds the figure rendered at 4x (built by hand, no library).
- `assets/style.css`: color tokens on `:root` (light) and for dark mode, which follows the system
setting unless the theme button (after "Paper", "Cite" and "Add your method") set `data-theme` on ``. The choice is kept in
`localStorage` (`selectarena-theme`) and passed on to the embedded pages, whose CSS
@@ -58,8 +61,8 @@ run no compute, so they are free; do not switch it to Gradio or Docker (those ne
The generated pages are self-contained (inline CSS/JS, no network) and post their height to the
parent window. All figures (Elo, Pareto front, lasagna plots) are such pages with an inline SVG:
-tooltips on hover or tap, colours that follow the page's theme, and SVG / PNG / CSV buttons whose
-downloads always use the light paper look.
+tooltips on hover or tap, colours that follow the page's theme, and SVG / PNG / PDF / CSV buttons
+whose downloads always use the light paper look.
`subsetDir()` in `app.js` mirrors `selectarena.website.subsets.Subset.rel_path`; change both
together.
diff --git a/assets/downloads.js b/assets/downloads.js
new file mode 100644
index 0000000000000000000000000000000000000000..59c8be6488782fd4c847e3ff62de3a7e94ed7381
--- /dev/null
+++ b/assets/downloads.js
@@ -0,0 +1,100 @@
+// Downloads of the figures drawn in index.html (the figure pages in data/ carry their own) and of
+// Figure D.3: SVG, PNG (4x) and PDF, always in the light colours (the paper look).
+
+// Styles of the inline figures in the light colours; their classes are styled in style.css.
+var SA_INLINE_SVG_CSS =
+ 'text{fill:#1f2328}.nz-muted{fill:#59636e}.nz-title{font-weight:600;font-size:12px}' +
+ '.nz-grid{stroke:#d1d9e0;stroke-width:0.6}.nz-axis{stroke:#1f2328;stroke-width:1}' +
+ '.nz-ref{stroke:#1f2328;stroke-width:1;stroke-dasharray:4 3;opacity:0.6}.nz-bar{fill:#0072b2}' +
+ '.nz-free{fill:#f2cfb2}.nz-err{stroke:#1f2328;stroke-width:1.2}.nz-on-bar{fill:#ffffff;font-size:10px}' +
+ '.nz-on-free{fill:#1f2328;font-size:10px}.nz-pct{font-size:9px}.nz-text-x{fill:#1f2328;font-size:11px}';
+
+function saSaveFile(blob, filename) {
+ var a = document.createElement('a');
+ a.href = URL.createObjectURL(blob);
+ a.download = filename;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ setTimeout(function () { URL.revokeObjectURL(a.href); }, 1000);
+}
+
+// PDF: one page of the figure's size (1 px = 0.75 pt) holding the figure rendered at 4x as a JPEG.
+function saPdfBlob(canvas, widthPt, heightPt) {
+ var jpeg = atob(canvas.toDataURL('image/jpeg', 0.95).split(',')[1]);
+ var w = widthPt.toFixed(2), h = heightPt.toFixed(2);
+ var content = 'q ' + w + ' 0 0 ' + h + ' 0 0 cm /Im0 Do Q';
+ var objects = [
+ '<< /Type /Catalog /Pages 2 0 R >>',
+ '<< /Type /Pages /Kids [3 0 R] /Count 1 >>',
+ '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ' + w + ' ' + h + '] /Resources << /XObject << /Im0 5 0 R >> >> /Contents 4 0 R >>',
+ '<< /Length ' + content.length + ' >>\nstream\n' + content + '\nendstream',
+ '<< /Type /XObject /Subtype /Image /Width ' + canvas.width + ' /Height ' + canvas.height +
+ ' /ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode /Length ' + jpeg.length + ' >>\nstream\n' + jpeg + '\nendstream'
+ ];
+ var pdf = '%PDF-1.4\n', offsets = [];
+ objects.forEach(function (body, i) { offsets.push(pdf.length); pdf += (i + 1) + ' 0 obj\n' + body + '\nendobj\n'; });
+ var xref = pdf.length;
+ pdf += 'xref\n0 ' + (objects.length + 1) + '\n0000000000 65535 f \n';
+ offsets.forEach(function (o) { pdf += ('0000000000' + o).slice(-10) + ' 00000 n \n'; });
+ pdf += 'trailer\n<< /Size ' + (objects.length + 1) + ' /Root 1 0 R >>\nstartxref\n' + xref + '\n%%EOF';
+ var bytes = new Uint8Array(pdf.length);
+ for (var i = 0; i < pdf.length; i++) bytes[i] = pdf.charCodeAt(i) & 0xff;
+ return new Blob([bytes], { type: 'application/pdf' });
+}
+
+// Draws an SVG (as text) on a white canvas, ``scale`` times its size.
+function saRasterize(svgString, width, height, scale, done) {
+ var img = new Image();
+ img.onload = function () {
+ var canvas = document.createElement('canvas');
+ canvas.width = Math.round(width * scale);
+ canvas.height = Math.round(height * scale);
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#ffffff';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
+ done(canvas);
+ };
+ img.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svgString);
+}
+
+function saInlineSvgString(button) {
+ var svg = button.closest('figure').querySelector('svg.nz-svg').cloneNode(true);
+ var font = getComputedStyle(document.body).fontFamily.replace(/"/g, "'");
+ var style = document.createElementNS('http://www.w3.org/2000/svg', 'style');
+ style.textContent = 'svg{font-family:' + font + ';font-size:11px}' + SA_INLINE_SVG_CSS;
+ svg.insertBefore(style, svg.firstChild);
+ svg.querySelectorAll('title').forEach(function (t) { t.remove(); });
+ svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
+ return new XMLSerializer().serializeToString(svg);
+}
+
+// SVG / PNG / PDF of a figure drawn in the page (an svg.nz-svg in the button's figure).
+function saInlineDownload(button, kind, name) {
+ var svg = saInlineSvgString(button);
+ if (kind === 'svg') return saSaveFile(new Blob([svg], { type: 'image/svg+xml' }), name + '.svg');
+ var box = button.closest('figure').querySelector('svg.nz-svg').viewBox.baseVal;
+ saRasterize(svg, box.width, box.height, 4, function (canvas) {
+ if (kind === 'png') canvas.toBlob(function (blob) { saSaveFile(blob, name + '.png'); });
+ else saSaveFile(saPdfBlob(canvas, box.width * 0.75, box.height * 0.75), name + '.pdf');
+ });
+}
+
+// PNG (4x) of a figure shown as an image file (Figure D.3). Where the page has an opaque origin, a
+// file of the site taints the canvas: a copy of the SVG in window.SA_STATIC_SVG is drawn instead.
+function saImagePng(button, name) {
+ var img = button.closest('figure').querySelector('img');
+ var w = img.naturalWidth, h = img.naturalHeight;
+ var svg = (window.SA_STATIC_SVG || {})[name];
+ function save(canvas) { canvas.toBlob(function (blob) { saSaveFile(blob, name + '.png'); }); }
+ if (svg) return saRasterize(svg, w, h, 4, save);
+ var canvas = document.createElement('canvas');
+ canvas.width = w * 4;
+ canvas.height = h * 4;
+ var ctx = canvas.getContext('2d');
+ ctx.fillStyle = '#ffffff';
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
+ ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
+ save(canvas);
+}
diff --git a/assets/style.css b/assets/style.css
index f2123350b6547777d7c33e8b0fac908ce7db8af1..0555cc4cc2f6d51cc4be1b5d99855ef31a4ac15a 100644
--- a/assets/style.css
+++ b/assets/style.css
@@ -307,3 +307,9 @@ details.nz-raw > summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.nz-tl3 td:nth-child(n+2), .nz-tl3 th:nth-child(n+2) { text-align: right; }
.nz-tl4 td:nth-child(n+2), .nz-tl4 th:nth-child(n+2) { text-align: right; }
#ablation-content h3 { margin-top: 18px; }
+
+/* Download buttons of the figures drawn in the page (assets/downloads.js). */
+.fig-dl { display: flex; justify-content: flex-end; gap: 6px; margin: 0 0 6px; flex-wrap: wrap; }
+.fig-dl button, .fig-dl a { font: inherit; font-size: 0.78rem; padding: 3px 10px; border: 1px solid var(--line);
+ border-radius: 6px; background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; }
+.fig-dl button:hover, .fig-dl a:hover { border-color: var(--accent); }
diff --git a/data/analysis/elo_no_timeouts.html b/data/analysis/elo_no_timeouts.html
index 2ad8f042234e3269658d2d1f44d2e1bb6b138eb8..dac37d13759350f1c40b417d936a18408e1da0be 100644
--- a/data/analysis/elo_no_timeouts.html
+++ b/data/analysis/elo_no_timeouts.html
@@ -17,7 +17,7 @@ html, body { margin:0; padding:0; background:var(--bg); color:var(--fg);
padding:6px 9px; border-radius:6px; border:1px solid var(--line); background:var(--bg); color:var(--fg);
font-size:12px; line-height:1.45; white-space:pre-line; box-shadow:0 2px 8px rgba(0,0,0,0.15); }
#sa-tip b { font-weight:600; }
-