code wiki / _hdl_build / nx_viz_scale_gate.nx

nx_viz_scale_gate.nx source

↩ module page · 50 lines · 2551 B

1// nx_viz_scale_gate.nx -- REFEREE for the scales layer (KAT for the d3-scale equivalent). 2// T1 linear: 50 in [0,100] -> 250 in [0,500]; endpoints exact 3// T2 band: 4 cats over [0,400] -> band2 start=200, width=100 4// T3 sequential color: black->white at 500permil = 0x7f7f7f; endpoints exact 5// T4 ticks: 5 ticks over [0,100] = 0,25,50,75,100 6// GREEN iff T1..T4. Sovereign: nx_viz_scale + nx_syscalls. license_tier: ORIGINAL 7import "nx_viz_scale.nx" 8import "nx_syscalls.nx" 9import "nx_gate_verdict.nx" 10 11func g_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 12func g_row(name: *u8, ok: i64) -> i64 { 13 if ok == 1 { g_w(" PASS " as *u8) } 14 if ok != 1 { g_w(" FAIL " as *u8) } 15 g_w(name); g_w("\n" as *u8) 16 return ok 17} 18 19func main() -> i64 { 20 g_w("viz-scale gate (the d3-scale equivalent: linear / band / color / ticks)\n" as *u8) 21 var pass: i64 = 0 22 23 var t1: i64 = 0 24 if vs_linear(0, 100, 0, 500, 50) == 250 { if vs_linear(0, 100, 0, 500, 0) == 0 { if vs_linear(0, 100, 0, 500, 100) == 500 { t1 = 1 } } } 25 pass = pass + g_row("T1 linear 50@[0,100]->250@[0,500] + endpoints\x00" as *u8, t1) 26 27 var t2: i64 = 0 28 if vs_band_pos(4, 0, 0, 400, 0) == 0 { if vs_band_pos(4, 2, 0, 400, 0) == 200 { if vs_band_width(4, 0, 400, 0) == 100 { t2 = 1 } } } 29 pass = pass + g_row("T2 band 4@[0,400]: band2=200 width=100\x00" as *u8, t2) 30 31 var t3: i64 = 0 32 if vs_color_lerp(0, 16777215, 500) == 8355711 { if vs_color_lerp(0, 16777215, 0) == 0 { if vs_color_lerp(0, 16777215, 1000) == 16777215 { t3 = 1 } } } 33 pass = pass + g_row("T3 color black->white @500 = 0x7f7f7f + endpoints\x00" as *u8, t3) 34 35 let ticks: *i64 = sys_mmap(64) as *i64 36 let nt: i64 = vs_ticks(0, 100, 5, ticks) 37 var t4: i64 = 0 38 if nt == 5 { if ticks[0] == 0 { if ticks[1] == 25 { if ticks[2] == 50 { if ticks[3] == 75 { if ticks[4] == 100 { t4 = 1 } } } } } } 39 pass = pass + g_row("T4 ticks 5@[0,100] = 0,25,50,75,100\x00" as *u8, t4) 40 41 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 42 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 43 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 44 let ctr__dry: *i64 = gv_ctr() 45 ctr__dry[0] = pass 46 ctr__dry[1] = 4 47 let rc__dry: i64 = gv_verdict("VIZ-SCALE-GATE" as *u8, ctr__dry, "4/4 (scales layer: data -> position/size/color, bits-up)" as *u8) 48 sys_exit(rc__dry) 49 return rc__dry 50}