code wiki / _hdl_build / nx_contrast.nx
nx_contrast.nx
buildroot/runtime/_hdl_build/nx_contrast.nx
about
nx_contrast.nx -- SOVEREIGN WCAG 2.1 + APCA contrast CLI.
★CONSOLIDATED 2026-07-21: the luminance/contrast/APCA KERNEL now lives in nx_uiq_color (the ONE family
contrast kernel); this is a THIN CLI over it (OO consolidation, D001 migrate-on-touch). The duplicate
srgb_lin/lum/ratio100/apca_* that used to live here are DELETED -> no behaviour lost, one source of truth.
Behaviour-preserving, PROVEN by --kat reproducing the reference values (21.00 / 4.54 / APCA 106.0 / -107.9 / 63.1).
usage: nx_contrast <fg-hex> <bg-hex> e.g. nx_contrast 767676 ffffff | nx_contrast "#000" "#fff"
emits JSON: {"fg","bg","ratio","aa","aaa","aa_large","apca_lc"} | --kat runs the reference battery
license_tier: ORIGINAL genealogy: w3.org/TR/WCAG21 relative-luminance + contrast-ratio
dependencies 1 imports · 0 importers
imports: nx_uiq_color.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 10 | const K_MAGIC_2100: i64 = 2100 |
| 11 | const K_MAGIC_1050: i64 = 1050 |
| 12 | const K_MAGIC_1070: i64 = 1070 |
| 13 | const K_MAGIC_1090: i64 = 1090 |
functions
| 16 | func parse_hex(s: *u8, out: *i64) -> i64 |
| 24 | func pbool(b: i64) -> i64 { if b==1 { uiq_w("true" as *u8) } else { uiq_w("false" as *u8) } return 0 } |
| 25 | func papca(v: i64) -> i64 |
| 32 | func run_kat() -> i64 |
| 63 | func main(argc: i64, argv: *i64) -> i64 |