code wiki / _hdl_build / nx_brand_guard.nx
nx_brand_guard.nx
buildroot/runtime/_hdl_build/nx_brand_guard.nx
about
nx_brand_guard.nx -- R2 brand-consistency ENFORCEMENT, tied to the design-token SSOT. Three checks, all no-float:
(1) WCAG 2.x contrast ratio between two token colors -- accessibility-as-brand
(2) spacing-grid conformance (space tokens are multiples of a base unit) -- visual rhythm
(3) modular type-scale conformance (headings descend within a sane ratio band) -- typographic consistency
REUSE (audited, not reinvented): nx_css_color_decode (hex->rgb), nx_brand_tokens (bt_lookup), and fx.nx's
ACCURATE Q16.16 fx_pow for the sRGB gamma. NOTE: deliberately NOT nx_aces' pow24 -- that empirical fit carries
~30% error at mid-tones and would misclassify contrast near the 4.5 threshold (hand-verified: #767676/#fff ->
3.6 wrong vs 4.54 true). fx_pow is exp2/log2-based and matches the WCAG reference (validated in the gate, no
overclaim). CONSTANTS are PUBLISHED STANDARDS: sRGB OETF (IEC 61966-2-1) + Rec.709 luma (ITU-R BT.709). Library.
100% sovereign (nx_cc->nxasm, no gcc/JS). license_tier: ORIGINAL
dependencies 4 imports · 10 importers
imports: nx_syscalls.nxnx_css_color_decode.nxnx_brand_tokens.nxfx.nx
imported by: nx_brand_book.nxnx_brand_dark_gate.nxnx_brand_exceed2_gate.nxnx_brand_exceed3_gate.nxnx_brand_guard_gate.nxnx_brand_manage.nxnx_brand_packs_gate.nxnx_brand_spacescale_gate.nxnx_brand_typescale_gate.nxnx_ui_contrast.nx
structs
| none |
consts
| 16 | const BG_005: i64 = 3277 // 0.05 * 65536 (WCAG flare term) |
| 17 | const BG_THR: i64 = 2651 // 0.04045 * 65536 (sRGB piecewise threshold) |
| 18 | const BG_1292: i64 = 846746 // 12.92 * 65536 |
| 19 | const BG_1055: i64 = 69141 // 1.055 * 65536 |
| 20 | const BG_0055: i64 = 3604 // 0.055 * 65536 |
| 21 | const BG_24: i64 = 157286 // 2.4 * 65536 (sRGB gamma exponent) |
| 22 | const BG_LR: i64 = 13934 // 0.2126 * 65536 Rec.709 luma R |
| 23 | const BG_LG: i64 = 46870 // 0.7152 * 65536 Rec.709 luma G |
| 24 | const BG_LB: i64 = 4732 // 0.0722 * 65536 Rec.709 luma B |
functions
| 27 | func bg_chan_lin(c: i64) -> i64 |
| 37 | func bg_rel_lum(r: i64, g: i64, b: i64) -> i64 |
| 41 | func bg_contrast_x100(r1: i64, g1: i64, b1: i64, r2: i64, g2: i64, b2: i64) -> i64 |
| 50 | func bg_decode_hex(h: *u8, out: *CssColor) -> i64 |
| 58 | func bg_contrast_hex_x100(h1: *u8, h2: *u8) -> i64 called by 7: bb_color_rowmainmainbg_pair_contrastmainuc_grade+1 calls 3: sys_mmapbg_decode_hexbg_contrast_x100 |
| 66 | func bg_pair_contrast(brand: *u8, bn: i64, g1: *u8, n1: *u8, g2: *u8, n2: *u8) -> i64 |
| 76 | func bg_num_milli(s: *u8) -> i64 |
| 103 | func bg_space_grid_ok(brand: *u8, bn: i64, name: *u8, unit: i64) -> i64 |
| 114 | func bg_type_scale_ok(brand: *u8, bn: i64) -> i64 |