nx_cdmap_pixjudge_lib.nx
buildroot/runtime/nx_cdmap_pixjudge_lib.nx
about
nx_cdmap_pixjudge_lib.nx -- the position map's PIXEL REFEREE (datavis DV2, 2026-09-15): the emitted cdmap SVG is re-drawn
as INK and the readability defects are counted on the pixels. Every player label is rasterised glyph by glyph through
the sovereign TrueType engine (nx_ttf_fontlib, the browser's own font renderer: real outlines, real hmtx advances, the
pen walk tf_draw_text walks) and every mark is a filled disk; then: two labels whose ink shares a pixel (LL), a label
whose ink enters ANOTHER player's disk (LM), a label whose ink leaves the plot frame (OFF), marks whose disks overlap
(MM, the centre-distance rule cl_critic uses, a data property). DEFECTS = LL + LM + OFF, the same sum the emitter
publishes, so the pixel vector and the published vector compare slot for slot. SPREAD is a data property, not an ink
property, and is not re-derived here.
WHY: the self-grade counts BOXES whose width is a heuristic (CL_TEXT_W_PERMIL per glyph); a face wider than the
heuristic, or a run of wide glyphs, overlaps in ink while the boxes stay apart -- a font-metric drift the box
arithmetic cannot see. This ruler is the in-estate half of the liar-killer: it renders through a second path (glyph
coverage, not box arithmetic) and disagrees when the picture does. A foreign browser stays an oracle outside the path.
A label's OWN mark is skipped by design, exactly as cl_critic skips it (a halo label sits on its mark on purpose).
Ink = coverage at or above CRG_INK_MIN of 255: an anti-aliased fringe is not ink a reader collides on.
The figure grammar is cr_scan's (composed, never re-implemented). license_tier: ORIGINAL. No hw writes (Rule 26).
dependencies 2 imports · 2 importers
imports: nx_syscalls.nxnx_cdmap_referee_lib.nx
imported by: nx_cdmap_pixjudge.nxnx_cdmap_pixjudge_gate.nx
structs
| none |
consts
| 19 | const CRG_INK_MIN: i64 = 128 // half coverage: below this a pixel is fringe, not ink |
| 20 | const CRG_VB_W_DEFAULT: i64 = 760 // the emitter's CDP_SVG_W, used only when the svg carries no viewBox |
| 21 | const CRG_VB_H_DEFAULT: i64 = 520 // the emitter's CDP_SVG_H |
| 22 | const CRG_VB_MAX: i64 = 4096 // a viewBox axis past this is refused (one mask would exceed 16 MiB) |
| 23 | const CRG_I64_BYTES: i64 = 8 |
| 24 | const CRG_CH_SPACE: i64 = 32 |
| 25 | const CRG_BBOX_W: i64 = 4 // minx miny maxx maxy per label, in canvas coordinates, UNCLIPPED |
| 26 | const CRG_B_X0: i64 = 0 |
| 27 | const CRG_B_Y0: i64 = 1 |
| 28 | const CRG_B_X1: i64 = 2 |
| 29 | const CRG_B_Y1: i64 = 3 |
| 31 | const CRG_R_MX: i64 = 0 |
| 32 | const CRG_R_MY: i64 = 1 |
| 33 | const CRG_R_MR: i64 = 2 |
| 34 | const CRG_R_LX: i64 = 3 |
| 35 | const CRG_R_LY: i64 = 4 |
| 36 | const CRG_R_LFONT: i64 = 5 |
| 37 | const CRG_R_LBOLD: i64 = 6 |
| 38 | const CRG_R_FRAME: i64 = 7 |
| 39 | const CRG_R_OUT: i64 = 8 |
| 40 | const CRG_R_NAMES: i64 = 9 |
| 41 | const CRG_R_NL: i64 = 10 |
| 42 | const CRG_R_NM: i64 = 11 |
| 43 | const CRG_R_W: i64 = 12 |
| 44 | const CRG_R_H: i64 = 13 |
| 45 | const CRG_R_MASKS: i64 = 14 |
| 46 | const CRG_R_INK: i64 = 15 |
| 47 | const CRG_R_BBOX: i64 = 16 |
| 50 | const CRG_R_NNL: i64 = 17 // note lines found |
| 51 | const CRG_R_NN: i64 = 18 // notes (groups) found |
| 52 | const CRG_R_NLX: i64 = 19 |
| 53 | const CRG_R_NLY: i64 = 20 // the baseline as emitted |
| 54 | const CRG_R_NLFONT: i64 = 21 |
| 55 | const CRG_R_NLNOTE: i64 = 22 // the note each line belongs to |
| 56 | const CRG_R_NNAMES: i64 = 23 |
| 57 | const CRG_R_NMASKS: i64 = 24 // one mask per note |
| 58 | const CRG_R_NINK: i64 = 25 |
| 59 | const CRG_R_NBBOX: i64 = 26 |
| 60 | const CRG_R_SLOTS: i64 = 27 |
| 62 | const CRG_V_LL: i64 = 0 |
| 63 | const CRG_V_LM: i64 = 1 |
| 64 | const CRG_V_OFF: i64 = 2 |
| 65 | const CRG_V_MM: i64 = 3 |
| 66 | const CRG_V_INKPX: i64 = 4 // ink pixels over every label: a scale field, 0 means nothing was drawn |
| 67 | const CRG_V_DEFECTS: i64 = 5 |
| 68 | const CRG_V_W: i64 = 6 |
| 70 | const CRG_OK: i64 = 0 |
| 71 | const CRG_NO_FIGURE: i64 = 0 - 1 |
| 72 | const CRG_NO_LABELS: i64 = 0 - 2 |
| 73 | const CRG_UNPAIRED: i64 = 0 - 3 |
| 74 | const CRG_NO_FRAME: i64 = 0 - 4 |
| 75 | const CRG_NO_FONT: i64 = 0 - 5 |
| 76 | const CRG_NO_INK: i64 = 0 - 6 |
| 77 | const CRG_CANVAS: i64 = 0 - 7 |
functions
| 79 | func crg_i64(n: i64) -> *i64 { return sys_mmap(n * CRG_I64_BYTES) as *i64 } |
| 80 | func crg_rec_new() -> *i64 |
| 107 | func crg_nbbox_at(r: *i64, g: i64) -> *i64 { return ((r[CRG_R_NBBOX] as i64) + g * CRG_BBOX_W * CRG_I64_BYTES) as *i64 } |
| 109 | func crg_bbox_union(bb: *i64, bb2: *i64) -> i64 called by 1: crg_ink |
| 118 | func crg_skip_num(h: *u8, p: i64, to: i64) -> i64 called by 1: crg_viewbox |
| 130 | func crg_skip_sp(h: *u8, p: i64, to: i64) -> i64 called by 1: crg_viewbox |
| 140 | func crg_viewbox(h: *u8, n: i64, wh: *i64) -> i64 |
| 171 | func crg_scan(h: *u8, n: i64, r: *i64) -> i64 |
| 198 | func crg_mask_label(fh: *i64, s: *u8, ph: i64, x: i64, ybase: i64, W: i64, H: i64, mask: *u8, bb: *i64) -> i64 |
| 241 | func crg_overlap(a: *u8, b: *u8, npx: i64) -> i64 |
| 248 | func crg_ink_over_disk(mask: *u8, W: i64, H: i64, cx: i64, cy: i64, rad: i64) -> i64 |
| 270 | func crg_bbox_off(bb: *i64, fr: *i64) -> i64 |
| 279 | func crg_ink(r: *i64, fhr: *i64, fhb: *i64) -> i64 |
| 336 | func crg_vector(r: *i64, vec: *i64) -> i64 |
| 403 | func crg_judge(h: *u8, n: i64, fhr: *i64, fhb: *i64, r: *i64, vec: *i64) -> i64 |
| 413 | func crg_agree(vec: *i64, published_defects: i64) -> i64 |
| 418 | func crg_rc_name(rc: i64) -> *u8 called by 1: main |
| 430 | func crg_bbox_at(r: *i64, i: i64) -> *i64 { return ((r[CRG_R_BBOX] as i64) + i * CRG_BBOX_W * CRG_I64_BYTES) as *i64 } |