fix(anatomy): V1-2.2 refuse markers too small on the phone preview

Owner decision 2026-11-01: the scale bypass (viewBox blown up, drawing
scaled back) is closed by the visible size, 4 CSS px on the editor at
320 x 568 (equine junctions 4.97 px), verdict marker_too_small. A frame
is usable only where browsers draw it faithfully: edges within 2^20,
span from 1 unit, aspect 100, offset 256 spans; measured in 3 engines.
This commit is contained in:
bchanot committed 2026-11-01 01:28:48 +01:00
1 parent 9c606aa567
commit 96b99784b5
17 files changed
+944 -37

No files matched your search

@@ -0,0 +1,32 @@
// Rust vs browser on the frame limits (owner brief 2026-11-01): each case is a composed canvas
// (`frame_probe_generator.rs.txt`) with the core's f64 expectation of every visible disc (size and
// centre in CSS px on the smallest preview box). The browser draws it in a box of that size, CSS as
// AnatomyCanvas (svg max-width/max-height 100 %, centred); answers the largest size and centre gaps.
import { createRequire } from 'node:module'
import { readFileSync, readdirSync } from 'node:fs'
const require = createRequire(process.argv[2] + '/apps/app/package.json')
const pw = require('@playwright/test')
const DIR = process.argv[3]
const cases = readdirSync(DIR).filter((f) => f.endsWith('.json')).sort().map((f) => JSON.parse(readFileSync(`${DIR}/${f}`, 'utf8')))
for (const engine of process.argv[4].split(',')) {
const browser = await pw[engine].launch()
const page = await browser.newPage({ viewport: { width: 600, height: 600 } })
console.log(`== ${engine} ${browser.version()}`)
for (const c of cases) {
const [bw, bh] = c.box
await page.setContent(`<html><body style="margin:0"><div id="b" style="width:${bw}px;height:${bh}px">${c.svg.replace(/^<svg /, '<svg style="max-width:100%;max-height:100%;display:block;margin:0 auto" ')}</div></body></html>`)
const got = await page.evaluate((markers) => {
const svg = document.querySelector('#b svg'); const s = svg.getBoundingClientRect()
// The hitbox (stroke none): Firefox counts a stroke in an element's client rect, the others do not.
const boxes = [...svg.querySelectorAll('circle[pointer-events="visibleFill"]')]
return markers.map((m) => { const t = boxes.find((e) => e.getAttribute('data-anno-id') === m.id); if (!t) return null
const r = t.getBoundingClientRect(); return { size: r.width, cx: r.x + r.width / 2 - s.x, cy: r.y + r.height / 2 - s.y } })
}, c.markers)
let size = 0, centre = 0
c.markers.forEach((m, i) => { const g = got[i]; if (!g) { size = Infinity; return }
size = Math.max(size, Math.abs(g.size - m.hitbox) / m.hitbox); centre = Math.max(centre, Math.hypot(g.cx - m.cx, g.cy - m.cy)) })
const disc = Math.min(...c.markers.map((m) => m.size))
console.log(c.name.padEnd(30), c.core.padEnd(12), JSON.stringify({ core_disc_px: +disc.toPrecision(4), hitbox_size_gap_rel: +size.toPrecision(2), max_centre_gap_px: +centre.toPrecision(2) }))
}
await browser.close()
}