code wiki / _hdl_build / nx_brand_guard.nx

nx_brand_guard.nx

buildroot/runtime/_hdl_build/nx_brand_guard.nx

6154 B128 linesdepth 4pulls 6 transitivereach 16 importersview sourcekind librarytopic brand
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_css_color_decode.nx nx_brand_tokens.nx fx.nx nx_brand_guard.nx nx_brand_book.nx nx_brand_dark_gate.nx nx_brand_exceed2_gate.nx nx_brand_exceed3_gate.nx nx_brand_guard_gate.nx nx_brand_manage.nx nx_brand_packs_gate.nx nx_brand_spacescale_gate.nx nx_brand_typescale_gate.nx nx_ui_contrast.nx

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

16const BG_005: i64 = 3277 // 0.05 * 65536 (WCAG flare term)
17const BG_THR: i64 = 2651 // 0.04045 * 65536 (sRGB piecewise threshold)
18const BG_1292: i64 = 846746 // 12.92 * 65536
19const BG_1055: i64 = 69141 // 1.055 * 65536
20const BG_0055: i64 = 3604 // 0.055 * 65536
21const BG_24: i64 = 157286 // 2.4 * 65536 (sRGB gamma exponent)
22const BG_LR: i64 = 13934 // 0.2126 * 65536 Rec.709 luma R
23const BG_LG: i64 = 46870 // 0.7152 * 65536 Rec.709 luma G
24const BG_LB: i64 = 4732 // 0.0722 * 65536 Rec.709 luma B

functions

27func bg_chan_lin(c: i64) -> i64
called by 1: bg_rel_lum calls 2: fx_divfx_pow
37func bg_rel_lum(r: i64, g: i64, b: i64) -> i64
called by 1: bg_contrast_x100 calls 2: fx_mulbg_chan_lin
41func bg_contrast_x100(r1: i64, g1: i64, b1: i64, r2: i64, g2: i64, b2: i64) -> i64
called by 1: bg_contrast_hex_x100 calls 1: bg_rel_lum
50func bg_decode_hex(h: *u8, out: *CssColor) -> i64
58func bg_contrast_hex_x100(h1: *u8, h2: *u8) -> i64
66func bg_pair_contrast(brand: *u8, bn: i64, g1: *u8, n1: *u8, g2: *u8, n2: *u8) -> i64
76func bg_num_milli(s: *u8) -> i64
103func bg_space_grid_ok(brand: *u8, bn: i64, name: *u8, unit: i64) -> i64
114func bg_type_scale_ok(brand: *u8, bn: i64) -> i64