code wiki / _hdl_build / nx_chartlay_gate.nx
nx_chartlay_gate.nx source
↩ module page · 279 lines · 18569 B
1// nx_chartlay_gate.nx -- referee for nx_chartlay_lib (datavis DV1, 2026-09-15): hand-worked domains and ticks, the
2// integer scale both ways, the box arithmetic, the placer and the critic on THE LIVE CLUSTER that drew the operator's
3// junk verdict (five players, positions from the 2026-09-15 search spine) -- the junk layout must grade as junk, the
4// domain-fit layout must place every label clear and spread the field, and a canvas too small to seat anything must
5// read UNRESOLVED rather than pass. license_tier: ORIGINAL
6import "nx_chartlay_lib.nx"
7import "nx_syscalls.nx"
8import "nx_gate_verdict.nx"
9
10const G_N: i64 = 5
11const G_FONT: i64 = 13
12// the junk layout: the live 2026-09-15 marks as the fixed 0..1000 canvas placed them (svg 760x520, plot 70..730 x 30..460)
13const G_OLD_X0: i64 = 565
14const G_OLD_X1: i64 = 656
15const G_OLD_X2: i64 = 686
16const G_OLD_X3: i64 = 706
17const G_OLD_X4: i64 = 648
18const G_OLD_Y0: i64 = 374
19const G_OLD_Y1: i64 = 434
20const G_OLD_Y2: i64 = 428
21const G_OLD_Y3: i64 = 334
22const G_OLD_Y4: i64 = 435
23// the same players' permil values (centrality, distinctiveness) and bubble radii
24const G_C0: i64 = 750
25const G_C1: i64 = 888
26const G_C2: i64 = 934
27const G_C3: i64 = 965
28const G_C4: i64 = 877
29const G_D0: i64 = 199
30const G_D1: i64 = 60
31const G_D2: i64 = 74
32const G_D3: i64 = 291
33const G_D4: i64 = 58
34const G_R_SMALL: i64 = 15
35const G_R_BIG: i64 = 17
36const G_PLOT_X0: i64 = 70
37const G_PLOT_Y0: i64 = 30
38const G_PLOT_X1: i64 = 730
39const G_PLOT_Y1: i64 = 460
40const G_CANVAS_IN: i64 = 2
41const G_TINY: i64 = 30
42const G_SPREAD_FLOOR: i64 = 600
43const G_EXP_TICKS_A: i64 = 7
44const G_EXP_TICKS_B: i64 = 8
45const G_EXP_TICKS_C: i64 = 5
46const G_EXP_TICKS_D: i64 = 6
47const G_EXP_TICKS_E: i64 = 4
48const G_V_A_LO: i64 = 700
49const G_V_A_HI: i64 = 1000
50const G_V_B_LO: i64 = 0
51const G_V_B_HI: i64 = 350
52const G_V_C: i64 = 500
53const G_V_C_LO: i64 = 480
54const G_V_C_HI: i64 = 520
55const G_V_E_LO: i64 = 990
56const G_V_E_LO_EXP: i64 = 970
57const G_SC_MID: i64 = 850
58const G_SC_MID_PX: i64 = 400
59const G_TW_5: i64 = 36
60const G_TH_13: i64 = 16
61const G_BOX_A: i64 = 10
62const G_BOX_W: i64 = 20
63const G_BOX_B_TOUCH: i64 = 30
64const G_BOX_B_OVER: i64 = 25
65
66func g_fill5(a: *i64, v0: i64, v1: i64, v2: i64, v3: i64, v4: i64) -> i64 { a[0] = v0; a[1] = v1; a[2] = v2; a[3] = v3; a[4] = v4; return 0 }
67func g_names(i: i64) -> *u8 {
68 if i == 0 { return "Nishi" as *u8 }
69 if i == 1 { return "Mojeek" as *u8 }
70 if i == 2 { return "Brave" as *u8 }
71 if i == 3 { return "Google" as *u8 }
72 return "Marginalia" as *u8
73}
74func g_alloc() -> *i64 { return sys_mmap((G_N + 1) * CL_I64_BYTES) as *i64 }
75const G_CT_DIR: *u8 = "/tmp/nx_chartlay_gate/"
76const G_CT_CONF: *u8 = "/tmp/nx_chartlay_gate/contrast.conf"
77const G_CT_ABSENT: *u8 = "/tmp/nx_chartlay_gate/absent.conf"
78const G_DIR_MODE: i64 = 493
79const G_FILE_MODE: i64 = 420
80const G_RS_RW: i64 = 300 // the reseat region
81const G_RS_RH: i64 = 200
82const G_RS_CX: i64 = 150 // both boxes anchor at the region's centre
83const G_RS_CY: i64 = 100
84const G_RS_BIG_W: i64 = 200 // the fixed box covers the centre
85const G_RS_BIG_H: i64 = 120
86const G_RS_SMALL_W: i64 = 60
87const G_RS_SMALL_H: i64 = 14
88func g_write_text(path: *u8, s: *u8) -> i64 {
89 let fd: i64 = sys_openat_wr(path, G_FILE_MODE)
90 if fd < 0 { return 0 - 1 }
91 sys_write(fd, s, chl_slen(s))
92 sys_close(fd)
93 return 0
94}
95
96func main() -> i64 {
97 let ctr: *i64 = gv_ctr()
98 gv_head("=== NX-CHARTLAY GATE -- domain-fit scales, the placer and the critic on the live junk cluster ===" as *u8)
99 let dom: *i64 = sys_mmap(CL_DOM_W * CL_I64_BYTES) as *i64
100 // T1: domains
101 gv_check_eq("T1-domain-750..965-ticks" as *u8, cl_domain(G_C0, G_C3, dom), G_EXP_TICKS_A, ctr)
102 gv_check_eq("T1a-domain-750..965-lo-700" as *u8, dom[CL_D_LO], G_V_A_LO, ctr)
103 gv_check_eq("T1b-domain-750..965-hi-1000" as *u8, dom[CL_D_HI], G_V_A_HI, ctr)
104 gv_check_eq("T1c-domain-750..965-step-50" as *u8, dom[CL_D_STEP], CL_STEP_50, ctr)
105 gv_check_eq("T1d-domain-58..291-ticks" as *u8, cl_domain(G_D4, G_D3, dom), G_EXP_TICKS_B, ctr)
106 gv_check_eq("T1e-domain-58..291-lo-0" as *u8, dom[CL_D_LO], G_V_B_LO, ctr)
107 gv_check_eq("T1f-domain-58..291-hi-350" as *u8, dom[CL_D_HI], G_V_B_HI, ctr)
108 gv_check_eq("T1g-single-value-still-a-window" as *u8, cl_domain(G_V_C, G_V_C, dom), G_EXP_TICKS_C, ctr)
109 gv_check_eq("T1h-single-value-lo-480" as *u8, dom[CL_D_LO], G_V_C_LO, ctr)
110 gv_check_eq("T1i-single-value-hi-520" as *u8, dom[CL_D_HI], G_V_C_HI, ctr)
111 gv_check_eq("T1j-full-range-ticks" as *u8, cl_domain(0, CL_PERMIL, dom), G_EXP_TICKS_D, ctr)
112 gv_check_eq("T1k-full-range-step-200" as *u8, dom[CL_D_STEP], CL_STEP_200, ctr)
113 gv_check_eq("T1l-top-edge-ticks" as *u8, cl_domain(G_V_E_LO, CL_PERMIL, dom), G_EXP_TICKS_E, ctr)
114 gv_check_eq("T1m-top-edge-lo-970" as *u8, dom[CL_D_LO], G_V_E_LO_EXP, ctr)
115 gv_check_eq("T1n-NEG-top-edge-never-past-1000" as *u8, dom[CL_D_HI], CL_PERMIL, ctr)
116 gv_check_eq("T1o-reversed-args-same-domain" as *u8, cl_domain(G_C3, G_C0, dom), G_EXP_TICKS_A, ctr)
117 gv_check_eq("T1p-tick-walk-ends-at-hi" as *u8, cl_tick(dom, cl_ticks(dom) - 1), dom[CL_D_HI], ctr)
118 // T2: the scale both ways
119 gv_check_eq("T2-scale-lo-maps-to-p0" as *u8, cl_scale(G_V_A_LO, G_V_A_LO, G_V_A_HI, G_PLOT_X0, G_PLOT_X1), G_PLOT_X0, ctr)
120 gv_check_eq("T2a-scale-hi-maps-to-p1" as *u8, cl_scale(G_V_A_HI, G_V_A_LO, G_V_A_HI, G_PLOT_X0, G_PLOT_X1), G_PLOT_X1, ctr)
121 gv_check_eq("T2b-scale-midpoint" as *u8, cl_scale(G_SC_MID, G_V_A_LO, G_V_A_HI, G_PLOT_X0, G_PLOT_X1), G_SC_MID_PX, ctr)
122 gv_check_eq("T2c-inverted-lo-maps-to-p0" as *u8, cl_scale(G_V_B_LO, G_V_B_LO, G_V_B_HI, G_PLOT_Y1, G_PLOT_Y0), G_PLOT_Y1, ctr)
123 gv_check_eq("T2d-inverted-hi-maps-to-p1" as *u8, cl_scale(G_V_B_HI, G_V_B_LO, G_V_B_HI, G_PLOT_Y1, G_PLOT_Y0), G_PLOT_Y0, ctr)
124 gv_check_eq("T2e-NEG-degenerate-domain-returns-p0" as *u8, cl_scale(G_V_C, G_V_C, G_V_C, G_PLOT_X0, G_PLOT_X1), G_PLOT_X0, ctr)
125 // T3: text metrics and boxes
126 gv_check_eq("T3-text-width-5-chars-13px" as *u8, cl_text_w(chl_slen(g_names(0)), G_FONT), G_TW_5, ctr)
127 gv_check_eq("T3a-text-height-13px" as *u8, cl_text_h(G_FONT), G_TH_13, ctr)
128 gv_check_eq("T3b-boxes-disjoint" as *u8, cl_box_hit(0, 0, G_BOX_W, G_BOX_W, G_BOX_B_TOUCH + G_BOX_A, 0, G_BOX_W, G_BOX_W), 0, ctr)
129 gv_check_eq("T3c-NEG-boxes-touching-edge-do-not-hit" as *u8, cl_box_hit(G_BOX_A, G_BOX_A, G_BOX_W, G_BOX_W, G_BOX_B_TOUCH, G_BOX_A, G_BOX_W, G_BOX_W), 0, ctr)
130 gv_check_eq("T3d-boxes-overlapping-hit" as *u8, cl_box_hit(G_BOX_A, G_BOX_A, G_BOX_W, G_BOX_W, G_BOX_B_OVER, G_BOX_A, G_BOX_W, G_BOX_W), 1, ctr)
131 gv_check_eq("T3e-leader-flag-off-for-adjacent-seats" as *u8, cl_leader(CL_CAND_BELOW), 0, ctr)
132 gv_check_eq("T3f-leader-flag-on-for-far-seats" as *u8, cl_leader(CL_CAND_RU), 1, ctr)
133 // T4: the junk layout graded by the critic (labels as the old renderer placed them: right of the mark, mid-height)
134 let mx: *i64 = g_alloc()
135 let my: *i64 = g_alloc()
136 let mr: *i64 = g_alloc()
137 let lw: *i64 = g_alloc()
138 let lh: *i64 = g_alloc()
139 let lx: *i64 = g_alloc()
140 let ly: *i64 = g_alloc()
141 let ls: *i64 = g_alloc()
142 let lr: *i64 = g_alloc()
143 let crit: *i64 = sys_mmap(CL_CRIT_W * CL_I64_BYTES) as *i64
144 g_fill5(mx, G_OLD_X0, G_OLD_X1, G_OLD_X2, G_OLD_X3, G_OLD_X4)
145 g_fill5(my, G_OLD_Y0, G_OLD_Y1, G_OLD_Y2, G_OLD_Y3, G_OLD_Y4)
146 g_fill5(mr, G_R_SMALL, G_R_SMALL, G_R_SMALL, G_R_BIG, G_R_SMALL)
147 var i: i64 = 0
148 let xy: *i64 = sys_mmap(CL_TWO * CL_I64_BYTES) as *i64
149 while i < G_N { lw[i] = cl_text_w(chl_slen(g_names(i)), G_FONT); lh[i] = cl_text_h(G_FONT); cl_cand(CL_CAND_RIGHT, mx[i], my[i], mr[i], lw[i], lh[i], xy); lx[i] = xy[0]; ly[i] = xy[1]; i = i + 1 }
150 let old_defects: i64 = cl_critic(G_N, mx, my, mr, lx, ly, lw, lh, G_PLOT_X0, G_PLOT_Y0, G_PLOT_X1, G_PLOT_Y1, crit)
151 gv_check("T4-junk-layout-has-label-overlaps" as *u8, (crit[CL_C_LL] > 0) as i64, ctr)
152 gv_check("T4a-junk-layout-has-off-canvas-labels" as *u8, (crit[CL_C_OFF] > 0) as i64, ctr)
153 gv_check("T4b-junk-layout-has-mark-overlaps" as *u8, (crit[CL_C_MM] > 0) as i64, ctr)
154 gv_check("T4c-junk-layout-defects-nonzero" as *u8, (old_defects > 0) as i64, ctr)
155 let old_spread: i64 = crit[CL_C_SPREAD]
156 let old_mm: i64 = crit[CL_C_MM]
157 // T5: the domain-fit layout of the SAME players, placed by the placer, graded by the critic
158 let domx: *i64 = sys_mmap(CL_DOM_W * CL_I64_BYTES) as *i64
159 let domy: *i64 = sys_mmap(CL_DOM_W * CL_I64_BYTES) as *i64
160 cl_domain(G_C0, G_C3, domx)
161 cl_domain(G_D4, G_D3, domy)
162 let cx: *i64 = g_alloc()
163 let cy: *i64 = g_alloc()
164 g_fill5(cx, G_C0, G_C1, G_C2, G_C3, G_C4)
165 g_fill5(cy, G_D0, G_D1, G_D2, G_D3, G_D4)
166 i = 0
167 while i < G_N { mx[i] = cl_scale_dom(cx[i], domx, G_PLOT_X0, G_PLOT_X1); my[i] = cl_scale_dom(cy[i], domy, G_PLOT_Y1, G_PLOT_Y0); i = i + 1 }
168 let unresolved: i64 = cl_place(G_N, mx, my, mr, lw, lh, G_PLOT_X0 + G_CANVAS_IN, G_PLOT_Y0 + G_CANVAS_IN, G_PLOT_X1 - G_CANVAS_IN, G_PLOT_Y1 - G_CANVAS_IN, lx, ly, ls, lr)
169 let new_defects: i64 = cl_critic(G_N, mx, my, mr, lx, ly, lw, lh, G_PLOT_X0, G_PLOT_Y0, G_PLOT_X1, G_PLOT_Y1, crit)
170 gv_check_eq("T5-fit-layout-every-label-resolved" as *u8, unresolved, 0, ctr)
171 gv_check_eq("T5a-fit-layout-no-label-overlaps" as *u8, crit[CL_C_LL], 0, ctr)
172 gv_check_eq("T5b-fit-layout-no-label-over-mark" as *u8, crit[CL_C_LM], 0, ctr)
173 gv_check_eq("T5c-fit-layout-nothing-off-canvas" as *u8, crit[CL_C_OFF], 0, ctr)
174 gv_check_eq("T5d-fit-layout-zero-defects" as *u8, new_defects, 0, ctr)
175 gv_check("T5e-fit-layout-no-more-mark-overlaps-than-junk" as *u8, (crit[CL_C_MM] <= old_mm) as i64, ctr)
176 gv_check("T5f-fit-layout-spreads-the-field" as *u8, (crit[CL_C_SPREAD] > old_spread) as i64, ctr)
177 gv_check("T5g-fit-layout-spread-at-least-600-permil" as *u8, (crit[CL_C_SPREAD] >= G_SPREAD_FLOOR) as i64, ctr)
178 gv_check_eq("T5h-house-player-takes-the-right-seat" as *u8, ls[0], CL_CAND_RIGHT, ctr)
179 let fit_spread: i64 = crit[CL_C_SPREAD]
180 let fit_mm: i64 = crit[CL_C_MM]
181 // T6: NEG -- a canvas too small to seat anything must say so (this overwrites crit: the fit numbers were banked above)
182 let tiny_unres: i64 = cl_place(G_N, mx, my, mr, lw, lh, G_PLOT_X0, G_PLOT_Y0, G_PLOT_X0 + G_TINY, G_PLOT_Y0 + G_TINY, lx, ly, ls, lr)
183 cl_critic(G_N, mx, my, mr, lx, ly, lw, lh, G_PLOT_X0, G_PLOT_Y0, G_PLOT_X0 + G_TINY, G_PLOT_Y0 + G_TINY, crit)
184 gv_check("T6-NEG-tiny-canvas-leaves-labels-unresolved" as *u8, (tiny_unres > 0) as i64, ctr)
185 gv_check("T6a-NEG-tiny-canvas-critic-sees-defects" as *u8, (crit[CL_C_DEFECTS] > 0) as i64, ctr)
186 // T9: cl_place_from (2026-09-15) -- nfixed=0 reproduces cl_place seat for seat; a FIXED entry is never moved and a later
187 // entry avoids its box; the NEG control shows the avoidance was caused by the fixed flag and nothing else
188 let u_a: i64 = cl_place(G_N, mx, my, mr, lw, lh, G_PLOT_X0 + G_CANVAS_IN, G_PLOT_Y0 + G_CANVAS_IN, G_PLOT_X1 - G_CANVAS_IN, G_PLOT_Y1 - G_CANVAS_IN, lx, ly, ls, lr)
189 let flx: *i64 = g_alloc()
190 let fly: *i64 = g_alloc()
191 let fls: *i64 = g_alloc()
192 let flr: *i64 = g_alloc()
193 let flw: *i64 = g_alloc()
194 let flh: *i64 = g_alloc()
195 i = 0
196 while i < G_N { flw[i] = lw[i]; flh[i] = lh[i]; i = i + 1 }
197 let u_b: i64 = cl_place_from(G_N, 0, mx, my, mr, flw, flh, G_PLOT_X0 + G_CANVAS_IN, G_PLOT_Y0 + G_CANVAS_IN, G_PLOT_X1 - G_CANVAS_IN, G_PLOT_Y1 - G_CANVAS_IN, flx, fly, fls, flr)
198 var same_seats: i64 = 1
199 i = 0
200 while i < G_N { if flx[i] != lx[i] { same_seats = 0 } if fly[i] != ly[i] { same_seats = 0 } i = i + 1 }
201 gv_check("T9-place-from-with-nothing-fixed-is-the-placer-seat-for-seat" as *u8, same_seats * (u_a == u_b) as i64, ctr)
202 // entry 0 becomes a FIXED box parked exactly on entry 1's baseline seat
203 flx[0] = lx[1]; fly[0] = ly[1]; flw[0] = lw[1]; flh[0] = lh[1]
204 let u_c: i64 = cl_place_from(G_N, 1, mx, my, mr, flw, flh, G_PLOT_X0 + G_CANVAS_IN, G_PLOT_Y0 + G_CANVAS_IN, G_PLOT_X1 - G_CANVAS_IN, G_PLOT_Y1 - G_CANVAS_IN, flx, fly, fls, flr)
205 gv_check("T9a-a-fixed-entry-is-never-moved" as *u8, (flx[0] == lx[1]) as i64 * (fly[0] == ly[1]) as i64, ctr)
206 gv_check_eq("T9b-the-entry-whose-seat-was-taken-avoids-the-fixed-box" as *u8, cl_box_hit(flx[1], fly[1], flw[1], flh[1], flx[0], fly[0], flw[0], flh[0]), 0, ctr)
207 gv_check("T9c-that-entry-moved-off-its-baseline-seat" as *u8, ((flx[1] != lx[1]) as i64 + (fly[1] != ly[1]) as i64 > 0) as i64, ctr)
208 gv_check_eq("T9d-nothing-left-unresolved-by-the-obstacle" as *u8, u_c, 0, ctr)
209 // NEG: with nothing fixed the same arrays put entry 1 straight back on its baseline seat
210 let u_d: i64 = cl_place_from(G_N, 0, mx, my, mr, flw, flh, G_PLOT_X0 + G_CANVAS_IN, G_PLOT_Y0 + G_CANVAS_IN, G_PLOT_X1 - G_CANVAS_IN, G_PLOT_Y1 - G_CANVAS_IN, flx, fly, fls, flr)
211 gv_check("T9e-NEG-unfixed-the-seat-returns-so-the-flag-was-the-cause" as *u8, (flx[1] == lx[1]) as i64 * (fly[1] == ly[1]) as i64 * (u_d == u_a) as i64, ctr)
212 // T10: the contrast ruler (datavis DV3, 2026-09-15) -- the WCAG 2.x kernel through cl_contrast, the size-and-weight
213 // tiers, the policy file both present and absent, an unimplemented algorithm falling to defaults ANNOUNCED, and the
214 // measured reason the quadrant words lost their three-quarter opacity
215 gv_check_eq("T10-kat-black-on-white-is-21.00" as *u8, cl_contrast(0, 0, 0, 255, 255, 255), 2100, ctr)
216 gv_check_eq("T10a-kat-767676-on-white-is-4.54" as *u8, cl_contrast(118, 118, 118, 255, 255, 255), 454, ctr)
217 let ct: *i64 = sys_mmap(CL_CT_W * CL_I64_BYTES) as *i64
218 sys_mkdir(G_CT_DIR, G_DIR_MODE)
219 gv_check_eq("T10b-absent-policy-yields-defaults-and-says-so" as *u8, cl_contrast_conf(G_CT_ABSENT, ct), 0, ctr)
220 gv_check_eq("T10c-default-small-floor-is-4.50" as *u8, ct[CL_CT_SMALL], 450, ctr)
221 gv_check_eq("T10d-13px-regular-is-the-small-tier" as *u8, cl_contrast_floor(13, 0, ct), 450, ctr)
222 gv_check_eq("T10e-13px-bold-is-still-the-small-tier" as *u8, cl_contrast_floor(13, 1, ct), 450, ctr)
223 gv_check_eq("T10f-14px-bold-is-the-large-tier" as *u8, cl_contrast_floor(14, 1, ct), 300, ctr)
224 gv_check_eq("T10g-18px-regular-is-the-large-tier" as *u8, cl_contrast_floor(18, 0, ct), 300, ctr)
225 g_write_text(G_CT_CONF, "algorithm|wcag2-ratio|the kernel this ruler implements\nfloor_small_x100|500|a stricter house floor\nlarge_px|20|a later large tier\n" as *u8)
226 gv_check_eq("T10h-policy-read-flag" as *u8, cl_contrast_conf(G_CT_CONF, ct), 1, ctr)
227 gv_check_eq("T10i-policy-moves-the-small-floor" as *u8, ct[CL_CT_SMALL], 500, ctr)
228 gv_check_eq("T10j-policy-moves-the-large-tier" as *u8, ct[CL_CT_LARGE_PX], 20, ctr)
229 gv_check_eq("T10k-policy-leaves-unnamed-rows-at-their-defaults" as *u8, ct[CL_CT_LARGE], 300, ctr)
230 g_write_text(G_CT_CONF, "algorithm|apca-w3|an algorithm this ruler does not implement\nfloor_small_x100|100|would be ignored\n" as *u8)
231 gv_check_eq("T10l-NEG-an-unimplemented-algorithm-falls-to-defaults-announced" as *u8, cl_contrast_conf(G_CT_CONF, ct), CL_CT_UNKNOWN_ALG, ctr)
232 gv_check_eq("T10m-NEG-and-its-floors-are-not-taken" as *u8, ct[CL_CT_SMALL], 450, ctr)
233 gv_check_eq("T10n-house-fg-on-panel-clears-the-small-floor" as *u8, cl_contrast_ok(cl_contrast(26, 26, 28, 249, 247, 243), 450), 1, ctr)
234 gv_check_eq("T10o-muted-at-full-on-panel-clears-the-small-floor" as *u8, cl_contrast_ok(cl_contrast(92, 96, 104, 249, 247, 243), 450), 1, ctr)
235 gv_check_eq("T10p-NEG-muted-at-three-quarters-on-panel-fails-the-small-floor" as *u8, cl_contrast_ok(cl_contrast(cl_blend(92, 249, 750), cl_blend(96, 247, 750), cl_blend(104, 243, 750), 249, 247, 243), 450), 0, ctr)
236 gv_check_eq("T10q-blend-arithmetic" as *u8, cl_blend(92, 249, 750), 131, ctr)
237 // T11: reseat inside a region -- a box the placer clamped takes a free corner; a region its neighbour fills refuses
238 let rmx: *i64 = g_alloc()
239 let rmy: *i64 = g_alloc()
240 let rmr: *i64 = g_alloc()
241 let rlx: *i64 = g_alloc()
242 let rly: *i64 = g_alloc()
243 let rlw: *i64 = g_alloc()
244 let rlh: *i64 = g_alloc()
245 rmx[0] = G_RS_CX; rmy[0] = G_RS_CY; rmr[0] = 0; rlx[0] = G_RS_CX - G_RS_BIG_W / CL_TWO; rly[0] = G_RS_CY - G_RS_BIG_H / CL_TWO; rlw[0] = G_RS_BIG_W; rlh[0] = G_RS_BIG_H
246 rmx[1] = G_RS_CX; rmy[1] = G_RS_CY; rmr[1] = 0; rlx[1] = rlx[0]; rly[1] = rly[0]; rlw[1] = G_RS_SMALL_W; rlh[1] = G_RS_SMALL_H
247 gv_check_eq("T11-a-clamped-box-takes-a-free-corner-of-its-region" as *u8, cl_reseat_in(1, 2, rmx, rmy, rmr, rlx, rly, rlw, rlh, 0, 0, G_RS_RW, G_RS_RH), 1, ctr)
248 gv_check("T11a-the-seat-is-the-first-corner" as *u8, (rlx[1] == CL_GAP) as i64 * (rly[1] == CL_GAP) as i64, ctr)
249 gv_check_eq("T11b-the-reseated-box-is-clear-of-the-fixed-one" as *u8, cl_box_hit(rlx[1], rly[1], rlw[1], rlh[1], rlx[0], rly[0], rlw[0], rlh[0]), 0, ctr)
250 rlx[0] = 0; rly[0] = 0; rlw[0] = G_RS_RW; rlh[0] = G_RS_RH
251 gv_check_eq("T11c-NEG-a-region-its-neighbour-fills-refuses-the-reseat" as *u8, cl_reseat_in(1, 2, rmx, rmy, rmr, rlx, rly, rlw, rlh, 0, 0, G_RS_RW, G_RS_RH), 0, ctr)
252 // T7: the palette
253 gv_check("T7-slot-0-is-the-house-accent-token" as *u8, (chl_slen(cl_palette(CL_PAL_ACCENT)) > 0) as i64, ctr)
254 var distinct: i64 = 1
255 var a: i64 = 0
256 while a < CL_PAL_N {
257 var b: i64 = a + 1
258 while b < CL_PAL_N {
259 let pa: *u8 = cl_palette(a)
260 let pb: *u8 = cl_palette(b)
261 var same: i64 = 1
262 var c: i64 = 0
263 if chl_slen(pa) != chl_slen(pb) { same = 0 }
264 while c < chl_slen(pa) { if same == 1 { if pa[c] != pb[c] { same = 0 } } c = c + 1 }
265 if same == 1 { distinct = 0 }
266 b = b + 1
267 }
268 a = a + 1
269 }
270 gv_check_eq("T7a-eight-palette-slots-all-distinct" as *u8, distinct, 1, ctr)
271 gv_check("T7b-slot-past-the-set-wraps-to-a-rival-colour" as *u8, (chl_slen(cl_palette(CL_PAL_N)) > 0) as i64, ctr)
272 gv_kv("junk_label_overlaps" as *u8, old_defects)
273 gv_kv("junk_spread_permil" as *u8, old_spread)
274 gv_kv("fit_spread_permil" as *u8, fit_spread)
275 gv_kv("fit_unresolved" as *u8, unresolved)
276 gv_kv("fit_mark_overlaps" as *u8, fit_mm)
277 gv_kv("tiny_canvas_unresolved" as *u8, tiny_unres)
278 return gv_verdict("nx_chartlay_gate" as *u8, ctr, "domain-fit scales and ticks, the scale both ways, box arithmetic, the placer and the critic on the live junk cluster (junk grades as junk, the fit layout places every label clear and spreads the field), a tiny-canvas neg-control, the palette" as *u8)
279}