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:
1 parent
9c606aa567
commit
96b99784b5
17 files changed
+944
-37
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// Sibling-CSS isolation probe: a full-frame opaque magenta rect, last child of the drawing, carries each candidate style.
|
||||
// Metric: pure-magenta pixel count (equal to control-none = no marker covered) and, in the canvas, the hit at each point centre.
|
||||
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 doc = JSON.parse(readFileSync(process.argv[2] + '/supabase/seed/anatomical-sheets/equine/draft/document.json', 'utf8'))
|
||||
const points = doc.annotations.filter((a) => a.view_id === 'main' && a.geometry.type === 'circle').map((a) => [a.id, a.geometry.cx, a.geometry.cy])
|
||||
const names = [...new Set(readdirSync(DIR).map((f) => f.split('.')[0]))].sort()
|
||||
const W = 1000, H = Math.round(1000 * 1629.4 / 2073.4)
|
||||
const LIB = `window.mag = (d) => { let n = 0; for (let i = 0; i < d.length; i += 4) if (d[i] === 255 && d[i+1] === 0 && d[i+2] === 255) n++; return n }
|
||||
window.pdf = async (svg) => { const root = new DOMParser().parseFromString(svg, 'image/svg+xml').documentElement; root.setAttribute('width', '${W}'); root.setAttribute('height', '${H}');
|
||||
const url = URL.createObjectURL(new Blob([new XMLSerializer().serializeToString(root)], { type: 'image/svg+xml' })); const img = new Image(); img.width = ${W}; img.height = ${H}; img.src = url; await img.decode();
|
||||
const c = document.createElement('canvas'); c.width = ${W}; c.height = ${H}; const x = c.getContext('2d'); x.fillStyle = '#fff'; x.fillRect(0, 0, ${W}, ${H}); x.drawImage(img, 0, 0, ${W}, ${H}); return window.mag(x.getImageData(0, 0, ${W}, ${H}).data) }
|
||||
window.png = async (b64) => { const img = new Image(); img.src = 'data:image/png;base64,' + b64; await img.decode(); const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; const x = c.getContext('2d'); x.drawImage(img, 0, 0); return window.mag(x.getImageData(0, 0, c.width, c.height).data) }`
|
||||
for (const engine of process.argv[4].split(',')) {
|
||||
const browser = await pw[engine].launch()
|
||||
const work = await browser.newPage(); await work.setContent('<html><body></body></html>'); await work.addScriptTag({ content: LIB })
|
||||
const shot = await browser.newPage({ viewport: { width: 1100, height: 900 } })
|
||||
console.log(`== ${engine} ${browser.version()}`)
|
||||
for (const name of names) {
|
||||
const pdf = await work.evaluate((s) => window.pdf(s), readFileSync(`${DIR}/${name}.pdf.svg`, 'utf8'))
|
||||
const svg = readFileSync(`${DIR}/${name}.canvas.svg`, 'utf8').replace(/^<svg /, `<svg width="${W}" height="${H}" `)
|
||||
await shot.setContent(`<html><body style="margin:0;background:#fff"><div id="h" style="width:${W}px;height:${H}px">${svg}</div></body></html>`)
|
||||
const canvas = await work.evaluate((b) => window.png(b), (await shot.locator('#h').screenshot()).toString('base64'))
|
||||
const s = W / 2073.4
|
||||
const hits = await shot.evaluate(([pts, s]) => pts.filter(([id, cx, cy]) => document.elementFromPoint(cx * s, cy * s)?.closest('[data-anno-id]')?.getAttribute('data-anno-id') === id).length, [points, s])
|
||||
console.log(name.padEnd(16), JSON.stringify({ pdf_magenta: pdf, canvas_magenta: canvas, point_hits: `${hits}/${points.length}` }))
|
||||
}
|
||||
await browser.close()
|
||||
}
|
||||
Reference in new issue
Block a user